BACK TO LIST

C / C++ rules

C and C++ are really performant languages and can be very error-prone. We all had core dumps and made pointer arithmetic errors! Thankfully, Codiga has hundreds of static analysis rules to flag potential errors in your C/C++ code, automate code reviews and merge with confidence.

arrayIndexThenCheck

Code style
Informational

Access array beyond boundaries

asctimeCalled

Code style
Informational

Obsolete function 'std::asctime' called. It is recommended to use 'strftime' instead.

catchExceptionByValue

Code style
Informational

Exception should be caught by reference.

clarifyCalculation

Code style
Informational

Clarify calculation precedence for '+' and '?'.

clarifyCondition

Code style
Informational

Suspicious condition (bitwise operator + comparison)

comparisonError

Code style
Informational

Detect conditions that are always true

constArgument

Code style
Informational

Argument 'false&&static\_cast<bool>(!!(desc.version()==100))' to function isTrue is always 0

constVariable

Code style
Informational

Detect variables that could be const

cstyleCast

Code style
Informational

C-style pointer casting

duplicateAssignExpression

Code style
Informational

Duplicate assign expression

duplicateBreak

Code style
Informational

Consecutive return

duplicateCondition

Code style
Informational

Detect duplicate conditions

duplicateConditionalAssign

Code style
Informational

Duplicate conditions

duplicateExpression

Code style
Informational

Duplicate expressions

duplicateExpressionTernary

Code style
Informational

Duplicate Ternary operator

duplicateValueTernary

Code style
Informational

Duplicate ternary value

knownConditionTrueFalse

Code style
Informational

Condition value is always known

missingOverride

Code style
Informational

Function overrides a function in a base class but is not marked with a 'override' specifier.

multiCondition

Code style
Informational

Expression is always false because 'else if' condition matches previous condition

noConstructor

Code style
Informational

Class does not have a constructor although it has private member variables.

noExplicitConstructor

Code style
Informational

Class has a constructor with 1 argument that is not explicit.

oppositeExpression

Code style
Informational

Opposite expression on both sides of expression

redundantAssignment

Code style
Informational

Variable is reassigned a value before the old one has been used.

redundantCondition

Code style
Informational

Redundant condition

redundantPointerOp

Code style
Informational

Redundant pointer operation on 'CB' - it's already a pointer.

shadowFunction

Code style
Informational

Local variable shadows outer function

shadowVar

Code style
Informational

Local variable shadows outer variable

unassignedVariable

Code style
Informational

Detect variables that are not assigned (e.g. dead code)

unreachableCode

Code style
Informational

Statements following return ; dead code

unsafeClassDivZero

Code style
Informational

Public interface is not safe.

unsignedLessThanZero

Code style
Informational

Checking if unsigned expression is less than zero.

unsignedPositive

Code style
Informational

Unsigned expression can't be negative so it is unnecessary to test it.

unusedAllocatedMemory

Code style
Informational

Variable is allocated memory that is never used.

unusedLabel

Code style
Informational

Label is not used.

unusedPrivateFunction

Code style
Informational

Unused private function

unusedStructMember

Code style
Informational

struct member is never used.

unusedVariable

Code style
Informational

Unused variable

uselessAssignmentArg

Code style
Informational

Assignment of function parameter has no effect outside the function.

useStlAlgorithm

Code style
Informational

Consider using std::generate algorithm instead of a raw loop.

We use cookies to improve your site experience, including analytics cookies to understand how you use our product and design better experiences. Please read our Cookie Policy.