Source Checks

The Source Checks are a series of reports, one for each of the source code quality checks listed and described below. These source checks point out exceptions to generally agreed upon design and coding practices. Some of these checks correspond to specific MISRA C rules; for these, the rule number from MISRA C:2012 is indicated.

When invoked through the Reports menu, each report provides a listing of all the exceptions to a particular source check, across all the files in the project. Alternatively, you can view all of the exceptions to all of the source checks, for one specific file. To invoke this file-specific source checks report, use the context sensitive menu by right clicking on a file symbol, or use the File > Reports menu in a File Editor.

While in the File Editor, you can also view the specific areas in the source code where exceptions occur. These are indicated by underlining, which you enable or disable for specific source checks through the the general Options dialog (Files > Options > File Editors > Source Check Display). To learn what particular source check exception is being indicated by a specific underline, use the Information overlay.

Expression Type

Octal ConstantFlags the use of an octal constant (rule 7.1)
Missing u SuffixFlags the omission of a u or U suffix from an integer constant represented in an unsigned type (rule 7.2)
Inappropriate Essential TypeFlags an operand with an inappropriate essential type (rule 10.1)
Char Used in Arith OperationFlags an expression having an essentially character type being used inappropriately in addition and subtraction operations (rule 10.2)
Assign to Narrower TypeFlags an expression being assigned to a narrower essential type or a different essential type category (rule 10.3)
Mismatch Underlying TypesFlags an operation with arithmetic conversions on operands having different essential types (rule 10.4)
Conversion IssueFlags a conversion that could lose precision or rely on non-portable interpretations of arithmetic or pointers. This includes mixing of signed and unsigned operands when it can lead to portability problems. Also includes right-shifts of signed operands. (EX: int x; unsigned y; x = y;)
Composite Assign to WiderFlags a composite expression being assigned to a wider essential type (rule 10.6)
Composite Arith with WiderFlags an operation with arithmetic conversions where a composite operand has a narrower essential type than the other operand (rule 10.7)
Composite Cast to WiderFlags a composite expression being cast to a wider essential type or a different essential type category (rule 10.8)
Function Pointer Cast MismatchFlags a cast between a function pointer and any other type (rule 11.1)
Pointer Cast MismatchFlags a cast between pointers to different object types (rule 11.3)
Qualifier Removed in CastFlags the removal of a const or volatile qualifier in a cast (rule 11.8)

Expression Structure

Interchangeable Function AvailableFlags the use of a macro when an interchangeable function is available (directive 4.9)
Unterminated Escape SequenceFlags an unterminated octal or hexadecimal escape sequence (rule 4.1)
TrigraphFlags the use of a trigraph (rule 4.2)
Init Lacks Braces or ValuesFlags initialization of an array, structure, union or enum with insufficient braces or values (rule 9.2)
Array Partially ZeroedFlags an array variable initialized by a single "0". Zeros should probably be specified for all array elements.
Array Partially InitializedFlags an array variable initialized with fewer values than the dimension of the array
Unclear SubexpressionFlags a subexpression that is potentially not written as intended. Includes comparisons that can be statically evaluated like unsigned variables and negative numbers. Catches typical suspicious relational operator uses and potential lack of parenthesis. (EX: x && y | z) (rule 12.1)
Shift Out of RangeFlags a shift operation where the right hand operand is out of range of the bit width of the essential type of the left hand operand (rule 12.2)
Comma OperatorFlags the use of the comma operator (rule 12.3)
Wrap-Around of ConstantsFlags a wrap-around in the evaluation of unsigned constants in expression (rule 12.4)
Assign in Boolean ExpressionFlags the use of an assignment operator as an operand in a Boolean-valued expression (rule 13.4)
Suspicious AssignmentFlags a suspicious assignment in a conditional expression or argument list, where the assignment might actually be intended as a comparison
Sizeof Potential Side EffectsFlags the use of the sizeof operator where the operand contains an expression having potential side effects (rule 13.6)
Pointer Used in ArithmeticFlags an expression of pointer type being used with +, -, += or -= operators (rule 18.4)
Macro Arg Contains DirectiveFlags a macro argument that looks like a preprocessing directive (rule 20.6)
Macro Needs ParenthesesFlags the need for parentheses in an expression resulting from the expansion of macro parameters (rule 20.7)
Undefined Macro in DirectiveFlags the use of an undefined macro in an #if or #elif preprocessor directive (rule 20.9)
Macro Uses # or ##Flags the use of # or ## preprocessor operators in a macro definition (rule 20.10)
Macro Uses Multiple # and/or ##Flags the use of more than one # and/or ## preprocessor operator in a macro definition (rule 20.11)
Number of Built-In OperatorsIndicates that the number of built-in operators in an expression exceeds a user-specified threshold
Number of Functions in ExpressionIndicates that the number of function calls in an expression exceeds a user-specified threshold
Old Style AllocatorFlags the use of an old style memory allocator, such as malloc, realloc, calloc or free, in a C++ program.

Statements

Portability ProblemFlags certain language extensions that are incompatible with ISO C or ISO C++, such as Diab extension for sizeof and GNU extension for aggregate literals (rule 1.2)
Comment Contains Comment CharactersFlags the use of /* or // within a comment (rule 3.1)
Comment Contains Line-SplicingFlags the use of line-splicing in a // comment (rule 3.2)
Missing Static SpecifierFlags the declaration of a function or object with internal linkage where the static specifier isn't used (rule 8.8)
Empty StatementFlags an empty statement in an if, else or while, as it could be an indicator of missing code
Suspicious For LoopFlags a for loop that is not well formed, either in the three control expressions, or in interactions with the for body (rule 14.2)
Jump StatementFlags the use of a goto, break or continue statement, as it could make control flow more difficult to understand
Goto StatementFlags the use of a goto statement (rule 15.1)
Goto Earlier LabelFlags a goto statement jumping to a label declared earlier in the function (rule 15.2)
Goto Outside BlockFlags a goto statement jumping to a label outside the same block or a block enclosing the goto (rule 15.3)
Needs Compound StatementFlags a potentially missing compound statement (braces). This includes possible errors caused by a dangling else or by a statement mistakenly disassociated from a while or for (rule 15.6)
Missing Final ElseFlags an if .. else if construct that does not terminate with an else statement (rule 15.7)
Level of Switch LabelFlags a switch label where the most closely-enclosing compound statement is not the body of the switch statement (rule 16.2)
Unterminated CaseFlags a case in a switch statement that is not terminated by an explicit transfer of control, such as a break statement (rule 16.3)
Missing Default CaseFlags a switch statement that does not have a default case (rule 16.4)
Order of Default CaseFlags a switch statement where the default case is not either first or last case (rule 16.5)
Single Switch ClauseFlags a switch statement that has less than two switch-clauses (rule 16.6)
Boolean Type in SwitchFlags a switch expression that has an essentially Boolean type (rule 16.7)
Catch Statement List EmptyFlags catch statements that have an empty statement list as possible sign of missing logic
Catch AllFlags catch statements that catch all exceptions in one clause as possible sign of missing logic
Return IgnoredFlags a statement that ignores the result of either a function call or any other expression where the computation is not stored. This typically indicates that error results are being ignored
Excessive Pointer NestingFlags a declaration containing more than 2 levels of pointer nesting (rule 18.5)
Inappropriate Include DirectiveFlags a #include directive followed by something other than a <filename> or "filename" sequence (rule 20.3)

Functions

Missing Return TypeFlags a function declaration that does not specify the return type (rule 8.1)
Missing Parameter NameFlags a function declaration that does not specify a parameter name (rule 8.2)
Empty Parameter ListFlags a function declarator that uses empty parenthesis () instead of (void) (rule 8.2)
Mismatched Parameter TypeFlags a mismatch in parameter types between the function declaration and the function definition (rule 8.3)
Missing/Mismatched Function DeclaratorFlags a mismatch in parameter types between the function definition and a function call. This is mostly effective for C, where prototypes are missing or inconsistent
Variable Number of ArgumentsFlags a function that has a variable number of arguments
Mismatched Extern TypeFlags a mismatch in parameter types between the function declaration and an extern declaration (rule 8.4)
Undeclared FunctionFlags a function being called without a prior declaration (rule 17.3)
K&R Style DeclaratorFlags a function declarator that uses old style K&R syntax, which is no longer valid in C++
Potential Static FunctionIndicates that a function is only called from within the file where it is defined, but is not declared static

Variables

Missing Variable TypeFlags a variable declaration that does not explicitly specify a type (rule 8.1)
Mismatched Variable TypeFlags a mismatch in parameter types between the variable declaration and the variable definition (rule 8.3)
Unused GlobalIndicates that a global variable is never used in the source files loaded into the project
Unused StaticIndicates that a static variable is never used
Unused LocalIndicates that a local variable is never used

Classes

No ConstructorIndicates that a class does not have a constructor. Best practices recommend that explicit constructors always be defined in order to avoid problems in initializing the class objects
Problematic ConstructorFlags a problematic definition in a class constructor. This includes virtual function calls from the constructor and initialization order problems

Unanalyzed Code

Omitted LinesFlags a source line that is ignored by the analyzer due to the current preprocessor settings
Skipped LinesFlags a source line that is skipped due to syntax problems that the analyzer cannot resolve. If the source compiles in the original development environment, this could be an indication of missing include files or incorrect configuration of the analyzer