Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for static and dynamic analyzer tools.
https://codechecker.readthedocs.io
Apache License 2.0
2.27k stars 383 forks source link

--trim-path-prefix broken in 6.24.0 #4354

Open dholm opened 2 months ago

dholm commented 2 months ago

Describe the bug

We just upgraded from CodeChecker 6.23.1 to 6.24.0 and the --trim-path-prefix option to CodeChecker parse appears to have stopped working as the generated HTML pages are using the absolute path to the build folders on our Jenkins machines now.

CodeChecker version

[INFO 2024-09-24 06:54] - CodeChecker analyzer version:
---------------------------------------------------------------
Kind                 | Version
---------------------------------------------------------------
Base package version | 6.24.0
Package build date   | 2024-08-27T14:08
Git commit ID (hash) | ea795071d62637c69300f4528b6c46c75b2274bc
Git tag information  | 6.24
---------------------------------------------------------------

[INFO 2024-09-24 06:54] - CodeChecker web version:
------------------------------------------------------------------------------
Kind                                | Version
------------------------------------------------------------------------------
Base package version                | 6.24.0
Package build date                  | 2024-08-27T14:08
Git commit ID (hash)                | ea795071d62637c69300f4528b6c46c75b2274bc
Git tag information                 | 6.24
Server supported Thrift API version | 6.58
Client Thrift API version           | 6.58
------------------------------------------------------------------------------

To Reproduce

After analyzing the code, run CodeChecker parse --export html --print-steps --trim-path-prefix "<absolute-path-to-source-code>" --ignore <our-skipfile> --output "<build-dir>/code-checker-report" "<build-dir>/code-checker". Steps to reproduce the behaviour:

Expected behaviour

In the report generated by 6.23.1 it looks like this: image

In the report generated by 6.24.0 it looks like this: image

Desktop (please complete the following information)

dholm commented 1 month ago

We suspect that this also impacts skipfile because our reports now includes all the files in our skipfile as well.

eseiler commented 3 days ago

I encountered the same issue.

https://github.com/Ericsson/codechecker/blob/3229b9bf7db423df206a63afc7788f1f2f60b75c/tools/report-converter/codechecker_report_converter/report/output/html/html.py#L240

Changing report.file.id to report.file.path makes it work again.

Apparently, file.id is the absolute path and file.path the path with (optional) trimming applied.

Version Info ``` CodeChecker analyzer version: --------------------------------------------------------------- Kind | Version --------------------------------------------------------------- Base package version | 6.24.4 Package build date | 2024-10-28T15:46 Git commit ID (hash) | 454d978191ed42c8202a2244dc092dfb6fd8c83a Git tag information | 6.24.4 --------------------------------------------------------------- CodeChecker web version: ------------------------------------------------------------------------------ Kind | Version ------------------------------------------------------------------------------ Base package version | 6.24.4 Package build date | 2024-10-28T15:46 Git commit ID (hash) | 454d978191ed42c8202a2244dc092dfb6fd8c83a Git tag information | 6.24.4 Server supported Thrift API version | 6.58 Client Thrift API version | 6.58 ------------------------------------------------------------------------------ ```

I directly edited the contents installed by pip (/<venv-path>/lib/python3.12/site-packages/codechecker_report_converter/report/output/html/html.py)

Edit:

This might be more robust (i.e., not have unintended side-effects):

diff --git a/tools/report-converter/codechecker_report_converter/report/output/html/html.py b/tools/report-converter/codechecker_report_converter/report/output/html/html.py
index c102199c..85bacfed 100644
--- a/tools/report-converter/codechecker_report_converter/report/output/html/html.py
+++ b/tools/report-converter/codechecker_report_converter/report/output/html/html.py
@@ -309,7 +309,7 @@ class HtmlBuilder:

         table_reports = map(lambda data: {
             'link': os.path.basename(data['link']),
-            'file-path': data['report']['fileId'],
+            'file-path': self.files[data['report']['fileId']]['filePath'],
             'report-hash': data['report']['reportHash'],
             'checker-name': data['report']['checker']['name'],
             'checker-url': data['report']['checker']['url'],