spelling fixes
This commit is contained in:
parent
cc1faad34a
commit
dce16a970d
|
@ -551,8 +551,8 @@ void CheckClass::initializationListUsage()
|
||||||
|
|
||||||
void CheckClass::suggestInitializationList(const Token* tok, const std::string& varname)
|
void CheckClass::suggestInitializationList(const Token* tok, const std::string& varname)
|
||||||
{
|
{
|
||||||
reportError(tok, Severity::performance, "useInitializationList", "Variable '" + varname + "' is assigned in constructor body. Consider to perform initalization in initialization list.\n"
|
reportError(tok, Severity::performance, "useInitializationList", "Variable '" + varname + "' is assigned in constructor body. Consider performing initialization in initialization list.\n"
|
||||||
"When an object of a class is created, the constructors of all member variables are called consecutivly "
|
"When an object of a class is created, the constructors of all member variables are called consecutively "
|
||||||
"in the order the variables are declared, even if you don't explicitly write them to the initialization list. You "
|
"in the order the variables are declared, even if you don't explicitly write them to the initialization list. You "
|
||||||
"could avoid assigning '" + varname + "' a value by passing the value to the constructor in the initialization list.");
|
"could avoid assigning '" + varname + "' a value by passing the value to the constructor in the initialization list.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,8 +160,8 @@ private:
|
||||||
"* 'operator=' should return reference to self\n"
|
"* 'operator=' should return reference to self\n"
|
||||||
"* 'operator=' should check for assignment to self\n"
|
"* 'operator=' should check for assignment to self\n"
|
||||||
"* Constness for member functions\n"
|
"* Constness for member functions\n"
|
||||||
"* Order of initalizations\n"
|
"* Order of initializations\n"
|
||||||
"* Suggest usage of initalization list\n"
|
"* Suggest usage of initialization list\n"
|
||||||
"* Suspicious subtraction from 'this'\n";
|
"* Suspicious subtraction from 'this'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5127,27 +5127,27 @@ private:
|
||||||
" std::string s;\n"
|
" std::string s;\n"
|
||||||
" Fred() { a = 0; s = \"foo\"; }\n"
|
" Fred() { a = 0; s = \"foo\"; }\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Variable 's' is assigned in constructor body. Consider to perform initalization in initialization list.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (performance) Variable 's' is assigned in constructor body. Consider performing initialization in initialization list.\n", errout.str());
|
||||||
|
|
||||||
checkInitializationListUsage("class Fred {\n"
|
checkInitializationListUsage("class Fred {\n"
|
||||||
" std::vector<int> v;\n"
|
" std::vector<int> v;\n"
|
||||||
" Fred() { v = unknown; }\n"
|
" Fred() { v = unknown; }\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Variable 'v' is assigned in constructor body. Consider to perform initalization in initialization list.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (performance) Variable 'v' is assigned in constructor body. Consider performing initialization in initialization list.\n", errout.str());
|
||||||
|
|
||||||
checkInitializationListUsage("class C { std::string s; };\n"
|
checkInitializationListUsage("class C { std::string s; };\n"
|
||||||
"class Fred {\n"
|
"class Fred {\n"
|
||||||
" C c;\n"
|
" C c;\n"
|
||||||
" Fred() { c = unknown; }\n"
|
" Fred() { c = unknown; }\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (performance) Variable 'c' is assigned in constructor body. Consider to perform initalization in initialization list.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (performance) Variable 'c' is assigned in constructor body. Consider performing initialization in initialization list.\n", errout.str());
|
||||||
|
|
||||||
checkInitializationListUsage("class C;\n"
|
checkInitializationListUsage("class C;\n"
|
||||||
"class Fred {\n"
|
"class Fred {\n"
|
||||||
" C c;\n"
|
" C c;\n"
|
||||||
" Fred() { c = unknown; }\n"
|
" Fred() { c = unknown; }\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (performance) Variable 'c' is assigned in constructor body. Consider to perform initalization in initialization list.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (performance) Variable 'c' is assigned in constructor body. Consider performing initialization in initialization list.\n", errout.str());
|
||||||
|
|
||||||
checkInitializationListUsage("class C;\n"
|
checkInitializationListUsage("class C;\n"
|
||||||
"class Fred {\n"
|
"class Fred {\n"
|
||||||
|
@ -5173,7 +5173,7 @@ private:
|
||||||
checkInitializationListUsage("class C;\n"
|
checkInitializationListUsage("class C;\n"
|
||||||
"class Fred {\n"
|
"class Fred {\n"
|
||||||
" C a; int b;\n"
|
" C a; int b;\n"
|
||||||
" Fred() : b(5) { a = b; }\n" // Don't issue a message here: You actually could move it to the initalization list, but it would cause problems if you change the order of the variable declarations.
|
" Fred() : b(5) { a = b; }\n" // Don't issue a message here: You actually could move it to the initialization list, but it would cause problems if you change the order of the variable declarations.
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
@ -5201,7 +5201,7 @@ private:
|
||||||
" std::string a;\n"
|
" std::string a;\n"
|
||||||
" Fred() { a = foo(); }\n"
|
" Fred() { a = foo(); }\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Variable 'a' is assigned in constructor body. Consider to perform initalization in initialization list.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (performance) Variable 'a' is assigned in constructor body. Consider performing initialization in initialization list.\n", errout.str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue