Hi. We have a third-party library and we inherit a class from it. One of the virtual functions violates the rule cpp:S4998 (Replace this use of “unique_ptr” by a raw pointer or a reference (possibly const)) and Sonar is correct here. But also Sonar reports a warning for overridden function in our class which we would like to avoid because we can’t change the third-party library and we have to use the function signature provided by it. An example:
// third party lib
class ThirdPartyClass
{
// This is bad, but we can't change it
virtual void foo(const std::unique_ptr<Something>& pointer);
};
// our code
class Child : public ThirdPartyClass
{
// we have cpp:S4998 here
void foo(const std::unique_ptr<Something>& pointer) override;
};
So, maybe it’s possible to check such rules only for the base class?
We know that some of our rules report “valid” issues on function signatures, but it’s not possible to act on them, because the developer has no control over the function signature (being an override is one prominent case of that situation).
We would like to tackle this problem globally, and I added this rule to the list of affected rules.