6.2.12.11. Miscellaneous

Miscellaneous checks that are often parts of other rule sets

Nested Rules

Miscellaneous-AnsiStringUse

Use wide strings when calling the Microsoft C/C++ standard library

Miscellaneous-BusyHeaders

Identify files with large product of includes and includers

Miscellaneous-CComments

Checks for correctly used comment style in C units

Miscellaneous-CPPComments

Checks for correctly used comment style in C++ units

Miscellaneous-CapitalizeFunctions

Start functions and methods with an upper-case letter

Miscellaneous-DoNotMixLogicalOperators

The logical operators && and || should not appear together in a full expression

Miscellaneous-DoxygenCommentAtDefinition

Place Doxygen comments above (class and function) definitions

Miscellaneous-DoxygenCommentInHeader

Place Doxygen comments above classes and functions in header files

Miscellaneous-EntityMarker

Reports a (suppressed) issue per entity of a configurable type

Miscellaneous-ExpressionsWithoutSideEffect

There shall be no expressions that could be removed because they do not affect program behaviour

Miscellaneous-FileUsageInconsistency

Do not use a file as primary file and included file

Miscellaneous-Filemarker

Reports a (suppressed) issue per entity of a configurable type

Miscellaneous-ForbiddenFunctions

Do not call certain functions from certain header files

Miscellaneous-ForbiddenMacros

Do not use certain macros

Miscellaneous-ForbiddenTokens

Do not use certain token sequences

Miscellaneous-HidingTolerateCtor

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

Miscellaneous-ImportCSV

Import style violations from CSV file

Miscellaneous-IncludeKind

Use the correct include kind “” vs. <>

Miscellaneous-InitializeAllVariables

Initialize all variables when defining them

Miscellaneous-InvalidEffectAttributes

Do not use invalid effect attributes

Miscellaneous-LineBreaks

You have to use the specified sort of line breaks

Miscellaneous-LocalInclude

Replace #include with forward declaration or more precise #include where possible

Miscellaneous-LocalScope

Declare variables as local as possible

Miscellaneous-MarkupComments

Scans for comments containing a specified regular expression

Miscellaneous-MaxComplexity

Functions must not exceed cyclomatic complexity limit

Miscellaneous-MaxConditions

An expression must not have more than N logical operators

Miscellaneous-MaxNesting

A function must have a nesting level less than or equal N

Miscellaneous-MaxOneStmtPerLine

Do not put more than one statement in a line

Miscellaneous-MaxParams

A function must not have more than N parameters

Miscellaneous-MissingConstructor

Each class needs an explicitly declared constructor

Miscellaneous-MissingDestructor

Each class needs an explicitly declared destructor

Miscellaneous-MissingInlineDefinition

Inline functions must be defined in every compilation unit where they are declared

Miscellaneous-MissingParameterAssert

Assert parameters before actual function body

Miscellaneous-MissingSelfHeaderInclude

Each compilation unit shall include its own header file

Miscellaneous-NamingConvention

Check named entities against naming conventions

Miscellaneous-NoAbsoluteInclude

Do not use absolute path names in #include

Miscellaneous-NoAccessToGlobalsInXtor

Avoid the use of global objects in constructors and destructors as they may not yet be initialized

Miscellaneous-NoAssembler

Do not use the assembler

Miscellaneous-NoAutoType

Do not use the C++11 auto type specifier

Miscellaneous-NoCCasts

Do not use C-style casts in C++ code

Miscellaneous-NoCFunctionCall

Do not call C functions from C++ code

Miscellaneous-NoCHeaderInclude

Do not use C standard headers when a C++ one is available

Miscellaneous-NoCPPStructs

Do not use structs in C++, rather use classes

Miscellaneous-NoCatchAll

You should not use catch(…)

Miscellaneous-NoCharPointer

Do not use char* in C++ code

Miscellaneous-NoCommaSequence

Do not use the C comma sequence operator

Miscellaneous-NoConditionalOperator

Do not use the conditional operator

Miscellaneous-NoConstCasts

Do not use const_cast

Miscellaneous-NoConstOnLHS

Put constants on right side of equality comparisons in conditions

Miscellaneous-NoConstOnRHS

Put constants on left side of equality comparisons in conditions

Miscellaneous-NoDebugMacro

Do not use certain debugging macros

Miscellaneous-NoDiamondInheritance

Do not introduce a non-virtual diamond inheritance

Miscellaneous-NoDiscardedReturnCode

Do not ignore return values of functions

Miscellaneous-NoDoubleUnderscoreInMacro

Do not use more than one consecutive underscore in a macro

Miscellaneous-NoEllipsis

Do not use variable arguments in functions

Miscellaneous-NoEmptyLoops

Loops must not be empty

Miscellaneous-NoEmptyStructs

Structs/unions must not be empty

Miscellaneous-NoExceptionSpec

Do not use dynamic exception specifications

Miscellaneous-NoExternInImpl

Do not put extern declarations into implementation files

Miscellaneous-NoFriendClass

Friend type declarations shall not be used

Miscellaneous-NoFunctionCommentInImpl

Do not place comments above functions and methods in implementation files

Miscellaneous-NoFunctionDefinitionInHeader

Do not define (non-inline) functions in header files

Miscellaneous-NoFunctionMacroInvocation

Function-like macros shall not be called

Miscellaneous-NoFunctionPointerCalls

Do not use indirect calls with function pointers

Miscellaneous-NoFunctionPointers

Avoid defining function pointers

Miscellaneous-NoFunctionPrototypeInImpl

Do not declare function prototypes in implementation files

Miscellaneous-NoGlobalVariables

Do not use global (non-const) variables

Miscellaneous-NoIfdefInHeader

Except for include guards there shall be no #if[n]def or #if in header files

Miscellaneous-NoImplicitTypeConversion

Do not use implicit type conversions

Miscellaneous-NoIncludePaths

Avoid using forbidden kinds of paths in #include

Miscellaneous-NoIrregularInclude

Avoid #includes which cannot be syntactically integrated

Miscellaneous-NoLeakingReferenceToLocal

Do not assign to some nonlocal object a reference or pointer to a local variable

Miscellaneous-NoMagicNumbers

Do not use magic literals

Miscellaneous-NoMalloc

The library functions “malloc”, “calloc”, “realloc”, and “free” from library <stdlib.h> shall not be used

Miscellaneous-NoMixOfPtrAndIntArithmetic

Do not mix pointer and integer arithmetic

Miscellaneous-NoMultipleInheritance

Do not use multiple inheritance

Miscellaneous-NoNewWithArrays

Do not use new with arrays

Miscellaneous-NoPrecisionLoss

Do not assign longer data types to shorter ones

Miscellaneous-NoPublicDataMembers

Do not declare non-const data members public

Miscellaneous-NoReferenceToPrivateDataMember

Do not return non-const references to private data members

Miscellaneous-NoSignedDivision

Do not use signed variables in divisions

Miscellaneous-NoSingleCharIdentifier

Do not use identifiers consisting of just a single character

Miscellaneous-NoStaticInHeader

Do not put static declarations into header files

Miscellaneous-NoStdStringInternals

Do not rely on std::string internals when converting to char*

Miscellaneous-NoTabs

Do not use tabs

Miscellaneous-NoTrailingWhitespace

Do not use trailing whitespace

Miscellaneous-NoTypeConversionToBool

Do not use type conversions to bool, use value comparison

Miscellaneous-NoUncheckedMalloc

The result of calls to the library functions “malloc”, “calloc”, and “realloc” must be checked

Miscellaneous-NoUncheckedPointerParamDereference

Check pointer parameters for NULL before dereferencing them

Miscellaneous-NoUnnamedNamespaceInHeader

Do not use unnamed namespaces in header files

Miscellaneous-NoUnsafeMacro

Do not use macro definitions with parameters or expressions without parentheses around them

Miscellaneous-NoVirtualDestructor

Class needs a virtual destructor if at least one member function is virtual

Miscellaneous-NoVirtualInheritance

Do not use virtual inheritance

Miscellaneous-NoWhitespaceMemberSelection

No whitespace before or after a member selection

Miscellaneous-NoWhitespaceUnaryOperator

No whitespace after an unary operator

Miscellaneous-PCHIncludes

Add #includes for often-used files to precompiled header

Miscellaneous-PreferFieldInit

You should prefer field initialization over assignment in constructors

Miscellaneous-PreferPrefixOverPostfix

Prefer prefix increment/decrement over postfix version

Miscellaneous-RedundantEnumDefaultClause

The “default” clause of a switch must be omitted if a switch has cases for all enumerators

Miscellaneous-Templates

List templates with instances

Miscellaneous-TooManyIncludes

Report units with high number of included files

Miscellaneous-TypedefCheck

Do not redefine a typedef

Miscellaneous-UserDefinedConversionExplicit

All user-defined conversion operators shall be defined explicit

Options