Questions tagged [hardcode]

It is the development practice of writing data considered as configuration or input directly in source code.

Hardcoding is considered a bad practice, source code must be changed every time programmer want to change the hardcoded data. It is commonly used when writing programs that should accept user's input, to avoid complexity the programmer should prefer hardcode the input data in the source code instead handle real input.

153 questions
2
votes
2 answers

How to not hardcode my password (Android)?

in my App i send bugreports via email. I heard that the to hardcode my password here is not secure so how do i protect it? Is it enough to write into my /res/values and then read it from there? The reason for this is that i won't use the internal…
androiddevjedi
  • 143
  • 1
  • 9
2
votes
7 answers

JQuery - Hardcoding HTML in Javascript - Is there a better way to dynamically create dom elements?

I have a lot of messages, and raw HTML that I hard code in my javascript code, such as: var subjectId = $(subject).attr('subjectId'); var subjectName = $(subject).attr('subjectName'); var html = "
Dom
2
votes
0 answers

How to check for hardcoded secrets with with SonarCloud?

We are moving from SonarQube to SonarCloud. In SonarQube we are using Sonar Secrets plugin With the standard built in profiles we couldn´t find hardcodede secrets that we found with this plugin. Now I am not sure what we can do to check for…
Olga
  • 73
  • 1
  • 8
2
votes
4 answers

String array containing expiration credit card years from current year count 10 more years

For the expiration date of credit/debit cards, I am using an array that contains all years since 2020 to 2030: String[] expirationYearArray = { "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030" }; That is a bad…
Jaime Montoya
  • 6,915
  • 14
  • 67
  • 103
2
votes
3 answers

Fortran: Hardcode some code in dependency on an environment variable

Hey there, if the env var "XYZ" is set WHILE compiling, than I want the part: write (STDOUT,*) "Compiled with XYZ" here one more function call bla() to be compiled into the binary. If not, than not. Any way to do it? Thanks a lot!
tim
  • 9,896
  • 20
  • 81
  • 137
2
votes
3 answers

Is it bad practice to base expected results off actual results in unit testing?

A co-worker was reviewing some of my unit-test code on some string generation, which kicked off a lengthy discussion. They said that the expected results should all be hard-coded and was worried that a lot of my test cases were using what was being…
Jay Cork
  • 344
  • 1
  • 6
  • 15
2
votes
2 answers

Android - Hardcode Login not Working

Aim To login to my Admin.xml via AdminLogin.xml Flow of Classes AdminLoginActivity ---> AdminActivity AdminLoginActivityClass import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; …
The Employee 123
  • 494
  • 1
  • 14
  • 27
2
votes
1 answer

How do i find the line or the script file from which the element.style() gets its values dynamically

I am working in a huge application where most things are hard coded badly using javascript/jquery (especially the heights & widths of lot of components).Most has its element.style property rendering some width and height from…
Harikrishnan KayKay
  • 293
  • 1
  • 3
  • 13
2
votes
2 answers

Access SELECT Statement and Hard coded Value

Here is my VB SQL statement that is applied to the rowsource of an unbound list box on Form_Current: SelectionSQL = "SELECT tbl_Patches_Cisco_SAs_Applicability.PatchID, tbl_Patches_Cisco_SAs_Applicability.OS FROM…
gunslingor
  • 1,358
  • 12
  • 34
2
votes
1 answer

Is there a way to avoid hard coding with Mongoose?

Consider the following code, where 'Team' is a mongoose model. var Team = mongoose.model( 'Team' ); Team.find({'GroupName':gname}, function (err, teams) { // Some code } How do I get rid of this hard coding where I hard code 'GroupName':gname…
Gaurav Goel
  • 325
  • 2
  • 14
2
votes
1 answer

Node: How to avoid hardcoding URLs in views?

I need to avoid writing hardcoding URls in Node apps(code or views). Is there a package? Now I write in Jade: a(href='/account/profile') Profile Profile url is hardcoded. I need something like this: a(href=links.accounts.profile()) Profile It…
dumitru
  • 379
  • 2
  • 10
2
votes
1 answer

Python lists without assigning variables

Well, I can easily use this code without errors on Python: >>>> a = range(5, 10) >>>> b = range(15, 20) >>>> a.extend(b) >>>> a [5, 6, 7, 8, 9, 15, 16, 17, 18, 19] I also can use this method, without using b: >>>> a = range(5, 10) >>>>…
ranieri
  • 2,030
  • 2
  • 21
  • 39
2
votes
1 answer

How do I interactively pass arguments to cURL from the shell?

I want to create an alias to get a file using cURL which prompts for the: URL output path username and password of a proxy How would I be able to do this interactively rather than hardcoding everything?
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
1
vote
1 answer

Is it correct to return a hard-coded array needed for recursion in C?

I realized that I need my C function to return 2 values and not just one, so is it correct to return a hard-coded array in this way? int * funct(){ if(condition1){ return{1,1} }else{ return{1,-1} } } I need this return…
1
vote
0 answers

Use of Hard-coded Password (CWE ID 259) C#

I'm using a piece of code related to the HttpClient in C# so passing some of the value as a parameter like: var httpResponse = await this.httpClient.GetAsync(new Uri("https://api.vimeo.com/me/albums/" + playListID + "/videos?access_token=" +…
1
2
3
10 11