1.4.30. Migration to 7.6.2¶
1.4.30.1. Stylechecks¶
FaultDetection-DeadBranches¶
The following rules report effects of constant logical expressions, e.g., dead branches.
FaultDetection-DeadBranches
CertC-MSC12
CQM-DeadImplementation
CWE-Bad-Coding-Practices-561
AutosarC++17_03-M0.1.1, AutosarC++17_10-M0.1.1, AutosarC++18_03-M0.1.1, AutosarC++18_10-M0.1.1, AutosarC++19_03-M0.1.1
AutosarC++17_03-M0.1.2, AutosarC++17_10-M0.1.2, AutosarC++18_03-M0.1.2, AutosarC++18_10-M0.1.2, AutosarC++19_03-M0.1.2
AutosarC++17_03-M0.1.9, AutosarC++17_10-M0.1.9, AutosarC++18_03-M0.1.9, AutosarC++18_10-M0.1.9, AutosarC++19_03-M0.1.9
AutosarC++17_03-M0.3.1, AutosarC++17_10-M0.3.1, AutosarC++18_03-M0.3.1, AutosarC++18_10-M0.3.1, AutosarC++19_03-M0.3.1
MisraC++-0.1.1
MisraC++-0.1.2
MisraC++-0.1.9
MisraC++-0.3.1
MisraC++202x-1
MisraC++202x-2
MisraC-13.7
MisraC-14.1
MisraC-21.1
For these rules, message texts have changed to reflect the actual violation more precisely. We also introduced the following new message subtypes.
loop_cond_true: Loop condition is always trueloop_cond_true_type_limits: Loop condition is always true due to limited range of data typeloop_cond_false: Loop body is dead, condition is always falseloop_cond_false_type_limits: Loop body is dead, condition is always false due to limited range of data typedo_while_only_once: Loop is only executed once, loop condition is always falsedo_while_only_once_type_limits: Loop is only executed once, loop condition is always false due to limited range of data typesubexpression_true: Subexpression always evaluates to truesubexpression_false: Subexpression always evaluates to falsesubexpression_true_type_limits: Subexpression always evaluates to true due to limited range of data typesubexpression_false_type_limits: Subexpression always evaluates to false due to limited range of data typeunreachable_short_circuit: Subexpression never evaluated due to short-circuiting operator
These new message subtypes represent subsets of existing messages, except for unreachable_short_circuit, which produces new messages.
For example, the following code will now produce two messages for rule MisraC++-0.1.2, one of type
subexpression_false and additionally one of type unreachable_short_circuit.
bool trivial_shortcircuit()
{
int x = 1;
return x != 1 && x != 0;
//^stdout:14: required: Subexpression always evaluates to false [x!=1] (Rule MisraC++-0.1.2)
//^^stdout:24: required: Subexpression never evaluated due to short-circuiting operator [x!=0] (Rule MisraC++-0.1.2)
}
You can disable these messages by setting the option msg/<subkey>/disabled to false in the respective rule.
AutosarC++-A2.7.3, Generic-DoxygenComment, Generic-NoFunctionCommentInImpl¶
The recognition of doxygen (and other) comments has been extended to support trailing comments and improved regarding the search of comment tokens. A frequent problem was that leading comments in a file have been mistaken as comments of the first definition. This caused false positives for the rule Generic-NoFunctionCommentInImpl and false negatives for the rules Generic-DoxygenCommentAtDefinition and AutosarC++-A2.7.3 (resp. AutosarC++-A2.8.3). The following rules have been extended by new options:
AutosarC++17_03-A2.8.3, AutosarC++17_10-A2.8.3
AutosarC++18_03-A2.7.3, AutosarC++18_10-A2.7.3, AutosarC++19_03-A2.7.3,
Generic-DoxygenCommentAtDefinition
Generic-DoxygenCommentInHeader
Generic-NoFunctionCommentInImpl
CQM-InformalDocumentation
All these rules have a new option stop_tokens to configure the set of tokens
that will stop the search for comment tokens.
The above false negatives and positives are reduced by the added "#include"
token. However, in rare cases where "#include" is supposed to belong to the
beginning of a definition, this will cause other false negatives or positives.
Apart from the rule Generic-NoFunctionCommentInImpl, that only treats plain but no doxygen comments, also the following options have been added:
lines_before: Maximal number of lines to search upwards for comment tokensdoxygen_trailer: Recognize also trailing doxygen commentslines_after: Maximal number of lines to search downwards for trailing commentsadd_extra_info: A flag to provide extra output of comment recognition
The maximal line number options can be set large enough to ensure backward compatibility.