Ignoring a rule on a portion of code

In some cases, it can be useful to temporarily ignore a rule non-conformance on a short portion of source code, while providing a justification of why you are allowing the non-conformance.

You can justify a non-conformance in the source code, for a specified number of lines and for the first or all occurrences of the error, by adding the following pragma lines to your source code:

You must provide an explanation of why you are ignoring the rule. The justification text is included in the code review report.

To justify a rule discrepancy on a portion of code:

  1. Open the source file in the text editor and locate the lines of code that you want the rule to ignore.

  2. Before the portion of code, add one of the following lines:

To justify the first non-conformance of a rule following the pragma:

#pragma attol crc_justify (<rule>[,<lines>],"<text>")

To justifies all non-conformances of a rule following the pragma:

#pragma attol crc_justify_all (<rule>,<lines>,"<text>")

To justifies the first non-conformance of a rule in all files in the current project, including in traps located before the pragma statement:

#pragma attol crc_justify_everywhere (<rule>,"<text>")

The recommended usage for crc_justify_everywhere is to create a specific source file containing only the list of pragmas and to add this file to the project.

For all theses pragmas:

Example

The following example causes all non-conformances to the rule M8.5 in the 3 next lines to be ignored and explained in the code review report.

#pragma attol crc_justify_all (Rule M8.5, 3, "Rule M8.5 does not apply to the 3 following lines")

Related Topics

Code review overviewConfiguring code review rulesInstrumentation pragmas