Improve redundant STL container condition -message.
Have separate summary and verbose messages. Se discusion at forum: https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
This commit is contained in:
parent
8d8945ac57
commit
f467e3120e
|
@ -845,11 +845,10 @@ void CheckStl::redundantCondition()
|
|||
|
||||
void CheckStl::redundantIfRemoveError(const Token *tok)
|
||||
{
|
||||
reportError(tok, Severity::style, "redundantIfRemove", "Redundant condition. The remove function in the STL will not do anything if element doesn't exist");
|
||||
reportError(tok, Severity::style, "redundantIfRemove", "Redundant checking of STL container element.\n"
|
||||
"The remove method in the STL will not do anything if element doesn't exist");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CheckStl::missingComparison()
|
||||
{
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
|
|
|
@ -1044,7 +1044,7 @@ private:
|
|||
" if (haystack.find(needle) != haystack.end())\n"
|
||||
" haystack.remove(needle);"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant condition. The remove function in the STL will not do anything if element doesn't exist\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant checking of STL container element.\n", errout.str());
|
||||
}
|
||||
|
||||
void redundantCondition2()
|
||||
|
@ -1056,7 +1056,7 @@ private:
|
|||
" haystack.remove(needle);\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant condition. The remove function in the STL will not do anything if element doesn't exist\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant checking of STL container element.\n", errout.str());
|
||||
}
|
||||
|
||||
void missingInnerComparison1()
|
||||
|
|
Loading…
Reference in New Issue