Skip to content

Commit a40fa55

Browse files
committed
report_converter: use relative file paths for testing ruff
1 parent 97d0131 commit a40fa55

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

tools/report-converter/codechecker_report_converter/analyzers/ruff/analyzer_result.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ def get_reports(self, file_path: str) -> List[Report]:
4949
file_cache: Dict[str, File] = {}
5050
for bug in bugs:
5151
fp = bug.get('filename')
52+
# Ruff uses absolute file names per default.
53+
# However, for the tests, we also try relative filenames!
54+
relative_fp = os.path.join(os.path.dirname(file_path), fp)
55+
if os.path.exists(relative_fp):
56+
fp = relative_fp
5257
if not os.path.exists(fp):
5358
LOG.warning("Source file does not exists: %s", fp)
5459
continue
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# copied from pylint, could
22
all:
3-
ruff check --exit-zero --output-format=json --output-file=./simple.json files/simple.py
3+
ruff check --exit-zero --output-format=json files/simple.py | sed "s#$(PWD)/##" > simple.json

tools/report-converter/tests/unit/analyzers/ruff_output_test_files/simple.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"column": 12,
77
"row": 3
88
},
9-
"filename": "/localdata1/zoel_ml/codechecker/tools/report-converter/tests/unit/analyzers/ruff_output_test_files/files/simple.py",
9+
"filename": "files/simple.py",
1010
"fix": {
1111
"applicability": "safe",
1212
"edits": [

0 commit comments

Comments
 (0)