From f467e3120e4245aed55d18b166993094452f99df Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Mon, 29 Nov 2010 20:24:08 +0200 Subject: [PATCH] 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 --- lib/checkstl.cpp | 5 ++--- test/teststl.cpp | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 22caed155..e28e65043 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -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()) diff --git a/test/teststl.cpp b/test/teststl.cpp index 764e00e3e..b045f22e5 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -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()