Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can prevent C/C++test from reporting specific static analysis findings by defining suppressions. Suppressions are useful when you generally follow a rule, but decide to ignore specific occurrences of the reported finding. If you do not want to receive findings for any violations of a specific rule, disable the rule in the test configuration.Suppression schemes can be defined in source code or in a suppression file

Info
iconfalse

If you are using the MISRA Compliance Pack for DTP, see the DTP User Guide to learn more about how suppressions are handled by MISRA compliance reporting on DTP.

Defining Suppressions in Source Code

...

Use the following format to add suppression entries to parasoft.suppress files:

Code Block
suppression-begin
file: Account.cpp                 (required)
line: 12                          (optional)
rule-id: CODSTA-123               (optional)
message: Exact violation message  (optional)
reason: Approved                  (optional)
author: devel                     (optional)
date: 2020-09-21                  (optional)
suppression-end

Example

At a minimum, you must specify the source file where the problem was detected. This will suppress all findings reported for the specified file. In the following example, all findings detected in the Account file will be suppressed:

Code Block
suppression-begin
file: Account.cpp
suppression-end

Other attributes are optional and help you fine-tune the suppression. In the following example, all findings that the PB.TYPO.TLS rule detected in the Account file are suppressed, regardless on which code line they occur:

Code Block
suppression-begin
file: Account.cpp
rule-id: PB.TYPO.TLS
suppression-end

Notes on Attributes

  • It is a good practice to specify the reason for suppression.
  • The line attribute should be used with caution as it may invalidate the suppression if the code is moved to another line when the source file is modified.

...

You can configure C/C++test to automatically suppress static rule violations that are detected on lines that match a regular expression pattern. This may be useful when you want to suppress tasks findings that are difficult to suppress using the in-line or in-code suppressions, such as  Qt macros.

...