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.

knownEmptyContainerLoop

Performance
Informational

Iterating over a container that is always empty.

passedByValue

Performance
Warning

Function parameter should be passed by const reference.

pointerPositive

Performance
Informational

A pointer can not be negative so it is either pointless or an error to check if it is not.

postfixOperator

Performance
Warning

Prefer prefix ++/-- operators for non-primitive types.

stlcstrParam

Performance
Warning

Passing the result of c_str() to a function that takes std::string as argument no. 1 is slow and redundant.

stlcstrReturn

Performance
Warning

Returning the result of c_str() in a function that returns std::string is slow and redundant.

stlFindInsert

Performance
Warning

Searching before insertion is not necessary.

stlIfStrFind

Performance
Warning

Inefficient usage of string::find() in condition; string::starts_with() could be faster.

useInitializationList

Performance
Warning

Variable is assigned in constructor body. Consider performing initialization in initialization list.

uselessCallsSubstr

Performance
Warning

Ineffective call of function 'substr' because it returns a copy of the object. Use operator= instead.

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.