Closed p4kner closed 4 years ago
Hi @p4kner,
You are using the C and C++ plugin.
The c++ part seams to be not in use, why not using the C++ plugin? The code is the same, only difference is that if you are using C and C++ you can define language specific profiles.
Regards,
Thanks for your helpful reply @guwirth!
Yes the activated rules in the Quality Profile are the Cppcheck C (Community) rules under the Repository heading - not the Cppcheck C++ (Community) rules. The Quality Profile says 522 Rules and 1 Projects (sic). The configured rules are shown as active when accessed via the Activate More Rules option. However I have noticed, that a click on the number of configured rules (the 522 is a hyperlink) opens an overview displaying the message 0 of 0 shown.
Yes, I am configuring the sonar.c.xxx settings. The log indicates, that the upload is being skipped for C++ due to a missing file. This is as expected, as I am not providing a report for C++.
'C++ (Community) CppCheckSensor' skipped because there is no related file in current project
Here are the project properties:
sonar.xml.file.suffixes=.disable-xml
sonar.c.suffixes.sources=.c
sonar.c.suffixes.headers=.h
sonar.c.cppcheck.reportPath=cppcheck-report.xml
Thanks for your remark re the use of both the C and C++ plugins. The aim is to analyse projects in c and others in c++. This should be possible with only the C++ plugin, right? Maybe this is where the problem originates from. I will get on to it!
Cheers!
Hi @p4kner,
the default settings of the C++ plugin are:
sonar.cxx.suffixes.sources=.cxx,.cpp,.cc,.c
sonar.cxx.suffixes.headers=.hxx,.hpp,.hh,.h
Maybe you can try to set them to .dummy (or remove .c) to try if this is the problem?
The aim is to analyse projects in c and others in c++. This should be possible with only the C++ plugin, right?
Yes, The c plugin was introduced to configure the languages c and c++ in a different way (profiles). I think this works only if you have a pure C project and a pure C++ project. In any other case it's anyway mixed.
What the c plugin is doing:
The c plugin is still experimental and we are thinking about to remove it. Do you have reasons to keep it?
Regards,
@p4kner in your log file I saw that sonar.cxx.suffixes.sources/headers is already correct. Must be something different...
@guwirth yes, sorry, I had deactivated the file types .c and .h for C++ in the back end.
We can accomplish what we want without the C Community Plugin. However I don't think this is a case of the plugins interfering, as explained below.
As of now the Sonar Qube instance has been updated to only use the C++ Community plugin.
The C Community plugin has been removed. The default settings of the plugin have been reset. A new quality profile for c++ was created and the rules for Cppchecker were activated. The report path was configured for sonar.cxx.
To no avail.
The log shows that the C++ plugin is active and that the quality profile is being used. But the c++ cppchecker is still being skipped due to no configured rules in the profile.
Calls to the Sonar API show that the quality profile exists and has active rules (522) , as shown in the JSON:
{"key":"AXPdpHEQdeA7Kax_3GIw","name":"cxx-cppcheck-1","language":"c++","languageName":"C++ (Community)","isInherited":true,"parentKey":"AXIw7QvgMHOmZ8q1k1aw","parentName":"Sonar way","isDefault":false,"activeRuleCount":522,"activeDeprecatedRuleCount":0,"projectCount":1,"rulesUpdatedAt":"2020-08-11T13:29:47+0000","lastUsed":"2020-08-11T13:19:41+0000","userUpdatedAt":"2020-08-11T13:29:47+0000","organization":"default-organization","isBuiltIn":false,"actions":{"edit":true,"setAsDefault":true,"copy":true,"associateProjects":true,"delete":true}}
A further call to the API to get the explicit rules for the profile: https://xxx.xxx.xxx/api/rules/search?activation=true&qprofile=AXPdpHEQdeA7Kax_3GIw yields
{"total":0,"p":1,"ps":100,"rules":[]}
This didn't come as too much of a surprise as calls to the page with the activated rules for the quality profile by clicking on the number of rules
https://xxx.xxx.xxx/coding_rules?activation=true&qprofile=AXPdpHEQdeA7Kax_3GIw
sadly still displays the 0 of 0 shown message.
For the SonarWay quality profiles which are available by default, this overview is not empty. However for quality profiles which are created and for which additional rules are added no rules are shown. This has also been tried for rules that have nothing to do with the C++ Community plugin.
This ties in with the message in the log. So when the scanner is querying the active rules for the quality profile of the project during the analysis, no active rules are returned.
My belief is, that this is the real issue and that it is thus not related to sonar-cxx! So once again, thanks for your ideas and I'm terribly sorry for wasting your time @guwirth. I will let you know when our instance is up and running correctly. Maybe someone can learn from this.
@p4kner thx
Description
Upload of pre generated Cppcheck report is being skipped despite activated rules in quality profile.
(I am aware that this sounds similar to issue #1556 .)
Steps to reproduce the problem
With the C (Community) plugin installed, create a new custom quality profile in Sonar Qube back end. Activate the the rules associated with Cppchcek for c. Assign this quality profile to a project in the back end.
Run Cppcheck and generate a report as .xml version 2 on the project locally.
Execute sonar-scanner on project with configured path to report via sonar.c.cppcheck.reportPath.
Expected behavior
Pre generated Cppcheck report is submitted to Sonar Qube on running of sonar-scanner and findings are visible in the back end.
Actual behavior
When running sonar-scanner on a C project which includes a report generated with Cppcheck, the report file is skipped. The given reason is that no corresponding rules are active in the quality profile of the project.
(If the report file is not there, or if the contents are wrong, the upload is being skipped with a different error message. Ar you would expect.)
Known workarounds
No known workaround I'm afraid.
LOG file
Related information
Sonar Qube Community Edition version 7.9.3 (build 33349) C (Community) version 1.3.2 (build 1853) Cppcheck version 1.82 sonar-scanner version 4.4.0 (Linux) -- also tried with 4.0.0