Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2657,8 +2657,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"
Expand Down
6 changes: 3 additions & 3 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class TestOther : public TestFixture
" 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"
Expand All @@ -475,7 +475,7 @@ class TestOther : public TestFixture
" 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()
Expand Down Expand Up @@ -541,7 +541,7 @@ class TestOther : public TestFixture
" 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()
Expand Down