Giter VIP home page Giter VIP logo

Comments (15)

bcipolli avatar bcipolli commented on July 29, 2024 14

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.

AshesITR avatar AshesITR commented on July 29, 2024 1

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.

jimhester avatar jimhester commented on July 29, 2024

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.

randy3k avatar randy3k commented on July 29, 2024

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.

jimhester avatar jimhester commented on July 29, 2024

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.

KDr2 avatar KDr2 commented on July 29, 2024

Is someone working on this? or I can disable some linter to avoid this?
Thanks

from lintr.

jimhester avatar jimhester commented on July 29, 2024

You can disable the object_usage_linter to avoid it.

from lintr.

galadude avatar galadude commented on July 29, 2024

I'm having this problem aswell. Can you tell me how to disable object_usage_linter?

from lintr.

user01 avatar user01 commented on July 29, 2024

@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.

fangly avatar fangly commented on July 29, 2024

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.

leonelgalan avatar leonelgalan commented on July 29, 2024

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.

tsikerdekis avatar tsikerdekis commented on July 29, 2024

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.

mnist91 avatar mnist91 commented on July 29, 2024

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.

MichaelChirico avatar MichaelChirico commented on July 29, 2024

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.

alicebyers5 avatar alicebyers5 commented on July 29, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.