clarify precedence: made the short message shorter

This commit is contained in:
Daniel Marjamäki 2011-04-02 17:27:36 +02:00
parent 33f743875b
commit 29422b8552
2 changed files with 4 additions and 4 deletions

View File

@ -127,7 +127,7 @@ void CheckOther::clarifyCalculationError(const Token *tok, char op)
reportError(tok, reportError(tok,
Severity::style, Severity::style,
"clarifyCalculation", "clarifyCalculation",
"Suspicious calculation, " + calc + " can be clarified as either " + s1 + " or " + s2 + "\n" + std::string("Clarify calculation precedence for ") + op + " and ?\n" +
"Suspicious calculation. Please use parentheses to clarify the code. " "Suspicious calculation. Please use parentheses to clarify the code. "
"The code " + calc + " should be written as either " + s1 + " or " + s2 + "."); "The code " + calc + " should be written as either " + s1 + " or " + s2 + ".");
} }

View File

@ -2274,12 +2274,12 @@ private:
check("int f(char c) {\n" check("int f(char c) {\n"
" return 10 * (c == 0) ? 1 : 2;\n" " return 10 * (c == 0) ? 1 : 2;\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious calculation, 'a*b?c:d' can be clarified as either '(a*b)?c:d' or 'a*(b?c:d)'\n", errout.str()); ASSERT_EQUALS("[test.cpp:2]: (style) Clarify calculation precedence for * and ?\n", errout.str());
check("void f(char c) {\n" check("void f(char c) {\n"
" printf(\"%i\", 10 * (c == 0) ? 1 : 2);\n" " printf(\"%i\", 10 * (c == 0) ? 1 : 2);\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious calculation, 'a*b?c:d' can be clarified as either '(a*b)?c:d' or 'a*(b?c:d)'\n", errout.str()); ASSERT_EQUALS("[test.cpp:2]: (style) Clarify calculation precedence for * and ?\n", errout.str());
// Ticket #2585 - segmentation fault for invalid code // Ticket #2585 - segmentation fault for invalid code
check("abcdef?" "?<" check("abcdef?" "?<"
@ -2290,7 +2290,7 @@ private:
check("void f(char c) {\n" check("void f(char c) {\n"
" printf(\"%i\", 1 + 1 ? 1 : 2);\n" " printf(\"%i\", 1 + 1 ? 1 : 2);\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious calculation, 'a+b?c:d' can be clarified as either '(a+b)?c:d' or 'a+(b?c:d)'\n", errout.str()); ASSERT_EQUALS("[test.cpp:2]: (style) Clarify calculation precedence for + and ?\n", errout.str());
} }
// clarify conditions with = and comparison // clarify conditions with = and comparison