Refactorizations:

- Made several functions (Check*::myName and others) because they don't touch depend on a specific instance. (cppcheck findings)
- Removed description of a check in CheckConst that has moved to CheckIO
This commit is contained in:
PKEuS 2012-08-02 09:50:48 -07:00
parent 28efd10dbd
commit 1b40668e04
21 changed files with 29 additions and 30 deletions

View File

@ -75,7 +75,7 @@ private:
c.returnPointerError(0); c.returnPointerError(0);
} }
std::string myName() const { static std::string myName() {
return "64-bit portability"; return "64-bit portability";
} }

View File

@ -80,7 +80,7 @@ private:
c.multiConditionError(0,1); c.multiConditionError(0,1);
} }
std::string myName() const { static std::string myName() {
return "Match assignments and conditions"; return "Match assignments and conditions";
} }

View File

@ -100,7 +100,7 @@ private:
c.errorReturnAddressOfFunctionParameter(0, "parameter"); c.errorReturnAddressOfFunctionParameter(0, "parameter");
} }
std::string myName() const { static std::string myName() {
return "Auto Variables"; return "Auto Variables";
} }

View File

@ -61,7 +61,7 @@ private:
c.boostForeachError(0); c.boostForeachError(0);
} }
std::string myName() const { static std::string myName() {
return "Boost usage"; return "Boost usage";
} }

View File

@ -246,7 +246,7 @@ public:
} }
private: private:
std::string myName() const { static std::string myName() {
return "Bounds checking"; return "Bounds checking";
} }

View File

@ -153,7 +153,7 @@ void CheckClass::constructors()
} }
} }
bool CheckClass::canNotCopy(const Scope *scope) const bool CheckClass::canNotCopy(const Scope *scope)
{ {
std::list<Function>::const_iterator func; std::list<Function>::const_iterator func;
bool privateAssign = false; bool privateAssign = false;
@ -195,13 +195,13 @@ void CheckClass::initVar(const std::string &varname, const Scope *scope, std::ve
} }
} }
void CheckClass::assignAllVar(std::vector<Usage> &usage) const void CheckClass::assignAllVar(std::vector<Usage> &usage)
{ {
for (std::size_t i = 0; i < usage.size(); ++i) for (std::size_t i = 0; i < usage.size(); ++i)
usage[i].assign = true; usage[i].assign = true;
} }
void CheckClass::clearAllVar(std::vector<Usage> &usage) const void CheckClass::clearAllVar(std::vector<Usage> &usage)
{ {
for (std::size_t i = 0; i < usage.size(); ++i) { for (std::size_t i = 0; i < usage.size(); ++i) {
usage[i].assign = false; usage[i].assign = false;

View File

@ -146,7 +146,7 @@ private:
c.suggestInitializationList(0, "variable"); c.suggestInitializationList(0, "variable");
} }
std::string myName() const { static std::string myName() {
return "Class"; return "Class";
} }
@ -213,13 +213,13 @@ private:
* @brief set all variables in list assigned * @brief set all variables in list assigned
* @param usage reference to usage vector * @param usage reference to usage vector
*/ */
void assignAllVar(std::vector<Usage> &usage) const; static void assignAllVar(std::vector<Usage> &usage);
/** /**
* @brief set all variables in list not assigned and not initialized * @brief set all variables in list not assigned and not initialized
* @param usage reference to usage vector * @param usage reference to usage vector
*/ */
void clearAllVar(std::vector<Usage> &usage) const; static void clearAllVar(std::vector<Usage> &usage);
/** /**
* @brief parse a scope for a constructor or member function and set the "init" flags in the provided varlist * @brief parse a scope for a constructor or member function and set the "init" flags in the provided varlist
@ -230,7 +230,7 @@ private:
*/ */
void initializeVarList(const Function &func, std::list<std::string> &callstack, const Scope *scope, std::vector<Usage> &usage); void initializeVarList(const Function &func, std::list<std::string> &callstack, const Scope *scope, std::vector<Usage> &usage);
bool canNotCopy(const Scope *scope) const; static bool canNotCopy(const Scope *scope);
}; };
/// @} /// @}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@ -107,7 +107,7 @@ private:
} }
/** Short description of class (for --doc) */ /** Short description of class (for --doc) */
std::string myName() const { static std::string myName() {
return "Exception Safety"; return "Exception Safety";
} }

View File

@ -82,7 +82,7 @@ private:
c.unknownPatternError(0, "%typ"); c.unknownPatternError(0, "%typ");
} }
std::string myName() const { static std::string myName() {
return "cppcheck internal API usage"; return "cppcheck internal API usage";
} }

View File

@ -114,7 +114,7 @@ private:
c.invalidScanfFormatWidthError(0, 10, 5, NULL); c.invalidScanfFormatWidthError(0, 10, 5, NULL);
} }
std::string myName() const { static std::string myName() {
return "IO"; return "IO";
} }

View File

@ -123,7 +123,7 @@ private:
c.configurationInfo(0, "f"); // user configuration is needed to complete analysis c.configurationInfo(0, "f"); // user configuration is needed to complete analysis
} }
std::string myName() const { static std::string myName() {
return "Leaks (auto variables)"; return "Leaks (auto variables)";
} }

View File

@ -325,7 +325,7 @@ private:
* Get name of class (--doc) * Get name of class (--doc)
* @return name of class * @return name of class
*/ */
std::string myName() const { static std::string myName() {
return "Memory leaks (function variables)"; return "Memory leaks (function variables)";
} }
@ -382,7 +382,7 @@ private:
void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const
{ } { }
std::string myName() const { static std::string myName() {
return "Memory leaks (class variables)"; return "Memory leaks (class variables)";
} }
@ -421,7 +421,7 @@ private:
void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const
{ } { }
std::string myName() const { static std::string myName() {
return "Memory leaks (struct members)"; return "Memory leaks (struct members)";
} }
@ -460,7 +460,7 @@ private:
c.functionCallLeak(0, "funcName", "funcName"); c.functionCallLeak(0, "funcName", "funcName");
} }
std::string myName() const { static std::string myName() {
return "Memory leaks (address not taken)"; return "Memory leaks (address not taken)";
} }

View File

@ -92,7 +92,7 @@ private:
} }
} }
std::string myName() const { static std::string myName() {
return "Non reentrant functions"; return "Non reentrant functions";
} }

View File

@ -110,7 +110,7 @@ private:
} }
/** Name of check */ /** Name of check */
std::string myName() const { static std::string myName() {
return "Null pointer"; return "Null pointer";
} }

View File

@ -131,7 +131,7 @@ private:
} }
} }
std::string myName() const { static std::string myName() {
return "Obsolete functions"; return "Obsolete functions";
} }

View File

@ -353,7 +353,7 @@ private:
c.moduloAlwaysTrueFalseError(0, "1"); c.moduloAlwaysTrueFalseError(0, "1");
} }
std::string myName() const { static std::string myName() {
return "Other"; return "Other";
} }
@ -380,7 +380,6 @@ private:
"* redundant if\n" "* redundant if\n"
"* bad usage of the function 'strtol'\n" "* bad usage of the function 'strtol'\n"
"* [[CheckUnsignedDivision|unsigned division]]\n" "* [[CheckUnsignedDivision|unsigned division]]\n"
"* Dangerous usage of 'scanf'\n"
"* passing parameter by value\n" "* passing parameter by value\n"
"* [[IncompleteStatement|Incomplete statement]]\n" "* [[IncompleteStatement|Incomplete statement]]\n"
"* [[charvar|check how signed char variables are used]]\n" "* [[charvar|check how signed char variables are used]]\n"

View File

@ -60,7 +60,7 @@ private:
c.postfixOperatorError(0); c.postfixOperatorError(0);
} }
std::string myName() const { static std::string myName() {
return "Using postfix operators"; return "Using postfix operators";
} }

View File

@ -204,7 +204,7 @@ private:
c.uselessCallsEmptyError(0); c.uselessCallsEmptyError(0);
} }
std::string myName() const { static std::string myName() {
return "STL usage"; return "STL usage";
} }

View File

@ -96,7 +96,7 @@ private:
c.uninitvarError(0, "varname"); c.uninitvarError(0, "varname");
} }
std::string myName() const { static std::string myName() {
return "Uninitialized variables"; return "Uninitialized variables";
} }

View File

@ -69,7 +69,7 @@ private:
} }
std::string myName() const { static std::string myName() {
return "Unused functions"; return "Unused functions";
} }

View File

@ -90,7 +90,7 @@ private:
c.unusedStructMemberError(0, "structname", "variable"); c.unusedStructMemberError(0, "structname", "variable");
} }
std::string myName() const { static std::string myName() {
return "UnusedVar"; return "UnusedVar";
} }