facebook pixelC and C++ Static Code Analysis Rules
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
      Minor

      Access array beyond boundaries

      asctimeCalled

      Code style
      Minor

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

      catchExceptionByValue

      Code style
      Minor

      Exception should be caught by reference.

      clarifyCalculation

      Code style
      Minor

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

      clarifyCondition

      Code style
      Minor

      Suspicious condition (bitwise operator + comparison)

      comparisonError

      Code style
      Minor

      Detect conditions that are always true

      constArgument

      Code style
      Minor

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

      constVariable

      Code style
      Minor

      Detect variables that could be const

      cstyleCast

      Code style
      Minor

      C-style pointer casting

      duplicateAssignExpression

      Code style
      Minor

      Duplicate assign expression

      duplicateBreak

      Code style
      Minor

      Consecutive return

      duplicateCondition

      Code style
      Minor

      Detect duplicate conditions

      duplicateConditionalAssign

      Code style
      Minor

      Duplicate conditions

      duplicateExpression

      Code style
      Minor

      Duplicate expressions

      duplicateExpressionTernary

      Code style
      Minor

      Duplicate Ternary operator

      duplicateValueTernary

      Code style
      Minor

      Duplicate ternary value

      knownConditionTrueFalse

      Code style
      Minor

      Condition value is always known

      missingOverride

      Code style
      Minor

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

      multiCondition

      Code style
      Minor

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

      noConstructor

      Code style
      Minor

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

      noExplicitConstructor

      Code style
      Minor

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

      oppositeExpression

      Code style
      Minor

      Opposite expression on both sides of expression

      redundantAssignment

      Code style
      Minor

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

      redundantCondition

      Code style
      Minor

      Redundant condition

      redundantPointerOp

      Code style
      Minor

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

      shadowFunction

      Code style
      Minor

      Local variable shadows outer function

      shadowVar

      Code style
      Minor

      Local variable shadows outer variable

      unassignedVariable

      Code style
      Minor

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

      unreachableCode

      Code style
      Minor

      Statements following return ; dead code

      unsafeClassDivZero

      Code style
      Minor

      Public interface is not safe.

      unsignedLessThanZero

      Code style
      Minor

      Checking if unsigned expression is less than zero.

      unsignedPositive

      Code style
      Minor

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

      unusedAllocatedMemory

      Code style
      Minor

      Variable is allocated memory that is never used.

      unusedLabel

      Code style
      Minor

      Label is not used.

      unusedPrivateFunction

      Code style
      Minor

      Unused private function

      unusedStructMember

      Code style
      Minor

      struct member is never used.

      unusedVariable

      Code style
      Minor

      Unused variable

      uselessAssignmentArg

      Code style
      Minor

      Assignment of function parameter has no effect outside the function.

      useStlAlgorithm

      Code style
      Minor

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