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
In topepo/caret#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:
Some exploratory code for potential implementation:
xml=source_expression$full_xml_parsed_contentall_call_expr= xml_find_all(xml, "//SYMBOL_FUNCTION_CALL/parent::expr/parent::expr")
# xml2lang() still not robust enough to generically convert <expr>...</expr> --> langall_call_lang= Filter(length, lapply(all_call_expr, \(x) tryCatch(xml2lang(x), error=\(c) NULL))
# drop primitives, e.g. match.call(c, quote(c(1))) fails; also no hope to resolve all calls generally,# e.g. nested / anonymous functions, so just skip thoseall_calls=Filter(\(e) tryCatch(!is.primitive(eval(e[[1]])), error=\(c) FALSE), all_calls)
lapply(all_calls, \(e) match.call(eval(e[[1]]), e))
codetools::checkUsage() can be used for partially matched arguments at least:
foo<-function() lm(Sepal.Width~Sepal.Length, d=iris)
codetools::checkUsage(foo, suppressPartialMatchArgs=FALSE)
# <anonymous>: warning in lm(Sepal.Width ~ Sepal.Length, d = iris): partial argument match of 'd' to 'data'
R CMD check already does so, so this won't help to find issues in CRAN packages, but can still help for real-time linting during development.
In topepo/caret#1361, I came across a lot of partially-matched argument calls, especially
seq(along=
andseq(length=
(should beseq(along.with=
andseq(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()
withoptions(warnPartialMatchArgs=TRUE)
set to check for issues:The key is resolving
seq
generically for any call name in the linted code.The text was updated successfully, but these errors were encountered: