diff --git a/src/check.h b/src/check.h index d00158ee8..dc27e7fe1 100644 --- a/src/check.h +++ b/src/check.h @@ -63,6 +63,9 @@ public: /** get error messages */ virtual void getErrorMessages() = 0; + /** get information about this class */ + virtual std::string classInfo() const = 0; + protected: const Tokenizer * const _tokenizer; const Settings * const _settings; diff --git a/src/checkautovariables.h b/src/checkautovariables.h index 689724b33..b51017029 100644 --- a/src/checkautovariables.h +++ b/src/checkautovariables.h @@ -70,6 +70,16 @@ private: reportError(0, "error", "autoVariables", "Wrong assignement of an auto-variable to an effective parameter of a function"); errorReturnPointerToLocalArray(0); } + + std::string classInfo() const + { + return "Auto variables are deallocated when they go out of scope. " + "A pointer to an auto variable is therefore only valid as " + "long as the auto variable is in scope.[BR]\n" + "Check:\n" + " * returning a pointer to auto variable\n" + " * assignement of an auto-variable to an effective parameter of a function\n"; + } }; //--------------------------------------------------------------------------- diff --git a/src/checkbufferoverrun.h b/src/checkbufferoverrun.h index afb39e49d..c3b9c1fe6 100644 --- a/src/checkbufferoverrun.h +++ b/src/checkbufferoverrun.h @@ -82,6 +82,11 @@ private: outOfBounds(0, "index"); sizeArgumentAsChar(0); } + + std::string classInfo() const + { + return "out of bounds checking"; + } }; //--------------------------------------------------------------------------- diff --git a/src/checkclass.h b/src/checkclass.h index db68e35ec..2d0081c40 100644 --- a/src/checkclass.h +++ b/src/checkclass.h @@ -120,6 +120,17 @@ private: virtualDestructorError(0, "Base", "Derived"); } + + std::string classInfo() const + { + return "Check the code for each class.\n" + " * Missing constructors\n" + " * Are all variables initialized by the constructors?\n" + " * Warn if memset, memcpy etc are used on a class.\n" + " * If it's a base class, check that the destructor is virtual\n" + " * The operator= should return a constant reference to itself\n" + " * Are there unused private functions\n"; + } }; //--------------------------------------------------------------------------- #endif diff --git a/src/checkdangerousfunctions.h b/src/checkdangerousfunctions.h index 9458ad1e3..921322ffa 100644 --- a/src/checkdangerousfunctions.h +++ b/src/checkdangerousfunctions.h @@ -62,7 +62,13 @@ private: dangerousFunctionscanf(0); } - + std::string classInfo() const + { + return "Warn if any of these deprecated functions are used:\n" + " * mktemp\n" + " * gets\n" + " * scanf\n"; + } }; //--------------------------------------------------------------------------- diff --git a/src/checkmemoryleak.h b/src/checkmemoryleak.h index 2e5fffae5..18a395a35 100644 --- a/src/checkmemoryleak.h +++ b/src/checkmemoryleak.h @@ -152,6 +152,11 @@ private: void getErrorMessages() { } + std::string classInfo() const + { + return "Memory leaks (function variables)[BR]\n" + "Is there any allocated memory when a function goes out of scope"; + } }; @@ -199,6 +204,11 @@ private: void getErrorMessages() { } + std::string classInfo() const + { + return "Memory leaks (class variables)[BR]\n" + "If the constructor allocate memory then the destructor must deallocate it."; + } }; diff --git a/src/checkother.h b/src/checkother.h index 6227c2802..a6c218431 100644 --- a/src/checkother.h +++ b/src/checkother.h @@ -163,6 +163,23 @@ private: zerodivError(0); } + std::string classInfo() const + { + return "Other checks\n" + " * C-style pointer cast in cpp file\n" + " * redundant if\n" + " * bad usage of the function 'strtol'\n" + " * bad usage of the function 'sprintf' (overlapping data)\n" + " * division with zero\n" + " * unsigned division\n" + " * unused struct member\n" + " * passing parameter by value\n" + " * char array-index\n" + " * char operand in a bit operation\n" + " * condition that is always true/false\n" + " * unusal pointer arithmetic. For example: \"abc\" + 'd'\n" + " * dereferencing a null pointer\n"; + } }; //--------------------------------------------------------------------------- diff --git a/src/checksecurity.h b/src/checksecurity.h index 1dd36348d..eeb66f7ce 100644 --- a/src/checksecurity.h +++ b/src/checksecurity.h @@ -57,6 +57,11 @@ private: std::cout << "===security===" << "\n"; unvalidatedInput(0); } + + std::string classInfo() const + { + return "This is an unfinnished check that will detect unvalidated input.\n"; + } }; //--------------------------------------------------------------------------- diff --git a/src/checkstl.h b/src/checkstl.h index 47ae57e25..2b036cf4d 100644 --- a/src/checkstl.h +++ b/src/checkstl.h @@ -107,6 +107,15 @@ private: invalidPointerError(0, "pointer"); stlBoundriesError(0); } + + std::string classInfo() const + { + return "STL usage:\n" + " * out of bounds errors\n" + " * misuse of iterators when iterating through a container\n" + " * dereferencing an erased iterator\n" + " * for vectors: using iterator/pointer after push_back has been used\n"; + } }; //---------------------------------------------------------------------------