lintr icon indicating copy to clipboard operation
lintr copied to clipboard

Linter for partially matched arguments

Open MichaelChirico opened this issue 1 year ago • 2 comments

In https://github.com/topepo/caret/pull/1361, I came across a lot of partially-matched argument calls, especially seq(along= and seq(length= (should be seq(along.with= and seq(length.out=), respectively).

It would be good to have a linter for this. This will require having function definitions loaded, in which case we can use match.call() with options(warnPartialMatchArgs=TRUE) set to check for issues:

c <- substitute(seq(along = x))
options(warnPartialMatchArgs = TRUE, warn=2L)
tryCatch(math.call(seq, c), error=\(c) "lint")
#  [1] "lint"

The key is resolving seq generically for any call name in the linted code.

MichaelChirico avatar Apr 22 '24 02:04 MichaelChirico