Rule for unused header files in cpp

Is there a SonarCube rule that will mark a header file include as unneeded - ie none of the variables or classes/functions in it are referenced by the compilation object?

Hello @larry_ciummo,

No, we don’t have any such rule for now (and it’s not so easy at is seems, if you consider indirectly included files). There are other tools, such as https://include-what-you-use.org/ that may provide you with an answer to your question.