Skip to content

Commit 3d1da8a

Browse files
committed
JS: Update message when the file is not located in the source root
1 parent 927522c commit 3d1da8a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ private void doExtract(FileExtractor extractor, Path file, ExtractorState state)
12381238
List<ParseError> errors = loc == null ? Collections.emptyList() : loc.getParseErrors();
12391239
for (ParseError err : errors) {
12401240
String msg = "A parse error occurred: " + StringUtil.quoteWithBackticks(err.getMessage().trim())
1241-
+ ". 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.";
1241+
+ ".";
12421242

12431243
Optional<DiagnosticLocation> diagLoc = Optional.empty();
12441244
if (file.startsWith(LGTM_SRC)) {
@@ -1250,13 +1250,17 @@ private void doExtract(FileExtractor extractor, Path file, ExtractorState state)
12501250
.setEndColumn(err.getPosition().getColumn() + 1) // convert from 0-based to 1-based
12511251
.build()
12521252
.getOk();
1253-
}
1254-
if (diagLoc.isPresent()) {
1255-
writeDiagnostics(msg, JSDiagnosticKind.PARSE_ERROR, diagLoc.get());
1256-
} else {
1257-
msg += "\n\nRelated file: " + file;
1258-
writeDiagnostics(msg, JSDiagnosticKind.PARSE_ERROR);
1259-
}
1253+
}
1254+
if (diagLoc.isPresent()) {
1255+
msg += " Check the syntax of the file. If the file is invalid, correct the error or "
1256+
+ "[exclude](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-"
1257+
+ "your-code-for-vulnerabilities-and-errors/customizing-code-scanning) the file from analysis.";
1258+
writeDiagnostics(msg, JSDiagnosticKind.PARSE_ERROR, diagLoc.get());
1259+
} else {
1260+
msg += " The affected file is not located within the code being analyzed."
1261+
+ (Env.systemEnv().isActions() ? " Please see the workflow run logs for more information." : "");
1262+
writeDiagnostics(msg, JSDiagnosticKind.PARSE_ERROR);
1263+
}
12601264
}
12611265
logEndProcess(start, "Done extracting " + file);
12621266
} catch (OutOfMemoryError oom) {

0 commit comments

Comments
 (0)