Fixed #1669 (Still seeing 'possible style' warnings in 1.43)
This commit is contained in:
parent
5d01047ae4
commit
84c3ec9c4c
|
@ -1216,7 +1216,7 @@ static bool hasMultipleInheritanceGlobal(const Token * start, const std::string
|
|||
|
||||
void CheckClass::operatorEqToSelf()
|
||||
{
|
||||
if (!_settings->_checkCodingStyle || !_settings->inconclusive)
|
||||
if (!_settings->_checkCodingStyle)
|
||||
return;
|
||||
|
||||
const Token *tok2 = _tokenizer->tokens();
|
||||
|
@ -1994,7 +1994,7 @@ void CheckClass::uninitVarError(const Token *tok, const std::string &classname,
|
|||
|
||||
void CheckClass::operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname)
|
||||
{
|
||||
reportError(tok, Severity::possibleStyle, "operatorEqVarError", "Member variable '" + classname + "::" + varname + "' is not assigned a value in '" + classname + "::operator=" + "'");
|
||||
reportError(tok, Severity::style, "operatorEqVarError", "Member variable '" + classname + "::" + varname + "' is not assigned a value in '" + classname + "::operator=" + "'");
|
||||
}
|
||||
|
||||
void CheckClass::unusedPrivateFunctionError(const Token *tok, const std::string &classname, const std::string &funcname)
|
||||
|
@ -2029,5 +2029,5 @@ void CheckClass::operatorEqRetRefThisError(const Token *tok)
|
|||
|
||||
void CheckClass::operatorEqToSelfError(const Token *tok)
|
||||
{
|
||||
reportError(tok, Severity::possibleStyle, "operatorEqToSelf", "'operator=' should check for assignment to self");
|
||||
reportError(tok, Severity::style, "operatorEqToSelf", "'operator=' should check for assignment to self");
|
||||
}
|
||||
|
|
|
@ -479,7 +479,7 @@ private:
|
|||
" return *this;\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (possible style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:5]: (style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
|
||||
// this test has an assignment test but doesn't need it
|
||||
checkOpertorEqToSelf(
|
||||
|
@ -534,7 +534,7 @@ private:
|
|||
" s = strdup(a.s);\n"
|
||||
" return *this;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:7]: (possible style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:7]: (style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
|
||||
// ticket #1224
|
||||
checkOpertorEqToSelf(
|
||||
|
@ -621,7 +621,7 @@ private:
|
|||
" }\n"
|
||||
" };\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (possible style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:8]: (style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
|
||||
// this test has an assignment test but doesn't need it
|
||||
checkOpertorEqToSelf(
|
||||
|
@ -692,7 +692,7 @@ private:
|
|||
" s = strdup(b.s);\n"
|
||||
" return *this;\n"
|
||||
" }\n");
|
||||
ASSERT_EQUALS("[test.cpp:11]: (possible style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:11]: (style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
}
|
||||
|
||||
void operatorEqToSelf3()
|
||||
|
@ -1118,7 +1118,7 @@ private:
|
|||
"private:\n"
|
||||
" char * data;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (possible style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
|
||||
checkOpertorEqToSelf(
|
||||
"class A\n"
|
||||
|
@ -1135,7 +1135,7 @@ private:
|
|||
" strcpy(data, a.data);\n"
|
||||
" return *this;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (possible style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:8]: (style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
|
||||
checkOpertorEqToSelf(
|
||||
"class A\n"
|
||||
|
@ -1151,7 +1151,7 @@ private:
|
|||
"private:\n"
|
||||
" char * data;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (possible style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
|
||||
checkOpertorEqToSelf(
|
||||
"class A\n"
|
||||
|
@ -1168,7 +1168,7 @@ private:
|
|||
" *data = *a.data;\n"
|
||||
" return *this;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (possible style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:8]: (style) 'operator=' should check for assignment to self\n", errout.str());
|
||||
}
|
||||
|
||||
// Check that base classes have virtual destructors
|
||||
|
@ -1763,8 +1763,13 @@ private:
|
|||
" Foo(int _i) { }\n"
|
||||
"};\n");
|
||||
|
||||
// actual results - "possible style" for both messages
|
||||
ASSERT_EQUALS("[test.cpp:5]: (possible style) Member variable not initialized in the constructor 'Foo::foo'\n"
|
||||
"[test.cpp:7]: (possible style) Member variable not initialized in the constructor 'Foo::foo'\n", errout.str());
|
||||
|
||||
// wanted results - "style" for the public constructor
|
||||
TODO_ASSERT_EQUALS("[test.cpp:5]: (possible style) Member variable not initialized in the constructor 'Foo::foo'\n"
|
||||
"[test.cpp:7]: (style) Member variable not initialized in the constructor 'Foo::foo'\n", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -390,7 +390,7 @@ private:
|
|||
" void operator=(const Fred &fred) { }\n"
|
||||
" int i;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (possible style) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:5]: (style) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='\n", errout.str());
|
||||
|
||||
check("struct Fred\n"
|
||||
"{\n"
|
||||
|
@ -398,7 +398,7 @@ private:
|
|||
" void operator=(const Fred &fred) { }\n"
|
||||
" int i;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (possible style) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='\n", errout.str());
|
||||
}
|
||||
|
||||
void initvar_operator_eq3()
|
||||
|
@ -706,7 +706,7 @@ private:
|
|||
"\n"
|
||||
"void Fred::operator=(const Fred &f)\n"
|
||||
"{ }", true);
|
||||
ASSERT_EQUALS("[test.cpp:13]: (possible style) Member variable 'Fred::ints' is not assigned a value in 'Fred::operator='\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:13]: (style) Member variable 'Fred::ints' is not assigned a value in 'Fred::operator='\n", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue