RuleDescriptionExampleKPI
alpha.valist.CopyToSelfExperimental: Check for va_lists which are copied onto itself.Maintainability
apiModeling.google.GTestModel gtest assertion APIsMaintainability
core.builtin.BuiltinFunctionsEvaluate compiler builtin functions (e.g., alloca())Maintainability
core.builtin.NoReturnFunctionsEvaluate “panic” functions that are known to not return to the callerMaintainability
core.DynamicTypePropagationGenerate dynamic type informationMaintainability
deadcode.DeadStoresCheck for values stored to variables that are never read afterwardsvoid test() { int x; x = 1; // warn }Resource Utilization
optin.mpi.MPI-CheckerChecks MPI codevoid 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.APICheck for proper uses of various Apple APIsvoid test() { dispatch_once_t pred = 0; dispatch_once(&pred, ^(){}); // warn: dispatch_once uses local }Maintainability
unix.StdCLibraryFunctionsImprove modeling of the C standard library functionsMaintainability
dynamic-castImplementations 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:

struct Base {
virtual ~Base() {}
};

struct Derived: Base {
void name() {}
};


Non-Compliant code:
Base* b1 = new Base;
Derived* d = dynamic_cast(b1);


Robustness
shallow copy assignmentShallow 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 constructShallow 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