Clarify error msg for hidingInheritedPublic (#2474)
This commit is contained in:
parent
4f1e8bc5e7
commit
a3ed9116e5
|
@ -2650,7 +2650,7 @@ void CheckClass::checkAccessModifierVirtualFunctionsError(const Token *tok, cons
|
||||||
{
|
{
|
||||||
reportError(tok, Severity::style, "hidingInheritedPublic",
|
reportError(tok, Severity::style, "hidingInheritedPublic",
|
||||||
"$symbol:" + func + "\n"
|
"$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! */,
|
CWE(0U) /* Unknown CWE! */,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,8 @@ private:
|
||||||
"- Duplicated inherited data members\n"
|
"- Duplicated inherited data members\n"
|
||||||
// disabled for now "- If 'copy constructor' defined, 'operator=' also should be defined and vice versa\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 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
|
// operatorEqRetRefThis helper functions
|
||||||
|
|
|
@ -100,7 +100,7 @@ private:
|
||||||
// style
|
// style
|
||||||
"- unused variable\n"
|
"- unused variable\n"
|
||||||
"- allocated but unused variable\n"
|
"- allocated but unused variable\n"
|
||||||
"- unred variable\n"
|
"- unread variable\n"
|
||||||
"- unassigned variable\n"
|
"- unassigned variable\n"
|
||||||
"- unused struct member\n";
|
"- unused struct member\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -7167,7 +7167,7 @@ private:
|
||||||
void accessModifierVirtualFunctions() {
|
void accessModifierVirtualFunctions() {
|
||||||
checkAccessModifierVirtualFunctions("struct Base { virtual void f(); };\n"
|
checkAccessModifierVirtualFunctions("struct Base { virtual void f(); };\n"
|
||||||
"struct Derived : Base { private: virtual void f(); };");
|
"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"
|
checkAccessModifierVirtualFunctions("struct Base { virtual void f(); };\n"
|
||||||
"struct Derived : Base { virtual void f(); };");
|
"struct Derived : Base { virtual void f(); };");
|
||||||
|
|
Loading…
Reference in New Issue