Skip to content

CXX Unknown Rule

Günter Wirth edited this page Nov 14, 2024 · 5 revisions

Starting with cxx plugin version 2.2 all CXX repositories contain a rule with the key unknown. By activating this rule, unknown rules in the reports are not discarded but mapped to this rule. This helps to identify unknown rules, e.g. from newer versions of a tool.

Configuring your project

  • To display issues, the corresponding rules must first be enabled in the Quality Profile being used by the project. Manage Quality Profiles explains the details.
  • Activate the unknown rule in the repository for which you want to report unknown rules in SonarQube. The repositories are assigned to a sensor that is responsible for reading tool-specific reports (e.g. Cppcheck, Clang-Tidy, ...).

Troubleshooting

Understanding the scanner .LOG file

The listing below shows an example of the contents of a scanner .LOG file and describes the specific steps. In order to get all required information, the debug information should be switched on during scanning.

If no rule is active for a sensor, the LOG file contains an entry like this:

10 INFO  ------------- Run sensors on project
11 DEBUG 'CXX Cppcheck report import' skipped because there is no related rule activated in the quality profile
12 DEBUG 'CXX Clang-Tidy report import' skipped because there is no related rule activated in the quality profile
...

If the unknown rule is not active for e.g. Cppcheck, the mapping is switched off and the LOG file contains the following entries:

20 INFO  Sensor CXX Cppcheck report import [cxx]
21 INFO  Rule mapping to 'cppcheck:unknown' is not active
...
22 INFO  Sensor CXX Cppcheck report import [cxx] (done) | time=58ms

If the unknown rule is active for e.g. Cppcheck, the mapping is switched on and the LOG file contains the following entries:

30 INFO  Sensor CXX Cppcheck report import [cxx]
31 INFO  Downloading rules for 'cppcheck' from server 'http://localhost:9000'
...
32 DEBUG 687 rules for 'cppcheck' were loaded from server
...
33 INFO  Rule 'id_of_a_rule_unknown_to_the_server' is unknown in 'cppcheck' and will be mapped to 'unknown'
34 INFO  Processing successful, saved new issues=3
35 INFO  Sensor CXX Cppcheck report import [cxx] (done) | time=501ms
Clone this wiki locally