This rule only triggers on the analyzed files, not on files included by the analyzed files. So, the intent is that it does not trigger on a header (.h) file. If that happens to you, it can mean one of two things:
You enabled this rule for SonarQube for IDE, and in SonarQube for IDE, we do analyze header files if the current file is a header. This is a bug, I created CPP-6266 to disable this rule in this mode.
You are seeing this issue in a classical analysis, in which case your analysis might have configuration issues. We would need more information on how you configure it to understand what happens.
This error has been raised by SonarQube for Visual Studio set in connected mode, and the rule is enabled on SonarCloud. But this one reports almost nothing, anyway… The reported errors are very different, in spite the connected mode. See this topic, if you’re interested:
But from what you say, I conclude that I have to wait for the bug resolution.
You can disable this rule. I’m not sure it provides great value anyway.
Knowing that some headers will be subjected to this rule in SonarQube for VisualStudio, you could update the regex so that those headers are accepted
More generally, it looks from this message and some previous ones that you have enabled many (all?) rules that are not enabled by default. I’m not sure what is the purpose of that, and it’s not the typical use of our product.
Well, our coding rules (set before my arrival in the company) say the files must match to the class declared & implemented respectively in .h and .cpp. I suppose it is the reason of the use of this rule.
Well, we’re based on MISRA C++:2008, and there are some other useful rules. But I didn’t add some yet since I’m in charge of Sonar.
“Sonar way” uses 450 rules, and we use “only” 423 rules.