6.2.12.10. GeneralPurpose

GeneralPurpose/Best practice checks

Nested Rules

GeneralPurpose-ArithmeticBitwiseReturnBasicValue

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

GeneralPurpose-AssignmentShallReturnRefThis

An assignment operator shall return a reference to “this”

GeneralPurpose-AssignmentVirtual

A user-defined assignment operator shall not be virtual

GeneralPurpose-BalancedParenthesisInDefines

Parenthesis in Macro Definitions should be balanced

GeneralPurpose-BaseClassDestructor

Destructor of a polymorphic class shall be virtual or protected non-virtual

GeneralPurpose-BlockingCallsInCriticalSection

There shall be no calls to blocking functions in a critical region

GeneralPurpose-CallMoveWithConstArg

The std::move shall not be used on objects declared const or const&

GeneralPurpose-CommentWithLineSplicing

Line-splicing shall not be used in // comments

GeneralPurpose-CompilerWarnings

Fix all compiler warnings and errors

GeneralPurpose-CouldBeRangeBasedLoop

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

GeneralPurpose-DefaultConstructedRandomEngine

Reports uses of the default constructor for the blacklisted classes

GeneralPurpose-DeleteAndNewInSameScope

The allocation and deallocation operators delete and new should be declared in the same scope

GeneralPurpose-DeleteIncompleteClass

Pointers to incomplete class types shall not be deleted

GeneralPurpose-Digraphs

Digraphs should not be used

GeneralPurpose-DuplicateIncludeGuard

Different include files should not use the same include guard

GeneralPurpose-FormatSpecifier

Validates the use of format specifiers

GeneralPurpose-ForwardingValuesRestrictions

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

GeneralPurpose-IdentifierHiding

Identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide that identifier

GeneralPurpose-InitializeAllFieldsInConstructor

A constructor must initialize all data members of the class

GeneralPurpose-InvalidArgumentInCall

The validity of values passed to library functions shall be checked

GeneralPurpose-LambdaOutlivesReferenceCapturedObject

A lambda expression object shall not outlive any of its reference-captured objects

GeneralPurpose-LeakingReferenceToTemporary

Do not assign a reference or pointer to a temporary object or a subobject thereof

GeneralPurpose-LinkageMismatch

Do not include C header files into C++ without ‘extern “C”’

GeneralPurpose-LinkerWarnings

Fix all linker warnings and errors

GeneralPurpose-MacroWithReservedName

Reserved identifiers, macros and functions in the standard library shall not be defined, redefined or undefined

GeneralPurpose-MissingBaseCopy

Do call the base class copy constructor or assignment operator, if you implement a copy constructor or assignment operator in a derived class

GeneralPurpose-MissingIncludeGuard

Include files need an include guard

GeneralPurpose-MissingOverride

Override of functions is only permitted with keyword override

GeneralPurpose-MixOfClassStruct

Consistently use either the keyword class or struct per composite type, do not mix them

GeneralPurpose-MixedUpArgumentOrder

Argument name equals one of the names of the parameters, but not to the one corresponding to the argument

GeneralPurpose-MoveConstructorCopySemantics

Move constructor shall not initialize its class members and base classes using copy semantics

GeneralPurpose-MutablePredicate

Non-static data members or captured values of predicate function objects that are state related to this object’s identity shall not be copied

GeneralPurpose-NarrowAndWideStringConcatenation

Narrow and wide string literals shall not be concatenated

GeneralPurpose-NonVirtualFunctionRedefinition

Non-virtual member functions shall not be redefined in derived classes

GeneralPurpose-OverloadedOperators

Do not overload certain operators

GeneralPurpose-PureVirtualCall

No pure virtual member calls from within its constructor or destructor

GeneralPurpose-ReferenceToLocalVariable

Do not return a reference or pointer to a local variable

GeneralPurpose-RethrowWithException

Avoid rethrowing with explicit exception

GeneralPurpose-ReturnWithValueRequired

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

GeneralPurpose-RuleOfThree

Certain special functions must always be declared together (e.g. copy constructor and copy assignment operator)

GeneralPurpose-SemicolonAtEndOfMacro

Macro replacement must not end with semicolon

GeneralPurpose-SpecialCharactersInIncludes

Non-standard characters should not occur in header file names in #include directives

GeneralPurpose-SpecializationsInSameFile

All partial and explicit specializations for a template shall be declared in the same file as the declaration of their primary template

GeneralPurpose-StaticInitializationOrderFiasco

Initialization of global objects should not depend on other translation units

GeneralPurpose-StdLibraryExtension

Non-standard entities shall not be added to standard namespaces

GeneralPurpose-StringLiteralToNonConstPointer

String literals shall not be assigned to non-constant pointers

GeneralPurpose-StringPointerEquality

Use strcmp() or similar functions when comparing strings, do not compare using ==

GeneralPurpose-ThrowByValueCatchByReference

Throw exceptions by value and catch them by reference

GeneralPurpose-Trigraphs

Trigraphs shall not be used

GeneralPurpose-UncheckedStringToNumericConversion

Specified symbols of library header shall not be used

GeneralPurpose-UndefinedBitwiseShift

Avoid computations or casts resulting in integer overflow

GeneralPurpose-UninitializedVaListOrMissingVaEnd

Use of va_list without a va_start or a va_start without va_end

GeneralPurpose-UnusedParameter

There should be no unused parameters in functions

GeneralPurpose-UseOfDeprecatedLanguageFeatures

Deprecated features should not be used

GeneralPurpose-UseOfZeroAsNull

The macro NULL and C++11 nullptr shall be the only permitted forms of null pointer constant

GeneralPurpose-UserDefinedLiteralNaming

User defined suffixes of the user defined literal operators shall start with underscore followed by one or more letters

GeneralPurpose-UsingNamespaceInHeader

Do not use ‘using namespace’ in a header file

GeneralPurpose-ValidOrderingPredicate

Provide a valid ordering predicate

GeneralPurpose-WrongIncludeCasing

Includes should use same casing as target file name

Options