r-lib / lintr

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

Collapsing consecutive lints into one #1717

Open AshesITR opened 2 years ago

AshesITR commented 2 years ago

I think it's a good feature, but also not something we do for other linters (e.g. no_tab_linter() is the first that comes to mind as a linter that tends to hit on many lines in a row).

Do you think it's worth maintaining the code to remove consecutive lints? Should we consider adding that logic to the other linters too? Maybe it's an argument we could add to Lint() or flatten_lints() or something like that?

_Originally posted by @MichaelChirico in https://github.com/r-lib/lintr/pull/1411#discussion_r996362525_

AshesITR commented 2 years ago

I think this is highly context dependent whether consecutive lints need to be "collapsed" into one. This linter tends to produce massive amounts of lints if e.g. a top-level indentation is wrong, see the tables with / without duplicates on the tested packages. But for no_tab_linter() I agree it could also be implemented such that it only lints the first line per file that it finds. OTOH if we ever add auto-fixing, this might be detrimental.

https://github.com/r-lib/lintr/pull/1411#discussion_r996413339