Relaxing Violations in Code

Squore provides a violation relaxation mechanism that is triggered via comments found in the source code itself. There are two pre-requisites for relaxation to work:

Squore interprets comments formatted in one of these three ways:

  1. Inline Relaxation

    This syntax is used to relax violations on the current line.

    some code; /* %RELAX<keys> : Text to justify the relaxation */
  2. Relax Next Line

    This syntax is used to relax a violation on the first following line that is not a comment. In the example the text of the justification will be: "Text to justify the relaxation the text of the justification continues while lines are made of comments only"

    /* >RELAX<keys> : Text to justify the relaxation */
    /* the text of the justification continues while */
    /* lines are made of comments only */
    some code;
  3. Block Relaxation

    This syntax is used to relax violations in an entire block of code.

    /* {{ RELAX<keys> : Text to justify the relaxation */
    /* like for format 2 text can be on more than one line */
    int my_func() {
       /* contains many violations */
       ...
    }
    /* }} RELAX<keys> */

<keys> can be one of the following:

The relaxed violations are still shown in the Findings page after the next analysis, but they appear under the rule R_RELAX, showing the mnemonic of the relaxed violation and the justification text.

As an example, this is how you would relax the violations of the rule Backward goto for Adherence to 'Analysability' Standards in Neptune:

  1. click the violation of Backward goto on the Findings page to find the rule's mnemonic (BWGOTO) and the location of the finding (DB5_backup.c line 52).

    The details of the Backward goto violation

  2. Edit the code of the sample project to relax the violation as shown below.

    goto loopwrite; /* %RELAX<BWGOTO> : This backward goto is acceptable in our code. */
  3. Create a new version of the project.

On the Findings page, the violation now visible if you select to display derogations in the filter:

The relaxed violation is visible when displaying derogations