r-lib / lintr

Static Code Analysis for R
https://lintr.r-lib.org
Other
1.16k stars 184 forks source link

Possible to point out over-broad exclusion '# nolint seq_linter'? #2608

Closed MichaelChirico closed 3 weeks ago

MichaelChirico commented 3 weeks ago

Came across someone using

1:N # nolint seq_linter

today. Of course that's to exclude the lint, but that's only because it's being read as a blanket #nolint, i.e. it matches # nolint _but not # nolint: so it is just doing a global exclusion.

It only matters for cases where other lints are also being hidden (or might be in the future).

Is there any way we can detect this & warn the user? I didn't think of anything quickly besides hacky approaches.

AshesITR commented 3 weeks ago

I think we had a similar idea for linting blanket nolints. A more common mistake appears to be # nolint: seq_linter, with the same effect due to the missing terminal ..

The difficulty is we'd need an exception for exclude() for such lints.

MichaelChirico commented 3 weeks ago

I think you're right that #690 is about as good as we can hope to do here. I'll close in favor of that.