HIS + MISRA-C Checklist

The Hersteller Initiative Software (HIS) metrics are a collection of 15 metrics that apply to a software project plus three metrics that apply to two revisions of software projects. Of the project metrics, two are actually summaries of rule violations of a subset of MISRA C.

This checklist contains checks for all 18 metrics representing HIS, along with checks for the underlying MISRA C coding standards that are referenced by HIS. The MISRA C directives and rules are listed by how they are referenced in MISRA-C:2012, rather than the earlier MISRA-C:2004 standard that was in place at the time the HIS standard was issued.

HIS Source Code Metrics

HIS-CALLINGNumber of callers more than 5
HIS-CALLSNumber of called functions more than 7
HIS-COMFRatio of comments to statements less or equal than 0.2
HIS-CYCCyclomatic Complexity Greater than 10
HIS-GOTONumber of Goto
HIS-LEVELNumber of nested conditions more than 4
HIS-NOMVViolations of the HIS subset of MISRA C rules
HIS-NOMVPRViolations of the HIS subset of MISRA C rules by rule
HIS-PARAMSNumber of function parameters more than 5
HIS-PATHNumber of Paths More than 80
HIS-RECRecursive Functions
HIS-RETURNNumber of returns in function
HIS-SCHGNumber of statements changed in project
HIS-SDELNumber of statements deleted in project
HIS-SIStability index of project
HIS-SNEWNumber of statements added in project
HIS-STMTNumber of statements in function more than 50
HIS-VOCFVocabulary of function more than 4

Underlying MISRA-C Directives

Dir 1.1Any implementation-defined behavior shall be documented and understood
Dir 4.4Sections of code should not be "commented out"
Dir 4.6typedefs for the basic numerical types
Dir 4.7Function returning error information shall be tested
Dir 4.9A function preferable to function-like macro
Dir 4.11The validity of values passed to library functions shall be checked
Dir 4.12Dynamic memory allocation shall not be used

Underlying MISRA-C Rules

Rule 1.1No violations of the standard C syntax and constraints, and translation limits
Rule 1.2Language extension should not be used
Rule 1.3There shall be no occurrence of undefined or critical unspecified behaviour
Rule 2.1A project shall not contain unreachable code
Rule 2.1aUnreachable code - functions defined but never called
Rule 2.1bUnreachable code - statements not reached in control flow
Rule 2.2There shall be no dead code
Rule 3.1Character sequences "/*" and "//" not in comment
Rule 4.1Octal and hexadecimal escape sequences shall be terminated
Rule 4.2Trigraphs should not be used
Rule 5.3An identifier declared in an inner scope shall not hide an identifier declared in an outer scope
Rule 5.6A typedef name shall be a unique identifier
Rule 5.7A tag name shall be a unique identifier
Rule 6.2Single-bit named bit fields shall not be of a signed type
Rule 7.1Octal constants shall not be used
Rule 8.1Types shall be explicitly specified
Rule 8.2Function types in prototype form with named parameters
Rule 8.3All declarations shall use same names and type qualifiers
Rule 8.4Compatible declaration for symbol with external linkage
Rule 8.5External symbol shall be declared once in one file
Rule 8.6External symbol shall have exactly one external definition
Rule 8.7Functions and objects that could be static
Rule 8.8Use static storage class specifier consistently
Rule 8.9Object to be defined at block scope if only in single function
Rule 8.13A pointer should point to a const-qualified type whenever possible
Rule 9.1Object with automatic storage shall not be read before set
Rule 9.2Initializer for aggregate or union shall be in braces
Rule 10.1Operands shall not be of an inappropriate essential type
Rule 10.2Expressions of character type inappropriately in addition and subtraction
Rule 10.3Expression not to be assigned to narrower different essential type
Rule 10.4Operands of operator with arithmetic conversions shall have same essential type
Rule 10.6Composite expression not be assigned to object with wider essential type
Rule 10.7Composite expression as operand with arithmetic conversion not with wider operand
Rule 10.8Composite expression not be cast to different or wider essential type
Rule 11.1Conversions not be performed between pointer to function and any other type
Rule 11.3A cast shall not be performed between pointers to different object types
Rule 11.8Cast not remove const or volatile qualifier from type
Rule 12.1Precedence of operators in expressions be made explicit
Rule 12.2Shift within bit width of type of left hand operand
Rule 12.3The comma operator should not be used
Rule 12.4Constant expression evaluation not lead to unsigned wrap-around
Rule 13.2Expression value and side effects same under all evaluation orders
Rule 13.4The result of an assignment operator should not be used
Rule 13.5Right hand operand of && or || operator not contain side effects
Rule 13.6Operand of sizeof not contain expression with side effects
Rule 14.1A loop counter shall not have essentially floating type
Rule 14.2A for loop shall be well-formed
Rule 15.1The goto statement should not be used
Rule 15.2The goto statement shall jump to a label declared later in the same function
Rule 15.3goto shall jump to same block or block enclosing goto
Rule 15.6Body of an iteration or selection shall be compound-statement
Rule 15.7All if...else if shall be terminated with an else statement
Rule 16.2switch label only for most closely-enclosing compound statement
Rule 16.3Unconditional break statement to terminate every switch-clause
Rule 16.4Every switch statement shall have a default label
Rule 16.5Default label either as first or last label of switch statement
Rule 16.6Every switch statement shall have at least two switch-clauses
Rule 16.7A switch-expression shall not have essentially Boolean type
Rule 17.1The features of shall not be used
Rule 17.2Functions shall not call themselves, either directly or indirectly
Rule 17.3A function shall not be declared implicitly
Rule 17.4All exit paths from non-void function need return with expression
Rule 18.1Pointer arithmetic shall address element of same array
Rule 18.2Subtraction between pointers only between elements of same array
Rule 18.3Operators >, >=, < and <= only for pointers to same object
Rule 18.4The +, -, += and -= operators not be applied to expression of pointer type
Rule 18.5Declarations should contain no more than two levels of pointer nesting
Rule 18.6Address of object with automatic storage not to non-local object
Rule 19.1An object shall not be assigned or copied to an overlapping object
Rule 20.2Certain character sequences shall not occur in a header file name
Rule 20.3#include directive be followed by or "filename" sequence
Rule 20.4A macro shall not be defined with the same name as a keyword
Rule 20.6Preprocessing directive within a macro argument
Rule 20.7Expressions resulting from macro parameters in parentheses
Rule 20.9Identifiers in #if or #elif to be #define'd before evaluation
Rule 20.10The # and ## preprocessor operators should not be used
Rule 20.11Macro operators # and ## not following each other
Rule 21.1#define and #undef not be used on reserved identifier or reserved macro name
Rule 21.1aNo #define and #undef for names beginning with an underscore
Rule 21.1bNo #define or #undef for identifiers in file scope in standard library headers
Rule 21.1c#define and #undef shall not be used for identifier 'defined'
Rule 21.2A reserved identifier or macro name shall not be declared
Rule 21.3Memory allocation functions of shall not be used
Rule 21.4The standard header file shall not be used
Rule 21.5The standard header file shall not be used
Rule 21.6The Standard Library input/output functions shall not be used
Rule 21.7The atof, atoi and atoll functions of shall not be used
Rule 21.8Library functions abort, exit, getenv and system of not be used
Rule 21.10The Standard Library time and date functions shall not be used