Clarify error msg for hidingInheritedPublic (#2474)

This commit is contained in:
Maksim Derbasov 2020-01-05 11:32:39 +03:00 committed by Daniel Marjamäki
parent 4f1e8bc5e7
commit a3ed9116e5
4 changed files with 5 additions and 4 deletions

View File

@ -2650,7 +2650,7 @@ void CheckClass::checkAccessModifierVirtualFunctionsError(const Token *tok, cons
{
reportError(tok, Severity::style, "hidingInheritedPublic",
"$symbol:" + func + "\n"
"The function '$symbol' has more narrow access modifier in a derived class. It could violate a LSP principle.",
"The virtual function '$symbol' is a public in a base class and became not-public in derived. It's violate a substitutability a principle in OOP.",
CWE(0U) /* Unknown CWE! */,
false);
}

View File

@ -253,7 +253,8 @@ private:
"- Duplicated inherited data members\n"
// disabled for now "- If 'copy constructor' defined, 'operator=' also should be defined and vice versa\n"
"- Check that arbitrary usage of public interface does not result in division by zero\n"
"- Check that the 'override' keyword is used when overriding virtual functions\n";
"- Check that the 'override' keyword is used when overriding virtual functions\n"
"- Check that virtual public function not became private in derived class\n";
}
// operatorEqRetRefThis helper functions

View File

@ -100,7 +100,7 @@ private:
// style
"- unused variable\n"
"- allocated but unused variable\n"
"- unred variable\n"
"- unread variable\n"
"- unassigned variable\n"
"- unused struct member\n";
}

View File

@ -7167,7 +7167,7 @@ private:
void accessModifierVirtualFunctions() {
checkAccessModifierVirtualFunctions("struct Base { virtual void f(); };\n"
"struct Derived : Base { private: virtual void f(); };");
ASSERT_EQUALS("[test.cpp:2]: (style) The function 'f' has more narrow access modifier in a derived class. It could violate a LSP principle.\n", errout.str());
ASSERT_EQUALS("[test.cpp:2]: (style) The virtual function 'f' is a public in a base class and became not-public in derived. It's violate a substitutability a principle in OOP.\n", errout.str());
checkAccessModifierVirtualFunctions("struct Base { virtual void f(); };\n"
"struct Derived : Base { virtual void f(); };");