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
I think the undesirable_function_linter() should only look for function calls. The context is that I want to use lintr to keep watch for base file system functions creeping into usethis (r-lib/usethis#531, r-lib/fs#85). I can almost do what I want with the undesirable_function_linter().
But it reports tons of false positives, i.e. warns when it should not.
dir() is one of the functions I'm linting for. But throughout the package, below both R/ and tests/, the name dir is frequently used for the path to a directory. So the linter reports dozens of false warnings.
Here's a small reprex with current lintr vs. after the change in my PR (#557):
library(lintr)
lint_this<-function(this, ...) {
file<- tempfile()
on.exit(unlink(file))
writeLines(this, con=file, sep="\n")
lint(file, ...)
}
linter<- undesirable_function_linter(fun= c("dir"=NA))
# warning is correct: I'm calling dir()
lint_this('dir(".")', linter)
#> /private/var/folders/pv/l2mbh7j90y5_vslh_1wyqxj00000gn/T/RtmpQbfI18/file121123553fe9e:1:1: warning: Function "dir" is undesirable.#> dir(".")#> ^~~# warning is WRONG: I'm defining an object named 'dir'
lint_this("dir <- 1:3", linter)
#> /private/var/folders/pv/l2mbh7j90y5_vslh_1wyqxj00000gn/T/RtmpQbfI18/file121121d71526c:1:1: warning: Function "dir" is undesirable.#> dir <- 1:3#> ^~~devtools::load_all("~/rrr/lintr")
#> ℹ Loading lintrlinter<- undesirable_function_linter(fun= c("dir"=NA))
# warning is correct: I'm calling dir()
lint_this('dir(".")', linter)
#> /private/var/folders/pv/l2mbh7j90y5_vslh_1wyqxj00000gn/T/RtmpQbfI18/file121127ada3f8d:1:1: warning: Function "dir" is undesirable.#> dir(".")#> ^~~# lack of warning is correct: I'm defining an object named 'dir'
lint_this("dir <- 1:3", linter)
Created on 2020-11-01 by the reprex package (v0.3.0.9001)
The text was updated successfully, but these errors were encountered:
* Option to control whether undesirable function names can appear as symbol
Closes#556
* Use inlined source
* Simplify
* Add expectation
* Remove examples
* Make test more concise
* operator spacing
Co-authored-by: AshesITR <alexander.rosenstock@web.de>
Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
I think the
undesirable_function_linter()
should only look for function calls. The context is that I want to use lintr to keep watch for base file system functions creeping into usethis (r-lib/usethis#531, r-lib/fs#85). I can almost do what I want with theundesirable_function_linter()
.But it reports tons of false positives, i.e. warns when it should not.
dir()
is one of the functions I'm linting for. But throughout the package, below bothR/
andtests/
, the namedir
is frequently used for the path to a directory. So the linter reports dozens of false warnings.Here's a small reprex with current lintr vs. after the change in my PR (#557):
Created on 2020-11-01 by the reprex package (v0.3.0.9001)
The text was updated successfully, but these errors were encountered: