Sonar: Replace this use of "unique_ptr" by a raw pointer or a reference (possibly const)

Viewed 39

I have the following piece of code for which Sonar is giving the following warning:

Medium·Code smell·Replace this use of "unique_ptr" by a raw pointer or a reference (possibly const).View report


Result runQuery(const std::string& iQuery,
                const std::unique_ptr<hri::search::n1ql::N1qlClientProxy>& iN1qlClient)
{
    kvclient::N1QLQuery n1qlQuery{iQuery};

    std::vector<std::string> n1qlResult;
    const kvclient::Status&  status = iN1qlClient->query(n1qlQuery, n1qlResult);
    return result;
}

Should I dereference the pointer and pass it as reference? like for instance

Result result = runQuery(iQuery,*iN1qlClient); 

With runQuery being modified to

Result runQuery(const std::string& iQuery, const hri::search::n1ql::N1qlClientProx & iN1qlClient)

Is passing a reference to unique pointer really that bad?

0 Answers
Related