-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang compiler warnings support (like GCC and MSVC) #2325
Comments
Hi @aallrd, please have a look in our Wiki: For the compiler warnings you are right, there is no support yet. Regards, |
Hey @guwirth, Thank you for the quick reply. |
Hi @aallrd, first of all there was already in the past a longer discussion if "compiler issues" makes sense in SQ. A lot of people have the opinion to fix such issues better in the IDE, "treat warnings as errors" and fail already in the CI/CD (instead of forwarding it to SQ). In case you like to add it you could use: Other possibility is to extend our built-in sensor:
Regards, |
I agree that However this is not possible if you already have thousands of warning in a huge codebase shared by hundreds of developers. I'll first check the generic report and the
If I manage that, I'll see if I can contribute a real built-in sensor from that experience. Thank you. |
Hi @aallrd, the sensor is very simple and have to parse the report (warning log) only. It's most likely copy and past from an existing one. For me also interesting what is there in beside the already existing ClangTidy and Diagnostic warnings? Regards, |
I'll probably parse this list to create the XML of rules: https://clang.llvm.org/docs/DiagnosticsReference.html |
We have already scripts parsing clang rule files: Please have also a look into This file contains already Diagnostic messages. |
Indeed, it seems that the Clang warnings are already listed (at least for the ones I checked). |
Hi @aallrd, can you provide a compilation LOG file (a snippet)? What is different in the format compared to ClangTidy? https://clang.llvm.org/extra/clang-tidy/
Regards, |
Compilation with Clang of module X:
Clang Tidy run on module X:
I can get the build compilation log for the whole codeline with Clang (and all the compilation warnings), but I cannot get a Clang Tidy run on all my codeline (too expensive). |
@aallrd thx for the samples. Have to say that I'm not familiar with clang tools... Some general remarks: Writing a sensor to parse the LOG files is simple but to maintain the rules with every update of LLVM a bigger effort. We also like to avoid to maintain same rules at several places. In your sample above the only difference is:
See several possibilities to solve this:
Any proposals? |
Option 3 is probably the best one.
It was enough to get the warnings reported in the SonarQube UI as clang-tidy issues. |
After thinking again about it, think would be best:
|
Can you tell me how to recreate https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/cxx-sensors/src/main/resources/clangtidy.xml? https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/cxx-sensors/src/tools/clangtidy_createrules.py#L572 has the instructions. They seem a bit outdated, though, I guess you are supposed to "clangtidy_new.xml.comparable", then let's call it a "clangtidy_diag_new.xml.comparable", and then "utils_createrules.py mergerules" them. The result is more or less OK. With the llvmorg-19-init tag I have 1,497 warnings, I'm guessing the missing 14 were just removed at in previous llvm versions. But the diff is still giant, with differences in the formatting of the descriptions. Maybe it's the pandoc version? I'm using pandoc 3.1.3 from Ubuntu 24.04. |
Hi @cmorve-te, some generell hints: After extracting the rules with a script it’s still a lot of manual work… Regards, |
close this with #2803 |
Hello,
I am compiling my project with Clang and I would like to feed the compiler warnings from the build log as violations into SonarQube.
It exists and works for GCC and MSVC: https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Compilers
I read the wiki and the opened issues but I could not find this feature/request documented anywhere for Clang.
Maybe I missed something, are you aware of a solution to feed Clang warnings into SonarQube?
The text was updated successfully, but these errors were encountered: