Improve "Assert statement 'varname' -message.
Modifying the message so that we have short message and verbose message. As discussed in dev-forum: https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
This commit is contained in:
parent
add8584612
commit
8d8945ac57
|
@ -2666,7 +2666,10 @@ void CheckOther::selfAssignmentError(const Token *tok, const std::string &varnam
|
||||||
void CheckOther::assignmentInAssertError(const Token *tok, const std::string &varname)
|
void CheckOther::assignmentInAssertError(const Token *tok, const std::string &varname)
|
||||||
{
|
{
|
||||||
reportError(tok, Severity::warning,
|
reportError(tok, Severity::warning,
|
||||||
"assignmentInAssert", "Assert statement modifies '" + varname + "'. If the modification is needed in release builds there is a bug.");
|
"assignmentInAssert", "Assert statement modifies '" + varname + "'.\n"
|
||||||
|
"Assert statements are removed from release builds so the code inside "
|
||||||
|
"assert statement is not run. If the code is needed also in release "
|
||||||
|
"builds this is a bug.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckOther::incorrectLogicOperatorError(const Token *tok)
|
void CheckOther::incorrectLogicOperatorError(const Token *tok)
|
||||||
|
|
|
@ -1336,7 +1336,7 @@ private:
|
||||||
" return a;\n"
|
" return a;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'. If the modification is needed in release builds there is a bug.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'.\n", errout.str());
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" int a = 0;\n"
|
" int a = 0;\n"
|
||||||
|
@ -1353,7 +1353,7 @@ private:
|
||||||
" return a;\n"
|
" return a;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (warning) Assert statement modifies 'b'. If the modification is needed in release builds there is a bug.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (warning) Assert statement modifies 'b'.\n", errout.str());
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" int a = 0;\n"
|
" int a = 0;\n"
|
||||||
|
@ -1361,7 +1361,7 @@ private:
|
||||||
" return a;\n"
|
" return a;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'. If the modification is needed in release builds there is a bug.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'.\n", errout.str());
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" int a = 0;\n"
|
" int a = 0;\n"
|
||||||
|
@ -1369,7 +1369,7 @@ private:
|
||||||
" return a;\n"
|
" return a;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'. If the modification is needed in release builds there is a bug.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'.\n", errout.str());
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" int a = 0;\n"
|
" int a = 0;\n"
|
||||||
|
@ -1377,7 +1377,7 @@ private:
|
||||||
" return a;\n"
|
" return a;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'. If the modification is needed in release builds there is a bug.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'.\n", errout.str());
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" int a = 0;\n"
|
" int a = 0;\n"
|
||||||
|
@ -1385,7 +1385,7 @@ private:
|
||||||
" return a;\n"
|
" return a;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'. If the modification is needed in release builds there is a bug.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void incorrectLogicOperator()
|
void incorrectLogicOperator()
|
||||||
|
|
Loading…
Reference in New Issue