Skip to content

Commit 605494c

Browse files
committed
Python: Treat SyntaxErrors as warnings in diagnostics
Rename going to happen in second commit, so git doesn't get too confused I don't actually recall where to lookup that warning is 1, and error is 2, but I took this from https://github.com/github/codeql/pull/6830/files#diff-460fc20823ced3b074784db804f2d4d6cfcad4f23fe5d264dc7496c782629a2eR121-R123
1 parent 7feab27 commit 605494c

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed
Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
11
/**
2-
* @name Python extraction errors
3-
* @description List all extraction errors for Python files in the source code directory.
2+
* @name Python extraction warnings
3+
* @description List all extraction warnings for Python files in the source code directory.
44
* @kind diagnostic
5-
* @id py/diagnostics/extraction-errors
5+
* @id py/diagnostics/extraction-warnings
66
*/
77

88
import python
99

1010
/**
11-
* Gets the SARIF severity for errors.
11+
* Gets the SARIF severity for warnings.
1212
*
13-
* See point 3.27.10 in https://docs.oasis-open.org/sarif/sarif/v2.0/sarif-v2.0.html for
14-
* what error means.
13+
* See https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html#_Toc10541338
1514
*/
16-
int getErrorSeverity() { result = 2 }
15+
int getWarningSeverity() { result = 1 }
1716

17+
// The spec
18+
// https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html#_Toc10541338
19+
// defines error and warning as:
20+
//
21+
// "error": A serious problem was found. The condition encountered by the tool resulted
22+
// in the analysis being halted or caused the results to be incorrect or incomplete.
23+
//
24+
// "warning": A problem that is not considered serious was found. The condition
25+
// encountered by the tool is such that it is uncertain whether a problem occurred, or
26+
// is such that the analysis might be incomplete but the results that were generated are
27+
// probably valid.
28+
//
29+
// so SyntaxErrors are reported at the warning level, since analysis might be incomplete
30+
// but the results that were generated are probably valid.
1831
from SyntaxError error, File file
1932
where
2033
file = error.getFile() and
2134
exists(file.getRelativePath())
2235
select error, "Extraction failed in " + file + " with error " + error.getMessage(),
23-
getErrorSeverity()
36+
getWarningSeverity()

0 commit comments

Comments
 (0)