Skip to content

Commit e709228

Browse files
Add trailing commas to text lines
A common error when modifying the JavaScript files is forgetting to add a separating comma to the previous line. This is detected when loading (including any tests), but it's still annoying. To reduce the likelihood of this error, add trailing commas to lines of the form "..." Signed-off-by: David A. Wheeler <[email protected]>
1 parent 32682bb commit e709228

File tree

12 files changed

+91
-91
lines changed

12 files changed

+91
-91
lines changed

docs/labs/argument-injection.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,73 @@ info =
33
hints: [
44
{
55
present: String.raw`exec \(`,
6-
text: "The `exec` function is vulnerable to command injection. Replace it with `execFile` to improve security."
6+
text: "The `exec` function is vulnerable to command injection. Replace it with `execFile` to improve security.",
77
},
88
{
99
absent: String.raw`^[\n\r]*\s*execFile\s*\(`,
10-
text: "Use the `execFile` function instead of `exec` to avoid shell interpretation. Your line should start with `execFile(`."
10+
text: "Use the `execFile` function instead of `exec` to avoid shell interpretation. Your line should start with `execFile(`.",
1111
},
1212
{
1313
absent: String.raw`execFile\s*\(\s*['"${BACKQUOTE}]git['"${BACKQUOTE}]\s*,`,
14-
text: "Separate the command and its arguments. The first argument to `execFile` should be the command 'git' without any of the command arguments."
14+
text: "Separate the command and its arguments. The first argument to `execFile` should be the command 'git' without any of the command arguments.",
1515
},
1616
{
1717
present: String.raw`['"${BACKQUOTE}]git\x20blame['"${BACKQUOTE}]`,
18-
text: "Separate the command and its arguments. The first argument to `execFile` should be the command 'git', followed by an array with parameters, like this: `execFile('git', ['blame', ...])`."
18+
text: "Separate the command and its arguments. The first argument to `execFile` should be the command 'git', followed by an array with parameters, like this: `execFile('git', ['blame', ...])`.",
1919
},
2020
{
2121
absent: String.raw`\[ ['"${BACKQUOTE}]blame`,
22-
text: "Pass the arguments as an array, like this: `execFile('git', ['blame', ...])`."
22+
text: "Pass the arguments as an array, like this: `execFile('git', ['blame', ...])`.",
2323
},
2424
{
2525
present: "--",
2626
absent: String.raw`['"${BACKQUOTE}]--['"${BACKQUOTE}]`,
27-
text: "To pass `--` you need to pass it as a literal string. Typically this is notated as `'--'` or `\"--\"`."
27+
text: "To pass `--` you need to pass it as a literal string. Typically this is notated as `'--'` or `\"--\"`.",
2828
},
2929
{
3030
absent: String.raw`\[ ['"${BACKQUOTE}]blame['"${BACKQUOTE}] , ['"${BACKQUOTE}]--['"${BACKQUOTE}] ,`,
31-
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', ...`."
31+
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', ...`.",
3232
},
3333
{
3434
present: String.raw`['"${BACKQUOTE}]filePath['"${BACKQUOTE}]`,
35-
text: "`filePath` is a variable, use it directly without using quote marks."
35+
text: "`filePath` is a variable, use it directly without using quote marks.",
3636
},
3737
{
3838
present: String.raw`['"]\$\{filePath\}['"]`,
39-
text: "`filePath` is a variable, use it directly without using quote marks."
39+
text: "`filePath` is a variable, use it directly without using quote marks.",
4040
},
4141
{
4242
present: String.raw`${BACKQUOTE}\$\{filePath\}${BACKQUOTE}`,
43-
text: "Strictly speaking, using a backquoted template with a single reference to a variable name works. In this case, it's being done to `filePath`. However, this is unnecessarily complicated. When you want to simply refer to a variable's value, use the variable name."
43+
text: "Strictly speaking, using a backquoted template with a single reference to a variable name works. In this case, it's being done to `filePath`. However, this is unnecessarily complicated. When you want to simply refer to a variable's value, use the variable name.",
4444
},
4545
{
4646
absent: String.raw`\[ ['"${BACKQUOTE}]blame['"${BACKQUOTE}] , ['"${BACKQUOTE}]--['"${BACKQUOTE}] , filePath \]`,
47-
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', filePath]`."
47+
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', filePath]`.",
4848
},
4949
{
5050
present: "shell = [fF]alse",
51-
text: "When passing options to execFile, you need an option with the options, and those use `:` not `=`. So you should say something like: `{shell: false}`."
51+
text: "When passing options to execFile, you need an option with the options, and those use `:` not `=`. So you should say something like: `{shell: false}`.",
5252
},
5353
{
5454
present: "[F]alse",
55-
text: "JavaScript is case-sensitive. The false value is spelled as `false` and not `False`."
55+
text: "JavaScript is case-sensitive. The false value is spelled as `false` and not `False`.",
5656
},
5757
{
5858
absent: String.raw`\{ shell : false \}`,
5959
present: "shell : false",
60-
text: "When passing options to execFile, you must provide those options as a JavaScript object. That means you must surround them with `{...}` like this: `{shell: false}`."
60+
text: "When passing options to execFile, you must provide those options as a JavaScript object. That means you must surround them with `{...}` like this: `{shell: false}`.",
6161
},
6262
{
6363
absent: String.raw`\{ shell : false \}`,
64-
text: "We encourage you to explicitly set `shell: false` in the options object to prevent shell interpretation. That is something like this: `execFile('git', ['blame', '--', filePath], { shell: false }, ...`"
64+
text: "We encourage you to explicitly set `shell: false` in the options object to prevent shell interpretation. That is something like this: `execFile('git', ['blame', '--', filePath], { shell: false }, ...`",
6565
},
6666
{
6767
absent: String.raw`\(\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*,\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*,\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\)\s*=>`,
68-
text: "Maintain the callback function structure with three parameters (typically named error, stdout, and stderr, but any valid variable names are acceptable)."
68+
text: "Maintain the callback function structure with three parameters (typically named error, stdout, and stderr, but any valid variable names are acceptable).",
6969
},
7070
{
7171
present: String.raw`\) \) =>`,
72-
text: "The `exec` function should be closed in later lines, not here."
72+
text: "The `exec` function should be closed in later lines, not here.",
7373
},
7474
],
7575
expected: [

docs/labs/assert.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ info =
1717
},
1818
{
1919
present: "(bindingresult|BindingResult)",
20-
text: "Java is case-sensitive. Use `bindingResult`, not `bindingresult` nor `BindingResult`."
20+
text: "Java is case-sensitive. Use `bindingResult`, not `bindingresult` nor `BindingResult`.",
2121
},
2222
{
2323
present: "(haserrors|HasErrors)",
24-
text: "Java is case-sensitive. Use `hasErrors`, not `haserrors` nor `HasErrors`."
24+
text: "Java is case-sensitive. Use `hasErrors`, not `haserrors` nor `HasErrors`.",
2525
},
2626
{
2727
present: String.raw`^\s*if\s*[^\(\s]`,
@@ -39,25 +39,25 @@ info =
3939
},
4040
{
4141
absent: String.raw`^ if \( bindingResult \. hasErrors \( \) \) `,
42-
text: "Begin the answer with the text `if (bindingResult.hasErrors())` so that a statement will be executed if that condition is true."
42+
text: "Begin the answer with the text `if (bindingResult.hasErrors())` so that a statement will be executed if that condition is true.",
4343
},
4444
{
4545
present: String.raw`if \( bindingResult \. hasErrors \( \) \) [^\{\s] `,
46-
text: "Follow the conditional with an open brace, e.g., `if (bindingResult.hasErrors()) {...`."
46+
text: "Follow the conditional with an open brace, e.g., `if (bindingResult.hasErrors()) {...`.",
4747
},
4848
{
4949
absent: String.raw`return "form"
5050
`,
51-
text: "You need to use `return \"form\";` somewhere."
51+
text: "You need to use `return \"form\";` somewhere.",
5252
},
5353
{
5454
present: String.raw`return "form"`,
5555
absent: String.raw`return "form" ;`,
56-
text: "You need to use `;` (semicolon) after `return \"form\"` because in Java statements must be followed by a semicolon."
56+
text: "You need to use `;` (semicolon) after `return \"form\"` because in Java statements must be followed by a semicolon.",
5757
},
5858
{
5959
absent: String.raw`\} $`,
60-
text: "The answer needs to end with `}` (closing brace)."
60+
text: "The answer needs to end with `}` (closing brace).",
6161
},
6262
],
6363
expected: [

docs/labs/conversion.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ info =
33
hints: [
44
{
55
absent: "unsigned",
6-
text: "The type defined for queue_count should exactly match the return type of get_queue."
6+
text: "The type defined for queue_count should exactly match the return type of get_queue.",
77
},
88
{
99
present: String.raw`unsigned\s+queue_count`,
10-
text: "The declared return type of get_queue is `unsigned int`; you should match it exactly instead of using a synonym like `unsigned`."
10+
text: "The declared return type of get_queue is `unsigned int`; you should match it exactly instead of using a synonym like `unsigned`.",
1111
},
1212
],
1313
expected: [

docs/labs/csp1.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ info =
1212
},
1313
{
1414
absent: "const",
15-
text: "Start with const."
15+
text: "Start with const.",
1616
},
1717
{
1818
absent: String.raw`const\s+helmet =`,
@@ -39,22 +39,22 @@ info =
3939
{
4040
absent: String.raw`\s* app \. use \( helmet \( \{`,
4141
index: 1,
42-
text: "Your code should begin with app.use(helmet({"
42+
text: "Your code should begin with app.use(helmet({",
4343
},
4444
{
4545
absent: String.raw`\s* app \. use \( helmet \( \{
4646
contentSecurityPolicy: \{ \s*
4747
`,
4848
index: 1,
49-
text: "Your code should begin with:\napp.use(helmet({\n contentSecurityPolicy: {\n"
49+
text: "Your code should begin with:\napp.use(helmet({\n contentSecurityPolicy: {\n",
5050
},
5151
{
5252
absent: String.raw`\s* app \. use \( helmet \( \{
5353
contentSecurityPolicy: \{
5454
directives: \{ \s*
5555
`,
5656
index: 1,
57-
text: "Your code should begin with:\napp.use(helmet({\n contentSecurityPolicy: {\n directives: {\n"
57+
text: "Your code should begin with:\napp.use(helmet({\n contentSecurityPolicy: {\n directives: {\n",
5858
},
5959
{
6060
absent: String.raw`\s* app \. use \( helmet \( \{
@@ -63,26 +63,26 @@ info =
6363
"script-src": \[ "'self'" , ["']https://example.com["'] \] , \s*
6464
`,
6565
index: 1,
66-
text: "Your code should continue with:\napp.use(helmet({\n contentSecurityPolicy: {\n directives: {\n \"script-src\": [\"'self'\", \"https://example.com\"],\n"
66+
text: "Your code should continue with:\napp.use(helmet({\n contentSecurityPolicy: {\n directives: {\n \"script-src\": [\"'self'\", \"https://example.com\"],\n",
6767
},
6868
{
6969
absent: String.raw`"style-src": \[ "'self'" \]
7070
`,
7171
index: 1,
72-
text: "Don't forget to include \"style-src\": [\"'self'\"]\n"
72+
text: "Don't forget to include \"style-src\": [\"'self'\"]\n",
7373
},
7474
{
7575
absent: "; $",
7676
index: 1,
77-
text: "JavaScript doesn''t require semicolon terminators, but the rest of the code uses them. You should try to match a coding style when modifying existing code unless there''s an important reason not to. Please update the second statement to use a semicolon terminator."
77+
text: "JavaScript doesn''t require semicolon terminators, but the rest of the code uses them. You should try to match a coding style when modifying existing code unless there''s an important reason not to. Please update the second statement to use a semicolon terminator.",
7878
},
7979
{
8080
absent: String.raw`\} \} \) \) ; $`,
8181
index: 1,
82-
text: "The correct answer is expected to end with `} } ) ) ;` ignoring whitespace. Check that you have matching parentheses and braces."
82+
text: "The correct answer is expected to end with `} } ) ) ;` ignoring whitespace. Check that you have matching parentheses and braces.",
8383
},
8484
{
85-
text: "I do not have more specific hints to provide. Please ensure that the parentheses, braces, and brackets pair correctly, as that is often the problem."
85+
text: "I do not have more specific hints to provide. Please ensure that the parentheses, braces, and brackets pair correctly, as that is often the problem.",
8686
},
8787
],
8888
expected: [

docs/labs/deserialization.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,31 @@ info =
2727
},
2828
{
2929
term: "CONDALL",
30-
value: "(COND0 && (COND1 && COND2|COND2 && COND1))"
30+
value: "(COND0 && (COND1 && COND2|COND2 && COND1))",
3131
},
3232
],
3333
hints: [
3434
{
3535
absent: "^ const data =\n",
36-
text: "The first section should begin with `const data =`"
36+
text: "The first section should begin with `const data =`",
3737
},
3838
{
3939
present: "json",
40-
text: "the JSON built-in global object is witten in uppercase."
40+
text: "the JSON built-in global object is witten in uppercase.",
4141
},
4242
{
4343
absent: String.raw`JSON \. parse
4444
`,
45-
text: "Make a call to `JSON.parse` with the data retrieved, e.g., `JSON.parse(base64Decoded)` should be stored in `data`."
45+
text: "Make a call to `JSON.parse` with the data retrieved, e.g., `JSON.parse(base64Decoded)` should be stored in `data`.",
4646
},
4747
{
4848
present: String.raw`\+
4949
`,
50-
text: "You should not have any concatenation (`+`) in the first section."
50+
text: "You should not have any concatenation (`+`) in the first section.",
5151
},
5252
{
5353
absent: "; $\n",
54-
text: "JavaScript does not require semicolons at the end of a statement, but since the other statements terminate with semicolons, you should also terminate your statement with a semicolon to be consistent."
54+
text: "JavaScript does not require semicolons at the end of a statement, but since the other statements terminate with semicolons, you should also terminate your statement with a semicolon to be consistent.",
5555
},
5656
{
5757
absent: String.raw`^ if \(`,
@@ -68,28 +68,28 @@ info =
6868
absent: String.raw`data \. username
6969
`,
7070
index: 1,
71-
text: "Check if the data object has a property called username. You can do this by referencing data.username."
71+
text: "Check if the data object has a property called username. You can do this by referencing data.username.",
7272
},
7373
{
7474
absent: String.raw`\&\&`,
7575
index: 1,
76-
text: "To combine multiple conditions in JavaScript use &&. This operator means 'and', so both conditions must be true for the entire statement to pass."
76+
text: "To combine multiple conditions in JavaScript use &&. This operator means 'and', so both conditions must be true for the entire statement to pass.",
7777
},
7878
{
7979
absent: "typeof",
8080
index: 1,
81-
text: "Use typeof to check the type of the operand's value. You should have `typeof data.username == 'string'` or similar."
81+
text: "Use typeof to check the type of the operand's value. You should have `typeof data.username == 'string'` or similar.",
8282
},
8383
{
8484
present: String.raw`typeof data \. username == 'String'
8585
`,
8686
index: 1,
87-
text: "When using typeof, JavaScript expects \"string\" all lowercase."
87+
text: "When using typeof, JavaScript expects \"string\" all lowercase.",
8888
},
8989
{
9090
absent: "length",
9191
index: 1,
92-
text: "check if the length of the string is smaller than 20 characters. Use the expression `data.username.length &lt; 20` to determine this."
92+
text: "check if the length of the string is smaller than 20 characters. Use the expression `data.username.length &lt; 20` to determine this.",
9393
},
9494
{
9595
present: String.raw`^ if \(`,

docs/labs/format-strings.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ info =
44
{
55
present: String.raw`def format_event \( user_input
66
`,
7-
text: "The `user_format` should no longer be used, so we should remove it from the list of parameters being passed into the function being defined by `def`. The first line should read `def format_event(new_event):`"
7+
text: "The `user_format` should no longer be used, so we should remove it from the list of parameters being passed into the function being defined by `def`. The first line should read `def format_event(new_event):`",
88
},
99
{
1010
present: "user_input",
11-
text: "Do not support a user-provided format at all. In this case there is no need for it."
11+
text: "Do not support a user-provided format at all. In this case there is no need for it.",
1212
},
1313
{
1414
absent: "event",
15-
text: "We want to see `event`, e.g., return '{event.level},...'.format(event=new_event)"
15+
text: "We want to see `event`, e.g., return '{event.level},...'.format(event=new_event)",
1616
},
1717
{
1818
present: String.raw`\{0`,
19-
text: "For our purposes we want to use named parameters, so do not use `{0}` or similar."
19+
text: "For our purposes we want to use named parameters, so do not use `{0}` or similar.",
2020
},
2121
{
2222
absent: String.raw`\'\{event.level\},\{event.message\}\'
2323
`,
24-
text: "The constant text `'{event.level},{event.message}'` should be present."
24+
text: "The constant text `'{event.level},{event.message}'` should be present.",
2525
},
2626
],
2727
expected: [

docs/labs/free.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ info =
2222
},
2323
{
2424
absent: "return",
25-
text: "This fails to return the result."
25+
text: "This fails to return the result.",
2626
},
2727
{
2828
absent: String.raw`\s* [^;]+;[^;]+;[^;]+; \s*`,

docs/labs/handling-errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ info =
44
{
55
index: 0,
66
absent: "; $",
7-
text: "This code uses the convention of terminating each line with a semicolon; please follow the conventions of the code being modified.\n"
7+
text: "This code uses the convention of terminating each line with a semicolon; please follow the conventions of the code being modified.\n",
88
},
99
{
1010
index: 0,

0 commit comments

Comments
 (0)