Skip to content

Commit

Permalink
Refactorizations:
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
PKEuS committed Aug 2, 2012
1 parent 28efd10 commit 1b40668
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/check64bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class CPPCHECKLIB Check64BitPortability : public Check {
c.returnPointerError(0);
}

std::string myName() const {
static std::string myName() {
return "64-bit portability";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkassignif.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class CPPCHECKLIB CheckAssignIf : public Check {
c.multiConditionError(0,1);
}

std::string myName() const {
static std::string myName() {
return "Match assignments and conditions";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkautovariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class CPPCHECKLIB CheckAutoVariables : public Check {
c.errorReturnAddressOfFunctionParameter(0, "parameter");
}

std::string myName() const {
static std::string myName() {
return "Auto Variables";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkboost.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CPPCHECKLIB CheckBoost : public Check {
c.boostForeachError(0);
}

std::string myName() const {
static std::string myName() {
return "Boost usage";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkbufferoverrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class CPPCHECKLIB CheckBufferOverrun : public Check {
}
private:

std::string myName() const {
static std::string myName() {
return "Bounds checking";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
bool privateAssign = false;
Expand Down Expand Up @@ -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)
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) {
usage[i].assign = false;
Expand Down
8 changes: 4 additions & 4 deletions lib/checkclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class CPPCHECKLIB CheckClass : public Check {
c.suggestInitializationList(0, "variable");
}

std::string myName() const {
static std::string myName() {
return "Class";
}

Expand Down Expand Up @@ -213,13 +213,13 @@ class CPPCHECKLIB CheckClass : public Check {
* @brief set all variables in list assigned
* @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
* @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
Expand All @@ -230,7 +230,7 @@ class CPPCHECKLIB CheckClass : public Check {
*/
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);
};
/// @}
//---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lib/checkexceptionsafety.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class CPPCHECKLIB CheckExceptionSafety : public Check {
}

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

Expand Down
2 changes: 1 addition & 1 deletion lib/checkinternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CPPCHECKLIB CheckInternal : public Check {
c.unknownPatternError(0, "%typ");
}

std::string myName() const {
static std::string myName() {
return "cppcheck internal API usage";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkio.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class CPPCHECKLIB CheckIO : public Check {
c.invalidScanfFormatWidthError(0, 10, 5, NULL);
}

std::string myName() const {
static std::string myName() {
return "IO";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkleakautovar.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check {
c.configurationInfo(0, "f"); // user configuration is needed to complete analysis
}

std::string myName() const {
static std::string myName() {
return "Leaks (auto variables)";
}

Expand Down
8 changes: 4 additions & 4 deletions lib/checkmemoryleak.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class CPPCHECKLIB CheckMemoryLeakInFunction : private Check, public CheckMemoryL
* Get name of class (--doc)
* @return name of class
*/
std::string myName() const {
static std::string myName() {
return "Memory leaks (function variables)";
}

Expand Down Expand Up @@ -382,7 +382,7 @@ class CPPCHECKLIB CheckMemoryLeakInClass : private Check, private CheckMemoryLea
void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const
{ }

std::string myName() const {
static std::string myName() {
return "Memory leaks (class variables)";
}

Expand Down Expand Up @@ -421,7 +421,7 @@ class CPPCHECKLIB CheckMemoryLeakStructMember : private Check, private CheckMemo
void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const
{ }

std::string myName() const {
static std::string myName() {
return "Memory leaks (struct members)";
}

Expand Down Expand Up @@ -460,7 +460,7 @@ class CPPCHECKLIB CheckMemoryLeakNoVar : private Check, private CheckMemoryLeak
c.functionCallLeak(0, "funcName", "funcName");
}

std::string myName() const {
static std::string myName() {
return "Memory leaks (address not taken)";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checknonreentrantfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class CPPCHECKLIB CheckNonReentrantFunctions : public Check {
}
}

std::string myName() const {
static std::string myName() {
return "Non reentrant functions";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checknullpointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class CPPCHECKLIB CheckNullPointer : public Check {
}

/** Name of check */
std::string myName() const {
static std::string myName() {
return "Null pointer";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkobsoletefunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class CPPCHECKLIB CheckObsoleteFunctions : public Check {
}
}

std::string myName() const {
static std::string myName() {
return "Obsolete functions";
}

Expand Down
3 changes: 1 addition & 2 deletions lib/checkother.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ class CPPCHECKLIB CheckOther : public Check {
c.moduloAlwaysTrueFalseError(0, "1");
}

std::string myName() const {
static std::string myName() {
return "Other";
}

Expand All @@ -380,7 +380,6 @@ class CPPCHECKLIB CheckOther : public Check {
"* redundant if\n"
"* bad usage of the function 'strtol'\n"
"* [[CheckUnsignedDivision|unsigned division]]\n"
"* Dangerous usage of 'scanf'\n"
"* passing parameter by value\n"
"* [[IncompleteStatement|Incomplete statement]]\n"
"* [[charvar|check how signed char variables are used]]\n"
Expand Down
2 changes: 1 addition & 1 deletion lib/checkpostfixoperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CPPCHECKLIB CheckPostfixOperator : public Check {
c.postfixOperatorError(0);
}

std::string myName() const {
static std::string myName() {
return "Using postfix operators";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkstl.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class CPPCHECKLIB CheckStl : public Check {
c.uselessCallsEmptyError(0);
}

std::string myName() const {
static std::string myName() {
return "STL usage";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkuninitvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class CPPCHECKLIB CheckUninitVar : public Check {
c.uninitvarError(0, "varname");
}

std::string myName() const {
static std::string myName() {
return "Uninitialized variables";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkunusedfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CPPCHECKLIB CheckUnusedFunctions: public Check {

}

std::string myName() const {
static std::string myName() {
return "Unused functions";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkunusedvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class CPPCHECKLIB CheckUnusedVar : public Check {
c.unusedStructMemberError(0, "structname", "variable");
}

std::string myName() const {
static std::string myName() {
return "UnusedVar";
}

Expand Down

0 comments on commit 1b40668

Please sign in to comment.