AutosarC++19_03-A2.7.2

Sections of code shall not be “commented out”

Required inputs: IR

Possible Messages

Key

Text

Severity

Disabled

code_in_c_comment

Sections of code should not be commented out.

None

False

code_in_cpp_comment

Sections of code should not be commented out.

None

False

Options

doxygen_start

doxygen_start : set[str] = {'/**', '///'}

Start of a valid Doxygen comment. Note that ignore_doxygen_comments needs to be enabled to actually ignore the matching comments.
 

files_to_check

files_to_check : bauhaus.rules.axivion.lexical.comments.FileToCheckSet = {'Primary_File', 'System_Include_File', 'User_Include_File'}

Files to be checked, e.g. Primary_File or File.
 

forbidden_tokens

forbidden_tokens : set[str] = {'/*', '// '}

Tokens that indicate code in comments despite normal text.

This is the first step of checking a comment. If any of these words exist in the comment text, it is regarded as containing code and no further steps are taken. By default these tokens are comment starters that can be removed if nested comments are acceptable.

 

ignore_doxygen_comments

ignore_doxygen_comments : bool = False

If set, doxygen comments (starting with prefixes as configured with doxygen_start) are never considered violations.
 

normal_text

normal_text

Type: set[str]

Default: {' and ', ' are ', ' be ', ' because ', ' but ', ' has ', ' is ', ' now ', ' oder ', ' only ', ' or ', ' the ', ' to ', ' und ', ' when ', ' with ', '##', '++++', '----', '://', '====', 'AXIVION'}

Tokens that indicate non-code comments.

This is the second step of checking a comment. If any of these words exist in the comment text, it is regarded as not containing code.

 

normal_text_regex

normal_text_regex : bauhaus.analysis.config.SearchPattern = '\b[\w\d_]+\s+[\w\d_]+\s+[\w\d_]+\b'

Regular expression to match normal non-code text.

This is the third step of checking a comment. If this regex finds a match in the comment text, the comment is regarded as not containing code.

 

suspicious

suspicious

Type: set[str]

Default: {' <= ', ' = ', ' == ', ' >= ', '#define', '#elif', '#else', '#endif', '#error', '#if', '#ifdef', '#ifndef', '#import', '#include', '#include_next', '#line', '#pragma', '#undef', '#warning', '++', '--', '->', '->*', '::', '::*', ';', '[', '_Pragma', '__has_include', 'for (', 'for(', 'if (', 'if(', 'while (', 'while('}

Tokens that indicate code in comments without normal text.

This is the final step of checking a comment. If the steps before did not exclude the comment from further inspection, the comment text is searched for any of these suspicious tokens. The comment is regarded as containing code, if any suspicious token is found.