-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
global variables not found? #27
Comments
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 This should get fixed though, thanks for opening the issue. |
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 One more thing: I tried to turn off the cache function, it reports the same lint results. |
Need to tweak logic at R/object_usage_linter.R#L8-L19 to evaluated the current file and include the top level names. |
Is someone working on this? or I can disable some linter to avoid this? |
You can disable the object_usage_linter to avoid it. |
broke test ny trying to trick my way through lintr, I now use .lintr and the and exlusion tags. lintr has some issue (r-lib/lintr#27).
I'm having this problem aswell. Can you tell me how to disable object_usage_linter? |
@galadude You can set the used linters when calling lint. For example:
I checked |
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. |
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.. |
* Address compatibility issues with testthat 2.0.0 * Work aroud issue r-lib/lintr#27
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 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? |
An update on the exclusion strategy. It is better to remove by name than by index position:
|
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? |
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! |
@mnist91 did you ever find a solution to this problem? I can't find any other issues that seem to address this. |
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. |
The same happens with variables which only exist within a data frame, within pipelines using e.g. |
Installing the package prior to linting fixed this for me, thank you! |
Script global variables should be detected, but they are not.
The text was updated successfully, but these errors were encountered: