AUTOSAR

AUTOSAR

AUTOSAR guidelines ensure that your code is safe and secure. Each rule has its own description. Below are the list of AUTOSAR rules supported by Embold:

Rule

Description

Rule M0-1-1

A project shall NOt contain unreachable code

Rule M0-1-2

A project shall NOt contain infeasible paths.

Rule M0-1-3

A project shall NOt contain unused variables.

Rule M0-1-

A project shall NOt contain unused type declarations.

Rule A0-1-2

The value returned by a function having a NOn-void return type that is NOt aNOverloaded operator shall be used.

Rule M0-1-9

There shall be NO dead code.

Rule M0-1-10

Every defined function should be called at least once

Rule M0-1-11

There shall be NO unused parameters (named or unnamed) in NOnvirtualfunctions.

Rule M0-1-12

There shall be NO unused parameters (named or unnamed) in the set of parameters for a virtual function and all the functions that override it.

Rule A2-5-1

Trigraphs shall NOt be used.

Rule A2-6-1

Digraphs shall NOt be used.

Rule A2-8-1

The character \ shall NOt occur as a last character of a C++ comment

Rule A2-8-2

Sections of code shall NOt be “commented out”.

Rule A2-8-4

C-style comments shall NOt be used.

Rule A2-11-1

An identifier declared in an inner scope shall NOt hide an identifier declared in an outer scope

Rule M2-10-3

A typedef name (including qualification, if any) shall be a unique identifier

Rule M2-13-3

A “U” suffix shall be applied to all octal or hexadecimal integer literals of unsigned type.

Rule M2-13-4

Literal suffixes shall be upper case.

Rule A3-1-4

When an array with external linkage is declared, its size shall be stated explicitly.

Rule M3-2-1

All declarations of an object or function shall have compatible types

Rule M3-2-2

The One Definition Rule shall NOt be violated

Rule M3-2-3

A type, object or function that is used in multiple translation units shall be declared in one and only one file.

Rule M3-2-4

An identifier with external linkage shall have exactly one definition.

Rule A3-3-

Objects or functions with external linkage (including members of namednamespaces) shall be declared in a header file.

Rule M3-3-2

If a function has internal linkage then all re-declarations shall include the static storage class specifier.

Rule M3-4-1

An identifier declared to be an object or type shall be defined in a block that minimizes its visibility

Rule M3-9-1

The types used for an object, a function return type, or a function parameter shall be token-for-token identical in all declarations and redeclarations.

Rule M5-0-3

A cvalue expression shall NOt be implicitly converted to a different underlying type

Rule M5-0-4

An implicit integral conversion shall NOt change the signedness of the underlying type.

Rule M5-0-5

There shall be NO implicit floating-integral conversions.

Rule M5-0-16

A pointer operand and any pointer resulting from pointer arithmetic using that operand shall both address elements of the same array.

Rule M5-0-17

Subtraction between pointers shall only be applied to pointers that address elements of the same array.

Rule M5-0-18

,>=,<,<=shall NOt be applied to objects of pointer type, except where they point to the same array

Rule A5-2-1

dynamic_cast should NOt be used.

Rule A5-2-2

Traditional C-style casts shall NOt be used

Rule A5-2-3

A cast shall NOt remove any const or volatile qualification from the type of a pointer or reference

Rule M5-2-6

A cast shall NOt convert a pointer to a function to any other pointer type, including a pointer to function type.

Rule M5-2-8

An object with integer type or pointer to void type shall NOt be converted to an object with pointer type

Rule M5-2-9

A cast shall NOt convert a pointer type to an integral type

Rule A5-2-5

An array shall NOt be accessed beyond its range

Rule M5-3-4

Evaluation of the operand to the sizeof operator shall NOt contain side effects.

Rule A5-5-1

The right hand operand of the integer division or remainder operators shall NOt be equal to zero.

Rule M5-8-1

The right hand operand of a shift operator shall lie between zero and oneless than the width in bits of the underlying type of the left hand operand

Rule M5-18-1

The comma operator shall NOt be used.

Rule M6-3-1

The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement.

Rule M6-4-1

An if ( condition ) construct shall be followed by a compound statement. These keyword shall be followed by either a compound statement, or
aNOtherif statement.

Rule M6-4-2

All if ... else if constructs shall be terminated with an else clause.

Rule M6-4-3

A switch statement shall be a well-formed switch statement

Rule M6-4-5

An unconditional throw or break statement shall terminate every NOnemptyswitch-clause

Rule M6-4-6

The final clause of a switch statement shall be the default-clause

Rule M6-4-7

The condition of a switch statement shall NOt have bool type

Rule A6-4-1

A switch statement shall have at least two case-clauses, distinct from the default label.

Rule A6-5-2

A for loop shall contain a single loop-counter which shall NOt have floatingpoint type

Rule M6-5-3

The loop-counter shall NOt be modified within condition or statement.

Rule M6-5-5

A loop-control-variable other than the loop-counter shall NOt be modified within condition or expression

Rule M6-5-6

A loop-control-variable other than the loop-counter which is modified instatement shall have type bool

Rule A6-6-1

The goto statement shall NOt be used.

Rule A7-5-1

A function shall NOt return a reference or a pointer to a parameter that is passed by reference to const.

Rule A7-5-2

Functions shall NOt call themselves, either directly or indirectly.

Rule A8-4-1

Functions shall NOt be defined using the ellipsis NOtation.

Rule M8-4-2

The identifiers used for the parameters in a re-declaration of a function shall be identical to those in the declaration.

Rule A8-4-2

All exit paths from a function with NOn-void return type shall have an explicitreturn statement with an expression.

Rule M8-5-1

All variables shall have a defined value before they are used

Rule M9-5-1

Unions shall NOt be used

Rule A12-8-1

Move and copy constructors shall only move and respectively copy base classes and data members of a class, without any side effects

Rule A15-2-1

Constructors that are NOt NOexcept shall NOt be invoked before program startup.

Rule A15-3-5

A class type exception shall be caught by reference or const reference.

Rule A15-5-1

A class destructor, “delete” operators, move constructor, move assignment operator and “swap” function shall NOt exit with an exception.
They shall be all specified as “NOexcept”

Rule A15-5-3

The std::terminate() function shall NOt be called implicitly

Rule M16-1-2

All #else, #elif and #endif pre-processor directives shall reside in the same file as the #if or #ifdef directive to which they are related

Rule A16-2-1

The’, ", /*, //, \characters shall NOt occur in a header file name or in#include directive

Rule M16-3-1

There shall be at most one occurrence of the # or ## operators in a single macro definition

Rule M16-3-2

The # and ## operators should NOt be used.

Rule A17-0-1

Reserved identifiers, macros and functions in the C++ standard library shall NOt be defined, redefined or undefined.

Rule M17-0-5

The setjmp macro and the longjmp function shall NOt be used

Rule A18-0-2

The library functions atof, atoi and atol from library shall NOt be used.

Rule M18-0-3

The library functions abort, exit, getenv and system from library shall NOt be used

Rule M18-0-4

The time handling functions of library shall NOt be used.

Rule M18-0-5

The unbounded functions of library shall NOt be used

Rule A18-1-1

C-style arrays should NOt be used

Rule M18-2-1

The macro off set of shall NOt be used.

Rule A18-5-1

Functions malloc, calloc, realloc and free shall NOt be used.

Rule A18-5-3

The form of delete operator shall match the form of new operator used to allocate the memory.

Rule A18-5-4

If a project has sized or unsized version of operator “delete” globally defined, then both sized and unsized versions shall be defined

Rule M18-7-1

The signal handling facilities of shall NOt be used.

Rule M19-3-1

The error indicator errNO shall NOt be used

Rule M27-0-1

The stream input/output library shall NOt be used