Open w3ntao opened 7 months ago
Could you please try this with an older version (e.g., LLVM 16.0 or so?) of clang-tidy
? It could be that the changed diagnostic format around the fixits (#4063) are causing problems in the HTML view. What happens if you use CodeChecker parse
directly, without the HTML conversion?
With commands
$ CodeChecker analyze ./build/compile_commands.json --enable sensitive --output ./reports --analyzer-config 'clang-tidy:take-config-from-directory=true'
$ CodeChecker parse ./reports
I got
----==== File Statistics ====----
-------------------------------------
File name | Number of reports
-------------------------------------
main.cpp | 2
functional_hash.h | 1
-------------------------------------
----=================----
Still, 2 errors detected on main.cpp, all of 3 warnings from calculator.cpp
missed.
Does this proves that, this is not a HTML rendering bug?
Yes, the raw output files do not contain the warnings. So this must be an issue with how the analysis is executed. And the problem is likely the conflict between what the .clang-tidy
file says the checker list should be, vs. the --enable sensitive
passed on the command-line.
So regarding this specific bug, is there a workaround solution or do I have to wait for a fixing patch?
We have to investigate what is causing this exactly, why is .clang-tidy
files synergising badly with other CLI arguments. Unfortunately, we are in a release cycle as of right now, so it is likely that this will only be fixed in the following release, not the current one.
Meanwhile, what you can do, is not use the .clang-tidy
file and instead specify the enabled checkers through CodeChecker directly. --enable
takes multiple kinds of arguments: individual checkers, or checker "groups" (such as cppcoreguidelines
), or the profiles like sensitive
. So in your case, "Checks": "cppcoreguidelines-*,performance-*,clang-diagnostic-*"
would likely correspond to --enable cppcoreguidelines --enable performance --enable clang-diagnostic
.
Describe the bug For the same project, clang-tidy alone report 4 warnnings but CodeChecker (that use clang-tidy as backend) produces only 1.
CodeChecker version
To Reproduce
clone the code project, and generate
compile_commands.json
:analyze the project with clang-tidy binary alone and report 4 warnings (3 in
calculator.cpp
and 1 inmain.cpp
):/root/codechecker-bug/calculator.cpp:5:3: warning: avoid using 'goto' for flow control [cppcoreguidelines-avoid-goto] 5 | goto final; | ^
~~~~~ /root/codechecker-bug/calculator.cpp:10:1: note: label defined here 10 | final: | ^ /root/codechecker-bug/calculator.cpp:7:7: warning: variable 'k' is not initialized [cppcoreguidelines-init-variables] 7 | int k; | ^ | = 0 /root/codechecker-bug/calculator.cpp:8:27: warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl] 8 | std::cout << "hello" << std::endl; | ^~~~~ | '\n' /root/codechecker-bug/main.cpp:5:7: warning: variable 'unused_var_in_main' is not initialized [cppcoreguidelines-init-variables] 5 | int unused_var_in_main; | ^| = 0
$ cd codechecker-bug $ CodeChecker analyze ./build/compile_commands.json --enable sensitive --output ./reports --analyzer-config 'clang-tidy:take-config-from-directory=true' $ CodeChecker parse --export html --output ./reports_html ./reports