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:
Kimmo Varis 2010-11-29 20:24:08 +02:00
parent 8d8945ac57
commit f467e3120e
2 changed files with 4 additions and 5 deletions

View File

@ -845,11 +845,10 @@ void CheckStl::redundantCondition()
void CheckStl::redundantIfRemoveError(const Token *tok) 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() void CheckStl::missingComparison()
{ {
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())

View File

@ -1044,7 +1044,7 @@ private:
" if (haystack.find(needle) != haystack.end())\n" " if (haystack.find(needle) != haystack.end())\n"
" haystack.remove(needle);" " haystack.remove(needle);"
"}\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 redundantCondition2() void redundantCondition2()
@ -1056,7 +1056,7 @@ private:
" haystack.remove(needle);\n" " haystack.remove(needle);\n"
" }\n" " }\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() void missingInnerComparison1()