C++ plugin: function is never used

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Sonarqube v8.9

  • what are you trying to achieve
    We would like to know why C++ sonarqube rule appears when it seems it shouldn’t. We have “complete” function is never used

We have a c++ template class:

namespace namespacename
   template<class ClassNameTemplate>
   class TestZZZContext : public tasks_helpers::TaskIf
         explicit TestZZZContext(ClassNameTemplate& ctx)
         : TaskIf(__func__)
         , pCtxM(ctx){}
         tasks_helpers::TaskIf::Result run(){

In following class, we have the rule error saying that “complete function is neve used”

class DummyContext{
    DummyAtt req_;
    std::shared_ptr<xxx::http2::TextHttpResponse> resp_ = nullptr;
    DummyAttContext() {};
    const DummyReq& getReqData() const {
        return req_;
    void complete(const std::shared_ptr<xxx::http2::TextHttpResponse>& resp) {
        resp_ = resp;

DummyContext class is being used here:
class TestZZZContext: public HHHContext
    std::shared_ptr<DummyContext> asyncSrvCtx = nullptr;

And TestZZZContext is used here :
class TestZZZContextTest : public testing::Test
    TestZZZContext ctx_;
    TestZZZContext<TestZZZContext> task_;
    TestZZZContextTest() :
  • what have you tried so far to achieve this

Hello @BeatrizP,

Thanks for your report.

What is the rule that you are referring to? we have S5536 and S1144.
Your shared code isn’t complete so I cannot reproduce the issue.
Either provide a complete example that compiles or generate a reproducer file that helps us reproduce the issue on our side. To generate the reproducer file:

  • Add the reproducer option to the scanner configuration:
    sonar.cfamily.reproducer= "Full path to the .cpp file that has or include the file that has the false-positive"
  • Re-run the scanner to generate a file named sonar-cfamily.reproducer in the project folder.
  • Please share this file. if you think this file contains private information you can send it privately.


Hi Abbas, we have tried to reproduce the issue in a small piece of code, but we cannot. We are suspecting that the issue could happen only in big projects.
We are not allowed to send the project files to you

Hello @BeatrizP,
The size of the project shouldn’t impact how the rule behave. Rules are sensitive to the context, so I’m afraid if you cannot share the reproducer privately or share a fully contained example I will not be able to help.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.