Skip to content

Commit

Permalink
Path can be none
Browse files Browse the repository at this point in the history
  • Loading branch information
justinchuby authored Nov 12, 2022
1 parent ebef67d commit f5ae005
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tools/convert_to_sarif.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ def parse_single_lintrunner_result(lintrunner_result: dict) -> tuple:
"description":"line too long (81 > 79 characters)\nSee https://www.flake8rules.com/rules/E501.html"
}
"""
if lintrunner_result["path"] is None:
artifact_uri = None
else:
artifact_uri = (
("file://" + lintrunner_result["path"])
if lintrunner_result["path"].startswith("/")
else lintrunner_result["path"]
)
result = {
"ruleId": format_rule_name(lintrunner_result),
"level": severity_to_github_level(lintrunner_result["severity"]),
Expand All @@ -42,9 +50,7 @@ def parse_single_lintrunner_result(lintrunner_result: dict) -> tuple:
{
"physicalLocation": {
"artifactLocation": {
"uri": ("file://" + lintrunner_result["path"])
if lintrunner_result["path"].startswith("/")
else lintrunner_result["path"],
"uri": artifact_uri,
},
"region": {
"startLine": lintrunner_result["line"] or 1,
Expand Down

0 comments on commit f5ae005

Please sign in to comment.