Skip to content

Commit f062f8b

Browse files
committed
Fix markdownlint errors for generated files
1 parent f277b85 commit f062f8b

File tree

8 files changed

+53
-50
lines changed

8 files changed

+53
-50
lines changed

extensions/ql-vscode/src/variant-analysis/markdown-generation.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function generateVariantAnalysisMarkdownSummary(
112112
lines.push(`### Results for "${query.name}"`, "");
113113

114114
// Expandable section containing query text
115-
const queryCodeBlock = ["```ql", ...query.text.split("\n"), "```"];
115+
const queryCodeBlock = ["```ql", ...query.text.split("\n"), "```", ""];
116116
lines.push(...buildExpandableMarkdownSection("Query", queryCodeBlock));
117117

118118
// Padding between sections
@@ -128,6 +128,9 @@ export function generateVariantAnalysisMarkdownSummary(
128128
lines.push(`| ${fullName} | [${summary.resultCount} result(s)](${link}) |`);
129129
}
130130

131+
// Add a trailing newline
132+
lines.push("");
133+
131134
return {
132135
fileName: "_summary",
133136
content: lines,
@@ -279,8 +282,8 @@ function generateMarkdownForPathResults(
279282
);
280283
// Indent the snippet to fit with the numbered list.
281284
// The indentation is "n + 2" where the list number is an n-digit number.
282-
const codeSnippetIndented = codeSnippet.map(
283-
(line) => " ".repeat(listNumber.toString().length + 2) + line,
285+
const codeSnippetIndented = codeSnippet.map((line) =>
286+
(" ".repeat(listNumber.toString().length + 2) + line).trimEnd(),
284287
);
285288
pathLines.push(`${listNumber}. ${link}`, ...codeSnippetIndented);
286289
}
@@ -382,7 +385,6 @@ function buildExpandableMarkdownSection(
382385
`<summary>${title}</summary>`,
383386
"",
384387
...contents,
385-
"",
386388
"</details>",
387389
"",
388390
);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../../../../../.markdownlint.json",
3+
"MD010": false, // Hard tabs are from the original snippet in the SARIF file
4+
"MD024": false, // Duplicate headings
5+
"MD033": false, // Inline HTML for <details> and <summary>
6+
"MD051": false // Link fragments are used in Gist to link to other files
7+
}

extensions/ql-vscode/test/unit-tests/data/markdown-generation/interpreted-results/path-problem/expected/result-1-github-codeql.md

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,37 @@
2222
cp.execSync(cmd); // BAD
2323
}
2424
</code></pre>
25-
25+
2626
2. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4-L4)
2727
<pre><code class="javascript"> path = require("path");
2828
function cleanupTemp() {
2929
let cmd = "rm -rf " + <strong>path.join(__dirname, "temp")</strong>;
3030
cp.execSync(cmd); // BAD
3131
}
3232
</code></pre>
33-
33+
3434
3. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4-L4)
3535
<pre><code class="javascript"> path = require("path");
3636
function cleanupTemp() {
3737
let cmd = <strong>"rm -rf " + path.join(__dirname, "temp")</strong>;
3838
cp.execSync(cmd); // BAD
3939
}
4040
</code></pre>
41-
41+
4242
4. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4-L4)
4343
<pre><code class="javascript"> path = require("path");
4444
function cleanupTemp() {
4545
let <strong>cmd = "rm -rf " + path.join(__dirname, "temp")</strong>;
4646
cp.execSync(cmd); // BAD
4747
}
4848
</code></pre>
49-
49+
5050
5. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L5-L5)
5151
<pre><code class="javascript">function cleanupTemp() {
5252
let cmd = "rm -rf " + path.join(__dirname, "temp");
5353
cp.execSync(<strong>cmd</strong>); // BAD
5454
}
5555
</code></pre>
56-
5756

5857
</details>
5958

@@ -79,26 +78,25 @@
7978
<pre><code class="javascript">(function() {
8079
cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD
8180
cp.execSync('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // BAD
82-
81+
8382
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
8483
</code></pre>
85-
84+
8685
2. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6-L6)
8786
<pre><code class="javascript">(function() {
8887
cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD
8988
cp.execSync('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // BAD
90-
89+
9190
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
9291
</code></pre>
93-
92+
9493
3. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6-L6)
9594
<pre><code class="javascript">(function() {
9695
cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD
9796
cp.execSync(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // BAD
98-
97+
9998
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
10099
</code></pre>
101-
102100

103101
</details>
104102

@@ -122,28 +120,27 @@
122120

123121
1. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8)
124122
<pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD
125-
123+
126124
execa.shell('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // NOT OK
127125
execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
128-
126+
129127
</code></pre>
130-
128+
131129
2. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8)
132130
<pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD
133-
131+
134132
execa.shell('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // NOT OK
135133
execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
136-
134+
137135
</code></pre>
138-
136+
139137
3. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8)
140138
<pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD
141-
139+
142140
execa.shell(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // NOT OK
143141
execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
144-
142+
145143
</code></pre>
146-
147144

148145
</details>
149146

@@ -169,26 +166,25 @@
169166
<pre><code class="javascript">
170167
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
171168
execa.shellSync('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // NOT OK
172-
169+
173170
const safe = "\"" + path.join(__dirname, "temp") + "\"";
174171
</code></pre>
175-
172+
176173
2. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9-L9)
177174
<pre><code class="javascript">
178175
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
179176
execa.shellSync('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // NOT OK
180-
177+
181178
const safe = "\"" + path.join(__dirname, "temp") + "\"";
182179
</code></pre>
183-
180+
184181
3. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9-L9)
185182
<pre><code class="javascript">
186183
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
187184
execa.shellSync(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // NOT OK
188-
185+
189186
const safe = "\"" + path.join(__dirname, "temp") + "\"";
190187
</code></pre>
191-
192188

193189
</details>
194190

extensions/ql-vscode/test/unit-tests/data/markdown-generation/interpreted-results/path-problem/expected/result-2-meteor-meteor.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,34 @@
2020
<pre><code class="javascript">
2121
const meteorLocalFolder = '.meteor';
2222
const meteorPath = <strong>path.resolve(rootPath, meteorLocalFolder)</strong>;
23-
23+
2424
module.exports = {
2525
</code></pre>
26-
26+
2727
2. [npm-packages/meteor-installer/config.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/config.js#L39-L39)
2828
<pre><code class="javascript">
2929
const meteorLocalFolder = '.meteor';
3030
const <strong>meteorPath = path.resolve(rootPath, meteorLocalFolder)</strong>;
31-
31+
3232
module.exports = {
3333
</code></pre>
34-
34+
3535
3. [npm-packages/meteor-installer/config.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/config.js#L44-L44)
3636
<pre><code class="javascript"> METEOR_LATEST_VERSION,
3737
extractPath: rootPath,
3838
<strong>meteorPath</strong>,
3939
release: process.env.INSTALL_METEOR_VERSION || METEOR_LATEST_VERSION,
4040
rootPath,
4141
</code></pre>
42-
42+
4343
4. [npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L12-L12)
4444
<pre><code class="javascript">const os = require('os');
4545
const {
4646
<strong>meteorPath</strong>,
4747
release,
4848
startedPath,
4949
</code></pre>
50-
50+
5151
5. [npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L11-L23)
5252
<pre><code class="javascript">const tmp = require('tmp');
5353
const os = require('os');
@@ -67,55 +67,54 @@
6767
const { uninstall } = require('./uninstall');
6868
const {
6969
</code></pre>
70-
70+
7171
6. [npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L259-L259)
7272
<pre><code class="javascript"> if (isWindows()) {
7373
//set for the current session and beyond
7474
child_process.execSync(`setx path "${<strong>meteorPath</strong>}/;%path%`);
7575
return;
7676
}
7777
</code></pre>
78-
78+
7979
7. [npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L259-L259)
8080
<pre><code class="javascript"> if (isWindows()) {
8181
//set for the current session and beyond
8282
child_process.execSync(`setx path "${<strong>meteorPath</strong>}/;%path%`);
8383
return;
8484
}
8585
</code></pre>
86-
86+
8787
8. [npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L259-L259)
8888
<pre><code class="javascript"> if (isWindows()) {
8989
//set for the current session and beyond
9090
child_process.execSync(`setx path "${<strong>meteorPath</strong>}/;%path%`);
9191
return;
9292
}
9393
</code></pre>
94-
94+
9595
9. [npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L259-L259)
9696
<pre><code class="javascript"> if (isWindows()) {
9797
//set for the current session and beyond
9898
child_process.execSync(`setx path "${<strong>meteorPath</strong>}/;%path%`);
9999
return;
100100
}
101101
</code></pre>
102-
102+
103103
10. [npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L259-L259)
104104
<pre><code class="javascript"> if (isWindows()) {
105105
//set for the current session and beyond
106106
child_process.execSync(`setx path "${<strong>meteorPath</strong>}/;%path%`);
107107
return;
108108
}
109109
</code></pre>
110-
110+
111111
11. [npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L259-L259)
112112
<pre><code class="javascript"> if (isWindows()) {
113113
//set for the current session and beyond
114114
child_process.execSync(<strong>`setx path "${meteorPath}/;%path%`</strong>);
115115
return;
116116
}
117117
</code></pre>
118-
119118

120119
</details>
121120

@@ -126,18 +125,17 @@
126125
<pre><code class="javascript">
127126
const meteorLocalFolder = '.meteor';
128127
const meteorPath = <strong>path.resolve(rootPath, meteorLocalFolder)</strong>;
129-
128+
130129
module.exports = {
131130
</code></pre>
132-
131+
133132
2. [npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L259-L259)
134133
<pre><code class="javascript"> if (isWindows()) {
135134
//set for the current session and beyond
136135
child_process.execSync(<strong>`setx path "${meteorPath}/;%path%`</strong>);
137136
return;
138137
}
139138
</code></pre>
140-
141139

142140
</details>
143141

extensions/ql-vscode/test/unit-tests/data/markdown-generation/interpreted-results/problem/expected/_summary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ select t,
4141
| Repository | Results |
4242
| --- | --- |
4343
| github/codeql | [1 result(s)](#file-result-1-github-codeql-md) |
44-
| meteor/meteor | [5 result(s)](#file-result-2-meteor-meteor-md) |
44+
| meteor/meteor | [5 result(s)](#file-result-2-meteor-meteor-md) |

extensions/ql-vscode/test/unit-tests/data/markdown-generation/raw-results/expected/_summary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ select c, c.getNumLines()
3838
| Repository | Results |
3939
| --- | --- |
4040
| github/codeql | [22 result(s)](#file-result-1-github-codeql-md) |
41-
| meteor/meteor | [2 result(s)](#file-result-2-meteor-meteor-md) |
41+
| meteor/meteor | [2 result(s)](#file-result-2-meteor-meteor-md) |

extensions/ql-vscode/test/unit-tests/data/markdown-generation/raw-results/expected/result-1-github-codeql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
| [`functio ... true\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/Statements/UselessComparisonTest/constant.js#L1-L4) | `4` |
2424
| [`functio ... n -1;\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/Statements/UselessComparisonTest/example.js#L1-L12) | `12` |
2525
| [`functio ... turn; }`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/Statements/UselessComparisonTest/tst.js#L8-L8) | `1` |
26-
| [`\| functio ... i+1); \|}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/Statements/UselessComparisonTest/tst.js#L9-L9) | `1` |
26+
| [`\| functio ... i+1); \|}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/Statements/UselessComparisonTest/tst.js#L9-L9) | `1` |

extensions/ql-vscode/test/unit-tests/data/markdown-generation/raw-results/expected/result-2-meteor-meteor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
| c | |
44
| --- | --- |
55
| [`functio ... rn H\|0}`](https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12/packages/logic-solver/minisat.js#L7-L7) | `1` |
6-
| [`functio ... ext;\n\t}`](https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12/packages/sha/sha256.js#L94-L124) | `31` |
6+
| [`functio ... ext;\n\t}`](https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12/packages/sha/sha256.js#L94-L124) | `31` |

0 commit comments

Comments
 (0)