lintr
lintr copied to clipboard
Linter for partially matched arguments
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.