Annotation to suppress messages #293
Labels
Component: DSL
Something that concerns the design of PIE DSL
Component: editor
Priority: low
Status: suggestion
Something to consider, but not accepted yet
Type: enhancement
New feature or request
Summary
Add annotations to suppress messages
Todo
This means that it should not just be mentioned in the description of that field, but also in the main description of suppressions.
Reason
Not every message can be fixed. In particular, notes may not be fixable. Having notes that have already been deemed unfixable is noise, so it would be good if these can be suppressed.
Description
Annotations to suppress messages. This may make it possible to add notes when code does not follow language convention: if you don't want that, you can simply suppress them (possibly project wide, with
suppress { PROJECT, conventionBreak }
). Example of a convention: PROJECT suppressions should have their own file at the top level directory of the project, FILE suppressions should be before the module statement.Parameters:
CaptureCount
(optional, option name can be omitted): the number of messages that this suppression can capture. If the suppression matches outside the range ofCaptureCount
, there is a warning onsuppress
. The default isSINGLE
, i.e. each suppression only captures a single message. Options:SINGLE
OPT
ALL
ANY
MIN(x: int)
MAX(x: int|inf)
MAXOPT(x: int|inf)
EXACTLY(x: int)
RANGE(min: int, max: int|inf)
MessageName
(required, option name can be omitted): the name of the message to suppress. Message names form taxonomies, so you could e.g. usesuppress { shadowing }
to suppress all messages related to shadowingmatch
(optional): a filter that is matched against the text of messages. This suppression only matches messages for which the text matches. Takes a string ("hello"
) or a regex (/he..o/
).priority
(optional): the priority of the suppression (any int). Higher priority suppressions capture messages earlier.scope
(optional): can be eitherPROJECT
,FILE
,MODULE
,TARGET
(default) or a lexical scope created by adding a second set of brackets to the annotation. The second set can be either just{
and}
, or{x|
and|x}
, wherex
must be a non-negative integer (opening and closing bracket must use the same integer).PROJECT
applies the suppression to the whole project.FILE
applies the suppression to the whole file.MODULE
applies the suppression to the whole module and its nested modules. It does not (?) apply to pseudo-modules.TARGET
is the default and applies the suppression to the element that the annotation is put on.comment
(optional, option name can be omitted): a comment describing why this message is suppressed. It is a string which does not require enclosing brackets.If multiple suppressions with equal priorities match a message, it is captured by the suppression in the lexically closest (smallest) scope. If the outer suppression matches any messages not captured by another suppression, the inner suppression shows a warning (suppressed message is already captured in enclosing scope, see E15 below). If not, the outer suppression emits a warning (all matched messages are already captured by inner suppressions).
Warnings that are suppressed do not count for #158.
Example
Implementation
I don't think most of this is possible in Statix right now. For the lexical scoping, add lexical syntax
AnnotationClosingBracket
[}]
and[|[INT]}]
which can be added at a variety of positionsExtensions
Create a way to view/filter all suppressions. Already possible by just searching for
suppress
, but that may turn up some false positives. Such a view could show the comments (i.e. reason) as well. Might be useful to find suppressions without comments.Related issues
Fun fact
You can upgrade a note to a warning by doing
suppress { EXACT(0), ... }
, which will show a warning on this suppression if such a note is found. That could be useful in combination with #158 to fail the build for certain notes.The text was updated successfully, but these errors were encountered: