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

Parse html export prints unnecessary report #4007

Open NINI1988 opened 1 year ago

NINI1988 commented 1 year ago

Describe the bug Export codeclimate or JSON does only print the generated file output which is enough in my opinion

CodeChecker parse codechecker_build --export codeclimate --output codechecker.codeclimate
[INFO 2023-09-11 10:18] - JSON report file was created: codechecker.codeclimate

But export html prints debug outputs and the complete report which I don't require.

CodeChecker parse codechecker_build --export html --output codechecker.html
Parsing input file '<hidden>.c_cppcheck_717ec1412f7288a5919c4492ce86b853.plist'.
[INFO 2023-09-11 10:18] - No report data in <hidden>.c_cppcheck_717ec1412f7288a5919c4492ce86b853.plist file.
----==== Severity Statistics ====----
----------------------------
Severity | Number of reports
----------------------------
MEDIUM   |                 7
----------------------------
----=================----
----==== Checker Statistics ====----
-----------------------------------------------------------------
Checker name                       | Severity | Number of reports
-----------------------------------------------------------------
cppcheck-nullPointerRedundantCheck | MEDIUM   |                 6
cppcheck-arrayIndexOutOfBoundsCond | MEDIUM   |                 1
-----------------------------------------------------------------
----=================----
----==== File Statistics ====----
-----------------------------------
File name       | Number of reports
-----------------------------------
<hidden1>       |                 6
<hidden2>       |                 1
-----------------------------------
----=================----
----======== Summary ========----
---------------------------------------------
Number of processed analyzer result files | 8
Number of analyzer reports                | 7
---------------------------------------------
----=================----
To view statistics in a browser run:
> firefox codechecker.html/statistics.html
To view the results in a browser run:
> firefox codechecker.html/index.html

I could use >/dev/null to hide outputs but then I don't get the last useful outputs of the export command.

CodeChecker version

[INFO 2023-09-11 10:43] - CodeChecker analyzer version:
---------------------------------------------------------------
Kind                 | Version                                 
---------------------------------------------------------------
Base package version | 6.22.2                                  
Package build date   | 2023-07-13T15:52                        
Git commit ID (hash) | a3d35cfd509b995187288cd8631446415a334257
Git tag information  | 6.22.2                                  
---------------------------------------------------------------

[INFO 2023-09-11 10:43] - CodeChecker web version:
------------------------------------------------------------------------------
Kind                                | Version                                 
------------------------------------------------------------------------------
Base package version                | 6.22.2                                  
Package build date                  | 2023-07-13T15:52                        
Git commit ID (hash)                | a3d35cfd509b995187288cd8631446415a334257
Git tag information                 | 6.22.2                                  
Server supported Thrift API version | 6.53                                    
Client Thrift API version           | 6.53                                    
------------------------------------------------------------------------------

To Reproduce Steps to reproduce the behaviour:

  1. Run command CodeChecker parse codechecker_build --export html --output codechecker.html
  2. See a lot of output

Expected behaviour Parse export for all types should not print the report summary. If the report summary is required call CodeChecker parse codechecker_build without the export argument.

Desktop (please complete the following information)

whisperity commented 1 year ago

The problem is that calling parse twice will require parsing all the output (and the source filed for their source suppression comments) twice, which can get non-trivially expensive for large enough projects, unfortunately.

We could add a (spitballing the exact flag here...) --only-summary option, however.

NINI1988 commented 1 year ago

But you flag should be --no-summary when html output is used? Because if you want only summary then don't use an export argument.

At the moment, in our CI pipeline parse is called 3 times, once for GITLAB as codeclimate, once as html to download for further inspections by a user and the third output is a textual representation to get a fast overview on the CI pipeline and get a return code if new errors has been detected.

- CodeChecker parse codechecker_build --export codeclimate --output codechecker.codeclimate || true
- CodeChecker parse codechecker_build --export html --output codechecker.html >> /dev/null || true # Hide html reports on console (>> /dev/null)
- CodeChecker cmd diff -b codechecker.baseline -n codechecker_build --new # Check if new errors have been found and print results

Maybe the arguments could be like --export html,text,codeclimate -o results.html,result.codeclimate or like --export html -o results.html --export text --export codeclimate -o result.codeclimate Then the user can decide if text output is required or not?