diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 3b1de7923..e3dd4a79c 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3073,8 +3073,8 @@ void CheckOther::variableScopeError(const Token *tok, const std::string &varname reportError(tok, Severity::information, "variableScope", - "The scope of the variable " + varname + " can be reduced\n" - "The scope of the variable " + varname + " can be reduced. Warning: It can be unsafe " + "The scope of the variable '" + varname + "' can be reduced\n" + "The scope of the variable '" + varname + "' can be reduced. Warning: It can be unsafe " "to fix this message. Be careful. Especially when there are inner loops. Here is an " "example where cppcheck will write that the scope for 'i' can be reduced:\n" "void f(int x)\n" diff --git a/test/testother.cpp b/test/testother.cpp index c3cbdd815..b339fa054 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -547,7 +547,7 @@ private: " for ( ; i < 10; ++i) ;\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable i can be reduced\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable 'i' can be reduced\n", errout.str()); varScope("void f(int x)\n" "{\n" @@ -557,7 +557,7 @@ private: " for ( ; i < 10; ++i) ;\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable i can be reduced\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable 'i' can be reduced\n", errout.str()); } void varScope6() @@ -623,7 +623,7 @@ private: " edgeResistance = (edge+1) / 2.0;\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (information) The scope of the variable edgeResistance can be reduced\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (information) The scope of the variable 'edgeResistance' can be reduced\n", errout.str()); } void varScope9()