Fix ticket #104 (Change (error) Uninitialized member variable -> (style) Member variable not initialized in the constructor)

This commit is contained in:
Reijo Tomperi 2009-02-14 08:52:03 +00:00
parent 6282b5dee8
commit d1e9efc66a
5 changed files with 13 additions and 13 deletions

View File

@ -351,7 +351,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
checkMemoryLeak.CheckMemoryLeak();
// Check that all class constructors are ok.
if (ErrorLogger::noConstructor(_settings) || ErrorLogger::uninitVar())
if (ErrorLogger::noConstructor(_settings) || ErrorLogger::uninitVar(_settings))
checkClass.constructors();
// Check that all base classes have virtual destructors

View File

@ -131,11 +131,11 @@ public:
void uninitVar(const Tokenizer *tokenizer, const Token *Location, const std::string &classname, const std::string &varname)
{
_writemsg(tokenizer, Location, "error", "Uninitialized member variable '" + classname + "::" + varname + "'", "uninitVar");
_writemsg(tokenizer, Location, "style", "Member variable not initialized in the constructor '" + classname + "::" + varname + "'", "uninitVar");
}
static bool uninitVar()
static bool uninitVar(const Settings &s)
{
return true;
return s._checkCodingStyle;
}
void unusedPrivateFunction(const Tokenizer *tokenizer, const Token *Location, const std::string &classname, const std::string &funcname)

View File

@ -169,7 +169,7 @@ private:
" ECODES _code;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:10]: (error) Uninitialized member variable 'Fred::_code'\n", errout.str());
ASSERT_EQUALS("[test.cpp:10]: (style) Member variable not initialized in the constructor 'Fred::_code'\n", errout.str());
}
void uninitVarEnum()
@ -183,7 +183,7 @@ private:
" unsigned int i;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized member variable 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:5]: (style) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
}
void uninitVarStream()
@ -226,7 +226,7 @@ private:
" Foo(int _i) { }\n"
"};\n");
ASSERT_EQUALS(std::string("[test.cpp:7] uninitialized member variable Foo::foo"), errout.str());
ASSERT_EQUALS(std::string("[test.cpp:7] (style) Member variable not initialized in the constructor Foo::foo"), errout.str());
}
@ -277,7 +277,7 @@ private:
" Fred() { }\n"
"};\n"
"#endfile\n");
ASSERT_EQUALS("[fred.h:6]: (error) Uninitialized member variable 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[fred.h:6]: (style) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
}

View File

@ -96,7 +96,7 @@ private:
" Fred() { }\n"
" int i;\n"
"};\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Uninitialized member variable 'Fred::i'\n"), errout.str());
ASSERT_EQUALS(std::string("[test.cpp:4]: (style) Member variable not initialized in the constructor 'Fred::i'\n"), errout.str());
}
@ -110,7 +110,7 @@ private:
"};\n"
"Fred::Fred()\n"
"{ }\n");
ASSERT_EQUALS(std::string("[test.cpp:7]: (error) Uninitialized member variable 'Fred::i'\n"), errout.str());
ASSERT_EQUALS(std::string("[test.cpp:7]: (style) Member variable not initialized in the constructor 'Fred::i'\n"), errout.str());
}
@ -129,7 +129,7 @@ private:
"{\n"
" i = _i;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:8]: (error) Uninitialized member variable 'Fred::i'\n"), errout.str());
ASSERT_EQUALS(std::string("[test.cpp:8]: (style) Member variable not initialized in the constructor 'Fred::i'\n"), errout.str());
}
@ -196,7 +196,7 @@ private:
" void operator=() { }\n"
" int i;\n"
"};\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Uninitialized member variable 'Fred::i'\n"), errout.str());
ASSERT_EQUALS(std::string("[test.cpp:5]: (style) Member variable not initialized in the constructor 'Fred::i'\n"), errout.str());
}
void initvar_operator_eq3()

View File

@ -65,7 +65,7 @@ int main()
// checkclass.cpp..
err.push_back(Message("noConstructor", Message::style, "The class '%1' has no constructor", "classname"));
err.push_back(Message("uninitVar", Message::error, "Uninitialized member variable '%1::%2'", "classname", "varname"));
err.push_back(Message("uninitVar", Message::style, "Member variable not initialized in the constructor '%1::%2'", "classname", "varname"));
err.push_back(Message("unusedPrivateFunction", Message::style, "Unused private function '%1::%2'", "classname", "funcname"));
err.push_back(Message("memsetClass", Message::error, "Using '%1' on class", "memfunc"));
err.push_back(Message("memsetStruct", Message::error, "Using '%1' on struct that contains a 'std::%2'", "memfunc", "classname"));