Ticket #2237 (Too long "short" message about iterator increment)
Improve the message for suspicious iterator increment in loop.
This commit is contained in:
parent
837605b05b
commit
2ed14431fe
|
@ -915,9 +915,12 @@ void CheckStl::missingComparison()
|
|||
void CheckStl::missingComparisonError(const Token *incrementToken1, const Token *incrementToken2)
|
||||
{
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "The iterator is incremented at line " << incrementToken1->linenr()
|
||||
<< " and then at line " << incrementToken2->linenr()
|
||||
<< ". The loop might unintentionally skip an element in the container. There is no comparison between these increments to prevent that the iterator is incremented beyond the end.";
|
||||
errmsg << "Missing bounds check for extra iterator increment in loop.\n "
|
||||
<< "The iterator incrementing is suspicious - it is incremented at line "
|
||||
<< incrementToken1->linenr() << " and then at line " << incrementToken2->linenr()
|
||||
<< " The loop might unintentionally skip an element in the container. "
|
||||
<< "There is no comparison between these increments to prevent that the iterator is "
|
||||
<< "incremented beyond the end.";
|
||||
|
||||
reportError(incrementToken1, Severity::warning, "StlMissingComparison", errmsg.str());
|
||||
}
|
||||
|
|
|
@ -1068,7 +1068,7 @@ private:
|
|||
" }\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (warning) The iterator is incremented at line 4 and then at line 2. The loop might unintentionally skip an element in the container. There is no comparison between these increments to prevent that the iterator is incremented beyond the end.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4]: (warning) Missing bounds check for extra iterator increment in loop.\n", errout.str());
|
||||
}
|
||||
|
||||
void missingInnerComparison2()
|
||||
|
|
Loading…
Reference in New Issue