Line suppression in the source code

ptalwarptalwar Posts: 3

When we want to suppress a violation in the source code, is it okay to add a comment '// parasoft-suppress...' that is "not" in continuation to the line we want to suppress? Can we insert the comment on top or split it in multiple lines, for the suppression to work? The reason I ask this is because we use a tool that checks for structural code problems that could affect the quality and performance of our application and splits a "long" line into multiple lines and the same happens if we add a "suppress" comment to a line long enough already, which in turn moves the "suppress" comment to the next line and the tool does not pick it up.



  • Andrey MadanAndrey Madan Posts: 316 ✭✭✭

    What Palak is asking here is the following:
    Suppose we have an already long code line and want to add a suppression at the end of the line:

    LONG CODE LINE; /* parasoft-suppress MISRAC2012-RULE_17_3-a "this is ok per company policy" */
    The problem is that that line becomes way to long and some code formatters break it up in chunks automatically.
    So in essence she is asking for a way to specify that this rule is suppressed on the next line:
    Something like that:

    /* parasoft-suppress-next-line MISRAC2012-RULE_17_3-a "this is ok per company policy" */
        LONG CODE LINE; 
  • MirekMirek Posts: 116 ✭✭✭

    There are "Line Suppressions" which have to be in the same line as the code with the suppressed violation and "Block Suppressions" which potentially work on multiple lines of code. I'm not sure how practical it will be, but possibly block suppression could help here. Please see the example below:

    // parasoft-begin-suppress CODSTA.NEA "begin suppress rule CODSTA.NE
    // parasoft-end-suppress CODSTA.NEA "end suppress rule CODSTA.NEA"

Sign In or Register to comment.