Disabling warnings in D-Scanner: looking for suggestions

WebFreak001 d.forum at webfreak.org
Mon Mar 23 13:15:08 UTC 2020


Currently in D-Scanner it is only possible to disable warnings 
for the entire test suite, but not on a per-line basis. So we 
would like to ask for some suggestions what would be good 
constructs to achieve this. (See discussion on 
https://github.com/dlang-community/D-Scanner/pull/799 )

Some suggestions:

disabling warnings per-line using `// 
@suppress(dscanner.suspicious.unmodified)`
pros:
- relatively easy to implement (requires a full copy of source 
code in memory)
- supported by dls and serve-d already
cons:
- blows up line length
- not very flexible to ignore more than one type
- hard to verify (for example misspelling suppress)


more fully featured comments to disable
pros:
- very flexible
- could reuse syntax from well-known linting tools
cons:
- potentially very hard to implement parsing
- potentially reimplementing scoping to figure out where blocks 
start and end
- even harder to verify misspelling


using a Java-like @suppress UDA in the source code to mark blocks 
and statements
pros:
- easy to ignore warnings for whole classes
- very easy to implement when having an AST
- doesn't break when adding line breaks to a multi-line variable 
definition
- auto completion included, can easily extend UDA definitions & 
parameters with documentation and new warning codes
cons:
- easy to ignore warnings for whole classes (bad practice)
- hard to mark only certain lines (like template parameters, 
singular if checks, etc)
- D grammar doesn't allow UDA blocks inside statements
- would need some generated UDA definition file or additional dub 
package to depend on to compile successfully


extending D's pragma like in C# for pragma(warning, disable, 
[warning codes]) and pragma(warning, restore, [warning codes])
pros:
- good syntax support (supported in most syntax parts)
- can enable/disable anywhere without requiring extra nesting in 
{} blocks
- easy to understand exact effect range
- could offer integration with disabling built-in dmd warnings 
(like dead code)
cons:
- would need to extend D's spec (and would only start working 
with newer D versions) as currently unknown pragmas, even vendor 
defined, are defined to error
- would need more precise specification for warning codes
-> would take a lot of time to implement


What kind of suppression system would you prefer to see in 
D-Scanner, what would you prefer not to see? Open for suggestions.


More information about the Digitalmars-d mailing list