mirror of
https://github.com/github/codeql.git
synced 2025-12-24 12:46:34 +01:00
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)
This commit is contained in:
@@ -1239,12 +1239,11 @@ protected DependencyInstallationResult preparePackagesAndDependencies(Set<Path>
|
||||
String msg = "A parse error occurred: " + StringUtil.escapeMarkdown(err.getMessage())
|
||||
+ ". 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.";
|
||||
// file, relative to the source root
|
||||
String relativeFilePath = null;
|
||||
DiagnosticLocation.Builder builder = DiagnosticLocation.builder();
|
||||
if (file.startsWith(LGTM_SRC)) {
|
||||
relativeFilePath = file.subpath(LGTM_SRC.getNameCount(), file.getNameCount()).toString();
|
||||
builder = builder.setFile(file.subpath(LGTM_SRC.getNameCount(), file.getNameCount()).toString());
|
||||
}
|
||||
DiagnosticLocation diagLoc = DiagnosticLocation.builder()
|
||||
.setFile(relativeFilePath)
|
||||
DiagnosticLocation diagLoc = builder
|
||||
.setStartLine(err.getPosition().getLine())
|
||||
.setStartColumn(err.getPosition().getColumn())
|
||||
.setEndLine(err.getPosition().getLine())
|
||||
|
||||
Reference in New Issue
Block a user