6.2.12.10. GeneralPurpose¶
GeneralPurpose/Best practice checks
Nested Rules
A binary arithmetic operator and a bitwise operator shall return a “basic value” that is a type that is not a pointer / reference of cv-qualified |
|
An assignment operator shall return a reference to “this” |
|
A user-defined assignment operator shall not be virtual |
|
Parenthesis in Macro Definitions should be balanced |
|
Destructor of a polymorphic class shall be virtual or protected non-virtual |
|
There shall be no calls to blocking functions in a critical region |
|
The std::move shall not be used on objects declared const or const& |
|
Line-splicing shall not be used in // comments |
|
Fix all compiler warnings and errors |
|
A for-loop that loops through all elements of the container and does not use its loop-counter other than to index a container could be a range-based loop |
|
Reports uses of the default constructor for the blacklisted classes |
|
The allocation and deallocation operators delete and new should be declared in the same scope |
|
Pointers to incomplete class types shall not be deleted |
|
Digraphs should not be used |
|
Different include files should not use the same include guard |
|
Validates the use of format specifiers |
|
Forwarding values to other functions shall be done via: (1) std::move if the value is an rvalue reference, (2) std::forward if the value is forwarding reference |
|
Identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide that identifier |
|
A constructor must initialize all data members of the class |
|
The validity of values passed to library functions shall be checked |
|
A lambda expression object shall not outlive any of its reference-captured objects |
|
Do not assign a reference or pointer to a temporary object or a subobject thereof |
|
Do not include C header files into C++ without ‘extern “C”’ |
|
Fix all linker warnings and errors |
|
Reserved identifiers, macros and functions in the standard library shall not be defined, redefined or undefined |
|
Do call the base class copy constructor or assignment operator, if you implement a copy constructor or assignment operator in a derived class |
|
Include files need an include guard |
|
Override of functions is only permitted with keyword override |
|
Consistently use either the keyword class or struct per composite type, do not mix them |
|
Argument name equals one of the names of the parameters, but not to the one corresponding to the argument |
|
Move constructor shall not initialize its class members and base classes using copy semantics |
|
Non-static data members or captured values of predicate function objects that are state related to this object’s identity shall not be copied |
|
Narrow and wide string literals shall not be concatenated |
|
Non-virtual member functions shall not be redefined in derived classes |
|
Do not overload certain operators |
|
No pure virtual member calls from within its constructor or destructor |
|
Do not return a reference or pointer to a local variable |
|
Avoid rethrowing with explicit exception |
|
All exit paths from a function with non-void return type shall have an explicit return statement with an expression |
|
Certain special functions must always be declared together (e.g. copy constructor and copy assignment operator) |
|
Macro replacement must not end with semicolon |
|
Non-standard characters should not occur in header file names in #include directives |
|
All partial and explicit specializations for a template shall be declared in the same file as the declaration of their primary template |
|
Initialization of global objects should not depend on other translation units |
|
Non-standard entities shall not be added to standard namespaces |
|
String literals shall not be assigned to non-constant pointers |
|
Use strcmp() or similar functions when comparing strings, do not compare using == |
|
Throw exceptions by value and catch them by reference |
|
Trigraphs shall not be used |
|
Specified symbols of library header shall not be used |
|
Avoid computations or casts resulting in integer overflow |
|
Use of va_list without a va_start or a va_start without va_end |
|
There should be no unused parameters in functions |
|
Deprecated features should not be used |
|
The macro NULL and C++11 nullptr shall be the only permitted forms of null pointer constant |
|
User defined suffixes of the user defined literal operators shall start with underscore followed by one or more letters |
|
Do not use ‘using namespace’ in a header file |
|
Provide a valid ordering predicate |
|
Includes should use same casing as target file name |
Options
Setting an option for this rule means setting the default for all nested rules.
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
This rule has no individual options.