By: Tom Sydney Kerckhove <syd@cs-syd.eu>
Report a suppression in a file no rule is run over as unused
A suppression that answers for nothing is an error, and until now three kinds
of file could hold one that nothing said anything about: a file under a source
directory that no component claims and whose suppression was written in the
bare form, which the walk over unclaimed files did not match; an unclaimed file
spelled with a preprocessor's extension, which the walk did not look at; and a
preprocessor's input a component does claim, whose Haskell only exists at build
time so no layer ever reads it.
A rule that is never run over a file reports nothing in it, so a suppression
written in one answers for nothing and always will. That is the verdict
applySuppression already reaches for a suppression whose rule ran and found
nothing, so it is now reported as the same complaint, at the line the
suppression is written on:
[error UNUSED_SUPPRESSION]: [allow:CommentBareTodo] suppresses nothing.
Which file it happens to be in is the tool's problem rather than the reader's,
so it is not in the message, and one that names no rule this run makes fails
with the parser's own words as it would in a file that is read. Reaching that
without a parser is a scan, and every step it can share with parseAnnotation it
shares: meansToBeOne says what announces a suppression, splitAnnotation reads
the rule out of it, namedRule says whether this run makes that rule.
ComplaintUnused carries the rule and the span rather than the whole annotation,
because that is all the two ways of answering for nothing have in common and
all a reader is owed. A file under no source directory at all is outside what a
package run reads and is still not covered.