Rule | Description | Example | KPI |
---|---|---|---|
alpha.valist.CopyToSelf | Experimental: Check for va_lists which are copied onto itself. | Maintainability | |
apiModeling.google.GTest | Model gtest assertion APIs | Maintainability | |
core.builtin.BuiltinFunctions | Evaluate compiler builtin functions (e.g., alloca()) | Maintainability | |
core.builtin.NoReturnFunctions | Evaluate “panic” functions that are known to not return to the caller | Maintainability | |
core.DynamicTypePropagation | Generate dynamic type information | Maintainability | |
deadcode.DeadStores | Check for values stored to variables that are never read afterwards | void test() { int x; x = 1; // warn } | Resource Utilization |
optin.mpi.MPI-Checker | Checks MPI code | void test() { double buf = 0; MPI_Request sendReq1; MPI_Ireduce(MPI_IN_PLACE, &buf, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD, &sendReq1); } // warn: request ‘sendReq1’ has no matching wait. | Maintainability |
osx.API | Check for proper uses of various Apple APIs | void test() { dispatch_once_t pred = 0; dispatch_once(&pred, ^(){}); // warn: dispatch_once uses local } | Maintainability |
unix.StdCLibraryFunctions | Improve modeling of the C standard library functions | Maintainability | |
dynamic-cast | Implementations of dynamic_cast mechanism are unsuitable for use with real-timesystems where low memory usage and determined performance are essential. Dynamic_cast can be replaced with polymorphism, i.e. virtual functions. | Compliant code:
Non-Compliant code: Base* b1 = new Base; | Robustness |
shallow copy assignment | Shallow copy assignment and default assignment operator must be avoided when dynamically allocated resources are involved. | class Shape { //default assignment operator char *ptr; //Non-Compliant }; class Node { char *str; public: Node& operator=(const Node& pOther){ (*this).str = pOther.str; //Non-Compliant return *this; } }; class Foo { char *bar; public: Foo& operator=(const Foo& pOther) { bar = nullptr; //Compliant return *this; } }; class Point { int* xPtr; int* yPtr; public: Point& operator=(const Point& pOther) { xPtr = pOther.xPtr; //Non-Compliant yPtr = new int(); //Compliant return *this; } }; | Robustness |
shallow copy construct | Shallow copy and default copy constructor must be avoided when dynamically allocated resources are involved. | class Shape { //default copy constructor char *ptr; //Non-Compliant }; class Node { char *str; public: Node(const Node& pOther) { (*this).str = pOther.str; //Non-Compliant } }; class Foo { char *bar; public: Foo(const Foo& pOther) { bar = nullptr; //Compliant } }; class Point { int* xPtr; int* yPtr; public: Point(const Point& pOther) { xPtr = pOther.xPtr; //Non-Compliant yPtr = new int(); //Compliant } }; | Robustness |