r-lib / lintr

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

New linter to recommend `sequence()` base R function #2595

Open Bisaloo opened 4 weeks ago

Bisaloo commented 4 weeks ago

As an alternative to unlist(lapply(x, seq_len)).

A proof of concept implementation is available at https://github.com/r-lib/lintr/commit/32049afb75aa6b950d459a2797da0e059353ddac and I'd be happy to turn it into a PR, and add tests, etc.

Anything I should take into account first? Should it be merged into seq_linter()?

Bisaloo commented 4 weeks ago

It's not a super common pattern but some hits in the wild: https://github.com/search?q=org%3Acran+%2Funlist%5C%28%5Bsl%5Dapply%5C%28%5B%5E%2C%5D%2B%2C+seq_len%2F&type=code

IndrajeetPatil commented 4 weeks ago

I would let others weigh in, but I would personally prefer to subsume this into seq_linter().

AshesITR commented 3 weeks ago

I agree with merging this into seq_linter().

MichaelChirico commented 3 weeks ago

3rd-ed :)