Comments (15)
Any sense of priority on this? The linter complains about functions defined within the same file, not being found; this seems pretty basic.
Disabling the linting check ... defeats the purpose of having a linter. It's a critical check for a linter to do.
It's been almost 3 years; can anything be done to bump up the priority on this? I'm not sure my R chops are up to snuff to tackle this one..
from lintr.
Hi @alicebyers5, if you are developing a package, installing the package prior to linting will eliminate all object usage warnings related to symbols in the package namespace.
There is a documentation issue to track alerting users of this quirk.
from lintr.
This is an unfortunate side effect from switching to parsing each top-level expression separately (so that each expression can be cached separately) rather than parsing the whole file at once.
If you are developing a package lintr
will include of the symbols in the package namespace as globals (you just need to install some version of the in-development package).
This should get fixed though, thanks for opening the issue.
from lintr.
Hi Jim,
Thanks for the quick response. I forgot to thank you for this amazing package. I have been looking for a comprehensive R linting package for a while until I discovered this.
I work with R script files most of the time. It would be great if lintr
can handle script global variables correctly.
One more thing: I tried to turn off the cache function, it reports the same lint results.
from lintr.
Need to tweak logic at R/object_usage_linter.R#L8-L19 to evaluated the current file and include the top level names.
from lintr.
Is someone working on this? or I can disable some linter to avoid this?
Thanks
from lintr.
You can disable the object_usage_linter to avoid it.
from lintr.
I'm having this problem aswell. Can you tell me how to disable object_usage_linter?
from lintr.
@galadude You can set the used linters when calling lint. For example:
lintr::lint_package(linters=lintr::default_linters[-14])
I checked names(lintr::default_linters)
, "found object_usage_linter" index, and removed it for the lint.
from lintr.
I am also having "no visible global function definition for 'bakName'" and "no visible binding for global variable for global variable 'test'" lints, though, they only happen in my "tests/testthat/helper_utils.R" file:
test <- new.env()
bakName <- function(funName, envir) {
paste0(environmentName(envir), "_", funName, ".bak")
}
overwriteFunction <- function(oldFun, newFun, envir=baseenv()) {
assign(bakName(oldFun, envir), get0(oldFun, envir = envir), envir = test)
assign(oldFun, newFun, envir = envir)
}
My "R/*" files do not generate it, and neither do my "tests/testthat/test*.R" files.
from lintr.
I'm very new to R, so I'm not sure if this is the same issue but doing:
library(bar)
foo <- bar()
Give me a "no visible global function for bar
, did you mean 'x'?" This code works, this library, defines the function, is just a lintr issue.
Is the key still in https://github.com/jimhester/lintr/blob/master/R/object_usage_linter.R#L8-L19 like suggested by @jimhester? He said "to evaluated the current file and include the top level names.", any one has pointers of where to get started?
from lintr.
An update on the exclusion strategy. It is better to remove by name than by index position:
lintr::lint_package(linters=subset(lintr::default_linters,!lintr::default_linters %in% lintr::default_linters["object_usage_linter"] ))
from lintr.
I still encounter this issue when running lint-checks on github workfows. The very own functions of the package are not found by lintr. Has anyone solved this issue rather than disabling the object_usage_linter?
from lintr.
Hi @mnist91, please open a new issue with an example if you're able.
FYI, search around other issues with the same 'object linters' tag first, it might solve your issue. if so, still feel free to open a documentation request if you think that can be improved. Thanks!
from lintr.
@mnist91 did you ever find a solution to this problem? I can't find any other issues that seem to address this.
from lintr.
Related Issues (20)
- indentation_linter: multiline expression with braced block HOT 4
- indentation_linter: fenced code blocks inside enumeration in RMarkdown document HOT 1
- Lint *\.[rR] files in exec folder on `lint_package` HOT 1
- New `tolerance_linter()` to detect use of `round()` instead of a custom `tolerance` value
- Disagreement between `indentation_linter()` and `{styler}` when expression is in parentheses HOT 2
- Error in rep.int(character, length) : invalid 'times' value HOT 6
- Rename no_tabs_linter() to whitespace_linter()
- Drop deprecated linters from individual tag pages HOT 2
- available_linters(tags = "deprecated") should "just work" HOT 3
- False positive in `function_left_parentheses_linter()` HOT 1
- Skip eval=FALSE chunks
- Allow `expect_identical(names(x), names(y))` HOT 5
- no visible global function definition false positive when inside a function inside a script with the necessary library call HOT 5
- Potential speedup from `cyclocomp` HOT 8
- New lint to not use `{}` in generic HOT 3
- conflicting note on global variable assignment HOT 8
- get0 linter
- Minor typos in NEWS.md HOT 1
- Make `backport_linter()` more informative by default HOT 5
- linter to ensure roxygen documentation for all functions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lintr.