-
Notifications
You must be signed in to change notification settings - Fork 2k
Enrich messages of SARIF results #13179
Copy link
Copy link
Closed
Description
Given the following code snippet:
# test.py
import os
def greet():
print('hello {name}'.format())This is the default output:
$ ruff check test.py
test.py:1:8: F401 [*] `os` imported but unused
|
1 | import os
| ^^ F401
2 |
3 | def greet():
|
= help: Remove unused import: `os`
test.py:4:11: F524 `.format` call is missing argument(s) for placeholder(s): name
|
3 | def greet():
4 | print('hello {name}'.format())
| ^^^^^^^^^^^^^^^^^^^^^^^ F524
|
Found 2 errors.
[*] 1 fixable with the `--fix` option.If we try to get the SARIF output:
ruff check --output-format=sarif test.pyAs shown below, the result messages (e.g. UnusedImport and StringDotFormatMissingArguments) are too short to be informative:
{
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
"runs": [
{
"results": [
{
"level": "error",
"locations": [
{
"physicalLocation": {
"artifactLocation": {...},
"region": {
"endColumn": 10,
"endLine": 1,
"startColumn": 8,
"startLine": 1
}
}
}
],
"message": {
"text": "UnusedImport"
},
"ruleId": "F401"
},
{
"level": "error",
"locations": [
{
"physicalLocation": {
"artifactLocation": {...},
"region": {
"endColumn": 34,
"endLine": 4,
"startColumn": 11,
"startLine": 4
}
}
}
],
"message": {
"text": "StringDotFormatMissingArguments"
},
"ruleId": "F524"
}
],
"tool": {...}
}
],
"version": "2.1.0"
}Also per the SARIF example, the message is as informative as Ruff's default (non-SARIF) one:
"message": {
"text": "'x' is assigned a value but never used."
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels