Disabling warnings in D-Scanner: looking for suggestions

WebFreak001 d.forum at webfreak.org
Mon Mar 30 09:20:41 UTC 2020


On Saturday, 28 March 2020 at 19:40:49 UTC, SHOO wrote:
> On Monday, 23 March 2020 at 13:15:08 UTC, WebFreak001 wrote:
>> [...]
>
> I am working in C using MISRA-C static analysis.
> According to the findings made there, the suppression of 
> warnings by comments is definitely necessary.
> Too many warnings can discourage developers and bury important 
> warnings.
>
> In MISRA-C, daring to ignore warnings is called "deviation". 
> And to deviate, a deviation report is required.
> Even in the D-Scanner lint, a statement of reasons seems to be 
> necessary for suppression.
>
> In addition, there are three code units that require suppression
> - File unit suppression: For example, binding would fall under 
> this category.
> ```
>     // @dscanner suppress(suspicious.unmodified, "some reasons")
>     foo();
> ```
> - Block unit suppression: Wrapping multiple warnings in a 
> single function can be useful in consolidating the areas that 
> need attention.
> ```
>     void foo() {
>         // @dscanner suppress(suspicious.unmodified, "some 
> reasons")
>         hoge();
>         fuga();
>         piyo();
>         // @dscanner unsuppress(suspicious.unmodified)
>     }
> ```
> - Line unit suppression: This is useful when suppressing a 
> single warning. (but I don't like this, because lines tend to 
> be longer and less readable; I prefer block unit suppression 
> over line unit suppression, even if it is for a single line.)
> ```
>      foo(); // @dscanner-suppress(suspicious.unmodified, "some 
> reasons")
> ```

I think this is a good suggestion. Overall I'm also for the 
comments starting/ending multi-line blocks + single line 
suppression. I'm also strongly for descriptions why to ignore 
warnings (we also follow the MISRA-C guidelines)

I suggested your syntax (but slightly simpler, without quotes 
because we are in a comment block) in the PR page. But overall I 
think that's a good and simple syntax we can standardize on.

With the syntax it's currently only possible to 
suppress/unsuppress single warnings per line, but I think that's 
an alright limitation.


More information about the Digitalmars-d mailing list