AUTOSAR C++14 Rule A5-1-1
Literal values shall not be used apart from type initialization, otherwise symbolic names shall be used instead
Description
Rule Definition
Literal values shall not be used apart from type initialization, otherwise symbolic names shall be used instead.
Rationale
Improve the readability and maintainability of code by using symbolic names. Literal constants do not clearly indicate what the constant represents
Polyspace Implementation
Polyspace® flags the use of literal values other than those with the
data type char
in expressions and
case
clauses of a switch
statement.
Polyspace does not flag the use of literal values in logging mechanisms.
Polyspace does not flag the use of literal values '0
' and
'1
' in expressions, as they are often part of the logic of the code.
For instance, '0
' represents a NULL
pointer.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Expressions |
Category: Required, Partially automated |