Skip to content

Commit 08e3e24

Browse files
Clean up hardcoded.js
Signed-off-by: David A. Wheeler <[email protected]>
1 parent 1d0895c commit 08e3e24

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

docs/labs/hardcoded.js

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,50 @@ info =
22
{
33
hints: [
44
{
5-
absent: String.raw`^ \s* conn = DriverManager \. getConnection \( url \,
6-
`,
7-
text: "Your answer should start with `conn = DriverManager.getConnection( url,` just as the initial value did. You might want to use the `Reset` button.\n"
5+
absent: String.raw`^ \s* conn = DriverManager \. getConnection \( url \,`,
6+
text: "Your answer should start with `conn = DriverManager.getConnection( url,` just as the initial value did. You might want to use the `Reset` button."
87
},
98
{
10-
absent: String.raw`System \. getenv
11-
`,
12-
text: "Use `System.getenv` to retrieve an environment variable value. For example, use `System.getenv(\"USERNAME\")` to retrieve the username.\n"
9+
absent: String.raw`System \. getenv`,
10+
text: "Use `System.getenv` to retrieve an environment variable value. For example, use `System.getenv(\"USERNAME\")` to retrieve the username."
1311
},
1412
{
15-
present: String.raw`System \. getenv \( \"admin\" \)
16-
`,
17-
text: "You need to pass to `System.getenv` the name of an environment variable value, not the result you might get. Do not use constructs like `System.getenv(\"admin\")`. Instead, for example, use `System.getenv(\"USERNAME\")` to retrieve the username.\n"
13+
present: String.raw`System \. getenv \( \"admin\" \)`,
14+
text: "You need to pass to `System.getenv` the name of an environment variable value, not the result you might get. Do not use constructs like `System.getenv(\"admin\")`. Instead, for example, use `System.getenv(\"USERNAME\")` to retrieve the username."
1815
},
1916
{
20-
absent: String.raw`System \. getenv \( \"PASSWORD\" \)
21-
`,
22-
text: "Use `System.getenv` to retrieve an environment variable value. For example, use `System.getenv(\"USERNAME\")` to retrieve the username.\n"
17+
absent: String.raw`System \. getenv \( \"PASSWORD\" \)`,
18+
text: "Use `System.getenv` to retrieve an environment variable value. For example, use `System.getenv(\"USERNAME\")` to retrieve the username."
2319
},
2420
{
2521
present: "admin",
26-
text: "The term 'admin' should not be in your code. You should be retrieving both the username and the password from somewhere else, in this case, from environment variables.\n"
22+
text: "The term 'admin' should not be in your code. You should be retrieving both the username and the password from somewhere else, in this case, from environment variables."
2723
},
2824
{
29-
present: "(system|Getenv|GetEnv)\n",
30-
text: "Java is case-sensitive. You need to use `System.getenv` and not some other variation of uppercase or lowercase.\n"
25+
present: "(system|Getenv|GetEnv)",
26+
text: "Java is case-sensitive. You need to use `System.getenv` and not some other variation of uppercase or lowercase."
3127
},
3228
{
3329
absent: String.raw`\; \s* $`,
34-
text: "Java statements must end with a semicolon.\n"
30+
text: "Java statements must end with a semicolon."
3531
},
3632
{
37-
absent: String.raw`\) \) \; \s* $
38-
`,
39-
text: "Double-check your closing parentheses at the end of the statement.\n"
33+
absent: String.raw`\) \) \; \s* $`,
34+
text: "Double-check your closing parentheses at the end of the statement."
4035
},
4136
{
42-
present: String.raw`new\s+String
43-
`,
44-
text: "You do not need to construct a new string to retrieve an environment variable value.\n"
37+
present: String.raw`new\s+String`,
38+
text: "You do not need to construct a new string to retrieve an environment variable value."
4539
},
4640
{
47-
present: String.raw`^ conn = DriverManager \. getConnection \( url \) \; \s* $
48-
`,
49-
text: "In some sense this is correct, as long as the url is not hardcoded. However, it's often better if administrators can easily change the username or password separately, and it makes out point clearer. Please provide the username and password and separate values.\n"
41+
present: String.raw`^ conn = DriverManager \. getConnection \( url \) \; \s* $`,
42+
text: "In some sense this is correct, as long as the url is not hardcoded. However, it's often better if administrators can easily change the username or password separately, and it makes out point clearer. Please provide the username and password and separate values."
5043
},
5144
{
5245
present: String.raw`^ \s* conn = DriverManager \. getConnection \( url \,
5346
System \. getenv \( "PASSWORD" \) \,
54-
System \. getenv \( "USERNAME" \) \) \; \s* $
55-
`,
56-
text: "The order of parameters is wrong. Provide the url, then the username, then the password. You're providing the url, then the password, then the username, which swaps the second and third parameters.\n"
47+
System \. getenv \( "USERNAME" \) \) \; \s* $`,
48+
text: "The order of parameters is wrong. Provide the url, then the username, then the password. You're providing the url, then the password, then the username, which swaps the second and third parameters."
5749
}
5850
]
5951
}

0 commit comments

Comments
 (0)