Broad Mapping: AUTOSAR

This table contains broad mappings between JSF++ guideline numbers and CodeSonar warning classes.

The close mappings from JSF++ rules to CodeSonar warning classes are shown in JSF++ Checks.

A CSV versions of this table is provided in JSF++-mapping-broad.csv.

JSF++ CategoryC/C++ Warning Classes
JSF++:1 Any one function (or method) will contain no more than 200 logical source lines of code (L-SLOCs). Will
closely mapped
JSF++:3 All functions shall have a cyclomatic complexity number of 20 or less. Shall
closely mapped
JSF++:11 Trigraphs will not be used. Will
closely mapped
JSF++:13 Multi-byte characters and wide string literals will not be used. Will
closely mapped
JSF++:14 Literal suffixes shall use uppercase rather than lowercase letters. Shall
closely mapped
JSF++:17 The error indicator errno shall not be used. Shall
closely mapped
JSF++:18 The macro offsetof, in library <stddef.h>, shall not be used. Shall
closely mapped
JSF++:19 <locale.h> and the setlocale function shall not be used. Shall
closely mapped
JSF++:20 The setjmp macro and the longjmp function shall not be used. Shall
closely mapped
JSF++:21 The signal handling facilities of <signal.h> shall not be used. Shall
closely mapped
JSF++:22 The input/output library <stdio.h> shall not be used. Shall
closely mapped
JSF++:23 The library functions atof, atoi and atol from library <stdlib.h> shall not be used. Shall
closely mapped
JSF++:24 The library functions abort, exit, getenv and system from library <stdlib.h> shall not be used. Shall
closely mapped
JSF++:25 The time handling functions of library <time.h> shall not be used. Shall
closely mapped
JSF++:26 Only the following pre-processor directives shall be used:
  1. #ifndef
  2. #define
  3. #endif
  4. #include

Abbreviated form used elsewhere in this manual: "Only the following pre-processor directives shall be used: #ifndef, #define, #endif, #include."

Shall
closely mapped
JSF++:28 The #ifndef and #endif pre-processor directives will only be used as defined in AV Rule 27 to prevent multiple inclusions of the same header file. Will
closely mapped
JSF++:29 The #define pre-processor directive shall not be used to create inline macros. Inline functions shall be used instead. Shall
closely mapped
JSF++:30 The #define pre-processor directive shall not be used to define constant values. Instead, the const qualifier shall be applied to variable declarations to specify constant values. Shall
closely mapped
JSF++:31 The #define pre-processor directive will only be used as part of the technique to prevent multiple inclusions of the same header file. Will
closely mapped
JSF++:32 The #include pre-processor directive will only be used to include header (*.h) files. Will
closely mapped
JSF++:33 The #include directive shall use the <filename.h> notation to include header files. Shall
closely mapped
JSF++:39 Header files (*.h) will not contain non-const variable definitions or function definitions. Will
closely mapped
JSF++:40 Every implementation file shall include the header files that uniquely define the inline functions, types, and templates used. Shall
closely mapped
JSF++:42 Each expression-statement will be on a separate line. Will
closely mapped
JSF++:46 User-specified identifiers (internal and external) will not rely on significance of more than 64 characters. Will
closely mapped
JSF++:47 Identifiers will not begin with the underscore character '_'. Will
closely mapped
JSF++:48 Identifiers will not differ by:
  • Only a mixture of case
  • The presence/absence of the underscore character
  • The interchange of the letter 'O', with the number '0' or the letter 'D'
  • The interchange of the letter 'I', with the number '1' or the letter 'l'
  • The interchange of the letter 'S' with the number '5'
  • The interchange of the letter 'Z' with the number 2
  • The interchange of the letter 'n' with the letter 'h'.

Abbreviated form used elsewhere in this manual: "Identifiers will not be typographically ambiguous."

Will
closely mapped
JSF++:50 The first word of the name of a class, structure, namespace, enumeration, or type created with typedef will begin with an uppercase letter. All others letters will be lowercase. Will
closely mapped
JSF++:51 All letters contained in function and variable names will be composed entirely of lowercase letters. Will
closely mapped
JSF++:52 Identifiers for constant and enumerator values shall be lowercase. Shall
closely mapped
JSF++:53.1 The following character sequences shall not appear in header file names: ', \, /*, //, or ". Shall
closely mapped
JSF++:59 The statements forming the body of an if, else if, else, while, do...while or for statement shall always be enclosed in braces, even if the braces form an empty block. Shall
closely mapped
JSF++:68 Unneeded implicitly generated member functions shall be explicitly disallowed. Shall
closely mapped
JSF++:70.1 An object shall not be improperly used before its lifetime begins or after its lifetime ends. Shall
closely mapped
JSF++:71 Calls to an externally visible operation of an object, other than its constructors, shall not be allowed until the object has been fully initialized. Shall
closely mapped
JSF++:71.1 A class's virtual functions shall not be invoked from its destructor or any of its constructors. Shall
closely mapped
JSF++:75 Members of the initialization list shall be listed in the order in which they are declared in the class. Shall
closely mapped
JSF++:76 A copy constructor and an assignment operator shall be declared for classes that contain pointers to data items or nontrivial destructors. Shall
closely mapped
JSF++:77.1 The definition of a member function shall not contain default arguments that produce a signature identical to that of the implicitly-declared copy constructor for the corresponding class/structure. Shall
closely mapped
JSF++:78 All base classes with a virtual function shall define a virtual destructor. Shall
closely mapped
JSF++:79 All resources acquired by a class shall be released by the class's destructor. Shall
closely mapped
JSF++:80 The default copy and assignment operators will be used for classes when those operators offer reasonable semantics. Will
closely mapped
JSF++:81 The assignment operator shall handle self-assignment correctly. Shall
closely mapped
JSF++:82 An assignment operator shall return a reference to *this. Shall
closely mapped
JSF++:88 Multiple inheritance shall only be allowed in the following restricted form: n interfaces plus m private implementations, plus at most one protected implementation. Shall
closely mapped
JSF++:88.1 A stateful virtual base shall be explicitly declared in each derived class that accesses it. Shall
closely mapped
JSF++:89 A base class shall not be both virtual and non-virtual in the same hierarchy. Shall
closely mapped
JSF++:94 An inherited nonvirtual function shall not be redefined in a derived class. Shall
closely mapped
JSF++:95 An inherited default parameter shall never be redefined. Shall
closely mapped
JSF++:96 Arrays shall not be treated polymorphically. Shall
closely mapped
JSF++:97 Arrays shall not be used in interfaces. Instead, the Array class should be used. Shall
closely mapped
JSF++:97.1 Neither operand of an equality operator (== or !=) shall be a pointer to a virtual member function. Shall
closely mapped
JSF++:104 A template specialization shall be declared before its use. Shall
closely mapped
JSF++:107 Functions shall always be declared at file scope. Shall
closely mapped
JSF++:108 Functions with variable numbers of arguments shall not be used. Shall
closely mapped
JSF++:110 Functions with more than 7 arguments will not be used. Will
closely mapped
JSF++:111 A function shall not return a pointer or reference to a non-static local object. Shall
closely mapped
JSF++:112 Function return values should not obscure resource ownership. Should
also related
JSF++:113 Functions will have a single exit point. Will
closely mapped
JSF++:114 All exit points of value-returning functions shall be through return statements. Shall
closely mapped
also related
JSF++:115 If a function returns error information, then that error information will be tested. Will
closely mapped
JSF++:117.1 An object should be passed as const T& if the function should not change the value of the object. Should
closely mapped
JSF++:119 Functions shall not call themselves, either directly or indirectly (i.e. recursion shall not be allowed). Shall
closely mapped
JSF++:126 Only valid C++ style comments (//) shall be used. Shall
closely mapped
JSF++:127 Code that is not used (commented out) shall be deleted. Shall
closely mapped
JSF++:135 Identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide that identifier. Shall
closely mapped
JSF++:136 Declarations should be at the smallest feasible scope. Should
closely mapped
JSF++:137 All declarations at file scope should be static where possible. Should
closely mapped
JSF++:139 External objects will not be declared in more than one file. Will
closely mapped
JSF++:140 The register storage class specifier shall not be used. Shall
closely mapped
JSF++:142 All variables shall be initialized before use. Shall
closely mapped
JSF++:144 Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures. Shall
closely mapped
JSF++:145 In an enumerator list, the '=' construct shall not be used to explicitly initialize members other than the first, unless all items are explicitly initialized. Shall
closely mapped
JSF++:147 The underlying bit representations of floating point numbers shall not be used in any way by the programmer. Shall
closely mapped
JSF++:148 Enumeration types shall be used instead of integer types (and constants) to select from a limited series of choices. Shall
closely mapped
also related
JSF++:149 Octal constants (other than zero) shall not be used. Shall
closely mapped
JSF++:151.1 A string literal shall not be modified. Shall
closely mapped
JSF++:152 Multiple variable declarations shall not be allowed on the same line. Shall
closely mapped
JSF++:153 Unions shall not be used. Shall
closely mapped
JSF++:154 Bit-fields shall have explicitly unsigned integral or enumeration types only. Shall
closely mapped
JSF++:156 All the members of a structure (or class) shall be named and shall only be accessed via their names. Shall
closely mapped
JSF++:157 The right hand operand of a && or || operator shall not contain side effects. Shall
closely mapped
also related
JSF++:158 The operands of a logical && or || shall be parenthesized if the operands contain binary operators. Shall
closely mapped
JSF++:159 Operators ||, &&, and unary & shall not be overloaded. Shall
closely mapped
JSF++:160 An assignment expression shall be used only as the expression in an expression statement. Shall
closely mapped
JSF++:162 Signed and unsigned values shall not be mixed in arithmetic or comparison operations. Shall
closely mapped
JSF++:164 The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the left-hand operand (inclusive). Shall
closely mapped
JSF++:164.1 The left-hand operand of a right-shift operator shall not have a negative value. Shall
closely mapped
JSF++:165 The unary minus operator shall not be applied to an unsigned expression. Shall
closely mapped
JSF++:166 The sizeof operator will not be used on expressions that contain side effects. Will
closely mapped
JSF++:168 The comma operator shall not be used. Shall
closely mapped
JSF++:169 Pointers to pointers should be avoided when possible. Should
closely mapped
JSF++:170 More than 2 levels of pointer indirection shall not be used. Shall
closely mapped
JSF++:171 Relational operators shall not be applied to pointer types except where both operands are of the same type and point to:
  • the same object,
  • the same function,
  • members of the same object, or
  • elements of the same array (including one past the end of the same array).
Note that if either operand is null, then both shall be null. Also, "members of the same object" should not be construed to include base class subobjects.

Abbreviated form used elsewhere in this manual: "Relational operators shall not be applied to pointer types except where both operands are of the same type and point to the same entity."

Shall
closely mapped
JSF++:173 The address of an object with automatic storage shall not be assigned to an object which persists after the object has ceased to exist. Shall
closely mapped
JSF++:174 The null pointer shall not be de-referenced. Shall
closely mapped
JSF++:175 A pointer shall not be compared to NULL or be assigned NULL; use plain 0 instead. Shall
closely mapped
JSF++:178 Down casting (casting from base to derived class) shall only be allowed through one of the following mechanism:
  • Virtual functions that act like dynamic casts (most likely useful in relatively simple cases)
  • Use of the visitor (or similar) pattern (most likely useful in complicated cases)

Abbreviated form used elsewhere in this manual: "Down casting (casting from base to derived class) shall only be allowed through certain mechanisms."

Shall
closely mapped
JSF++:179 A pointer to a virtual base class shall not be converted to a pointer to a derived class. Shall
closely mapped
JSF++:180 Implicit conversions that may result in a loss of information shall not be used. Shall
closely mapped
JSF++:182 Type casting from any type to or from pointers shall not be used. Shall
closely mapped
JSF++:183 Every possible measure should be taken to avoid type casting. Should
closely mapped
JSF++:184 Floating point numbers shall not be converted to integers unless such a conversion is a specified algorithmic requirement or is necessary for a hardware interface. Shall
closely mapped
JSF++:185 C++ style casts (const_cast, reinterpret_cast, and static_cast) shall be used instead of the traditional C-style casts. Shall
closely mapped
JSF++:186 There shall be no unreachable code. Shall
closely mapped
JSF++:187 All non-null statements shall potentially have a side-effect. Shall
closely mapped
JSF++:189 The goto statement shall not be used. Shall
closely mapped
JSF++:190 The continue statement shall not be used. Shall
closely mapped
JSF++:191 The break statement shall not be used (except to terminate the cases of a switch statement). Shall
closely mapped
JSF++:192 All if, else if constructs will contain either a final else clause or a comment indicating why a final else clause is not necessary. Will
closely mapped
JSF++:193 Every non-empty case clause in a switch statement shall be terminated with a break statement. Shall
closely mapped
JSF++:194 All switch statements that do not intend to test for every enumeration value shall contain a final default clause. Shall
closely mapped
JSF++:195 A switch expression will not represent a Boolean value. Will
closely mapped
JSF++:196 Every switch statement will have at least two cases and a potential default. Will
closely mapped
JSF++:197 Floating point variables shall not be used as loop counters. Shall
closely mapped
JSF++:198 The initialization expression in a for loop will perform no actions other than to initialize the value of a single for loop parameter. Note that the initialization expression may invoke an accessor that returns an initial element in a sequence:
for (Iter_type p = c.begin() ; p != c.end() ; ++p) // Good
{
...
}

Abbreviated form used elsewhere in this manual: "The initialization expression in a for loop will perform no actions other than to initialize the value of a single for loop parameter."

Will
closely mapped
JSF++:199 The increment expression in a for loop will perform no action other than to change a single loop parameter to the next value for the loop. Will
closely mapped
JSF++:200 Null initialize or increment expressions in for loops will not be used; a while loop will be used instead. Will
closely mapped
JSF++:201 Numeric variables being used within a for loop for iteration counting shall not be modified in the body of the loop. Shall
closely mapped
JSF++:202 Floating point variables shall not be tested for exact equality or inequality. Shall
closely mapped
JSF++:203 Evaluation of expressions shall not lead to overflow/underflow (unless required algorithmically and then should be heavily documented). Shall
closely mapped
JSF++:204 A single operation with side-effects shall only be used in the following contexts:
  1. by itself
  2. the right-hand side of an assignment
  3. a condition
  4. the only argument expression with a side-effect in a function call
  5. condition of a loop
  6. switch condition
  7. single part of a chained operation.

Abbreviated form used elsewhere in this manual: "A single operation with side-effects shall only be used in certain contexts."

Shall
closely mapped
JSF++:204.1 The value of an expression shall be the same under any order of evaluation that the standard permits. Shall
closely mapped
JSF++:205 The volatile keyword shall not be used unless directly interfacing with hardware. Shall
closely mapped
JSF++:206 Allocation/deallocation from/to the free store (heap) shall not occur after initialization. Shall
closely mapped
JSF++:208 C++ exceptions shall not be used (i.e. throw, catch and try shall not be used.) Shall
closely mapped
JSF++:209 The basic types of int, short, long, float and double shall not be used, but specific-length equivalents should be typedef'd accordingly for each compiler, and these type names used in the code. Shall
closely mapped
JSF++:210 Algorithms shall not make assumptions concerning how data is represented in memory (e.g. big endian vs. little endian, base class subobject ordering in derived classes, nonstatic data member ordering across access specifiers, etc.) Shall
closely mapped
also related
JSF++:210.1 Algorithms shall not make assumptions concerning the order of allocation of nonstatic data members separated by an access specifier. Shall
closely mapped
JSF++:211 Algorithms shall not assume that shorts, ints, longs, floats, doubles or long doubles begin at particular addresses. Shall
closely mapped
JSF++:212 Underflow or overflow functioning shall not be depended on in any special way. Shall
closely mapped
JSF++:213 No dependence shall be placed on C++'s operator precedence rules, below arithmetic operators, in expressions. Shall
closely mapped
JSF++:214 Assuming that non-local static objects, in separate translation units, are initialized in a special order shall not be done. Shall
closely mapped
JSF++:215 Pointer arithmetic will not be used. Will
closely mapped
JSF++:218 Compiler warning levels will be set in compliance with project policies. Will
closely mapped