Skip to content

Commit 735372e

Browse files
committed
Implement PR feedback
1 parent c0187a5 commit 735372e

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

extensions/ql-vscode/src/remote-queries/sarif-processing.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
// A line of more than 8k characters is probably generated.
2020
const CODE_SNIPPET_LARGE_LINE_SIZE_LIMIT = 8192;
2121
// If less than 1% of the line is highlighted, we consider it a small snippet.
22-
const CODE_SNIPPET_HIGHLIGHTED_REGION_MINIMUM_PERCENTAGE = 0.01;
22+
const CODE_SNIPPET_HIGHLIGHTED_REGION_MINIMUM_RATIO = 0.01;
2323

2424
const defaultSeverity = "Warning";
2525

@@ -194,15 +194,14 @@ function getCodeSnippet(
194194
return parseHighlightedLine(line, startLine + index, highlightedRegion);
195195
});
196196

197-
const highlightedCharactersCount = highlightedLines
198-
.map((line) => line.highlightedSection.length)
199-
.reduce((a, b) => a + b, 0);
197+
const highlightedCharactersCount = highlightedLines.reduce(
198+
(a, line) => a + line.highlightedSection.length,
199+
0,
200+
);
200201

201-
const highlightedPercentage = highlightedCharactersCount / text.length;
202+
const highlightedRatio = highlightedCharactersCount / text.length;
202203

203-
if (
204-
highlightedPercentage < CODE_SNIPPET_HIGHLIGHTED_REGION_MINIMUM_PERCENTAGE
205-
) {
204+
if (highlightedRatio < CODE_SNIPPET_HIGHLIGHTED_REGION_MINIMUM_RATIO) {
206205
// If not enough is highlighted and the snippet is large, it's probably generated or bundled code and
207206
// we don't want to show it.
208207
return undefined;

0 commit comments

Comments
 (0)