You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New linter for unqualified # nolint or # nolint start #690
Once #660 is in master, we support excluding specific linters.
A linter linting exclusion comments without a list of excluded linters would be nice to have.
Ideally it would say something like
Use # nolint with a list of excluded linters, e.g. # nolint: xxx, yyy.
Where the list of linters in the message is auto-generated by checking which of the configured linters produce a hit.
Might be hard to do since exclusions would apply to the linter and thus mute it.
Add a new attribute important to Lint, defaulting to FALSE.
Make exclude_lints not exclude lints with important = TRUEunless (a) the entire file is excluded or (b) the specific linter is excluded
(a) would be hard to change because we currently optimize away linting completely excluded files.
(b) at least allows the user to mute important lints by explicitly specifying it in the # nolint: important_linter. way. Otherwise there would be no way to disable a specific instance of an important lint without excluding the entire file or the linter.
A different way to go would be to add an option recognized in .lintr, then throw a warning() from exclude that an unqualified # nolint was found and is being ignored
I could see both working and since this would probably be the only instance of an "important" lint, your approach seems more elegant. I'm not sure whether we want to open WARNINGs as a secondary information channel though, downstream code might not expect warnings from lintr.
I think it might make sense to turn it on to increase awareness for the new specific exclusions.
However if we trigger warnings, this might break existing code that only expects a list of lints. So if we decide to implement it via warnings it might be a wiser choice to make the new behaviour opt-in only.
Activity
AshesITR commentedon Jan 31, 2021
Just a few thoughts on how we might support this:
importanttoLint, defaulting toFALSE.exclude_lintsnot exclude lints withimportant = TRUEunless (a) the entire file is excluded or (b) the specific linter is excluded(a) would be hard to change because we currently optimize away linting completely excluded files.
(b) at least allows the user to mute important lints by explicitly specifying it in the
# nolint: important_linter.way. Otherwise there would be no way to disable a specific instance of an important lint without excluding the entire file or the linter.MichaelChirico commentedon Jan 31, 2021
A different way to go would be to add an option recognized in
.lintr, then throw awarning()fromexcludethat an unqualified# nolintwas found and is being ignoredAshesITR commentedon Jan 31, 2021
I could see both working and since this would probably be the only instance of an "important" lint, your approach seems more elegant. I'm not sure whether we want to open WARNINGs as a secondary information channel though, downstream code might not expect warnings from lintr.
MichaelChirico commentedon Jan 31, 2021
Default would be for it to be off (at least for now), so no warnings unless intentionally toggled
AshesITR commentedon Jan 31, 2021
I think it might make sense to turn it on to increase awareness for the new specific exclusions.
However if we trigger warnings, this might break existing code that only expects a list of lints. So if we decide to implement it via warnings it might be a wiser choice to make the new behaviour opt-in only.