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
{
public:
explicit TestZZZContext(ClassNameTemplate& ctx)
: TaskIf(__func__)
, pCtxM(ctx){}
tasks_helpers::TaskIf::Result run(){
...
pCtxM.asyncSrvCtx->complete(resp);
}
In following class, we have the rule error saying that “complete function is neve used”
class DummyContext{
public:
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
{
public:
std::shared_ptr<DummyContext> asyncSrvCtx = nullptr;
...
};
And TestZZZContext is used here :
class TestZZZContextTest : public testing::Test
{
public:
TestZZZContext ctx_;
TestZZZContext<TestZZZContext> task_;
TestZZZContextTest() :
ctx_(PConstants::MsgTypeEnum::UNDEFINED),
task_(ctx_)
{}
...
};
- what have you tried so far to achieve this