Skip to content

Commit 0e1d2ad

Browse files
authored
Merge pull request #12746 from alexrford/diagnostics-nullptr-rc-3.9
JS: only set the file in the diagnostics message if the file is within the source root (base rc/3.9)
2 parents 62fcea0 + 0b4f239 commit 0e1d2ad

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,12 +1239,11 @@ private void doExtract(FileExtractor extractor, Path file, ExtractorState state)
12391239
String msg = "A parse error occurred: " + StringUtil.escapeMarkdown(err.getMessage())
12401240
+ ". Check the syntax of the file. If the file is invalid, correct the error or [exclude](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning) the file from analysis.";
12411241
// file, relative to the source root
1242-
String relativeFilePath = null;
1242+
DiagnosticLocation.Builder builder = DiagnosticLocation.builder();
12431243
if (file.startsWith(LGTM_SRC)) {
1244-
relativeFilePath = file.subpath(LGTM_SRC.getNameCount(), file.getNameCount()).toString();
1244+
builder = builder.setFile(file.subpath(LGTM_SRC.getNameCount(), file.getNameCount()).toString());
12451245
}
1246-
DiagnosticLocation diagLoc = DiagnosticLocation.builder()
1247-
.setFile(relativeFilePath)
1246+
DiagnosticLocation diagLoc = builder
12481247
.setStartLine(err.getPosition().getLine())
12491248
.setStartColumn(err.getPosition().getColumn())
12501249
.setEndLine(err.getPosition().getLine())

0 commit comments

Comments
 (0)