Skip to content
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

no visible global variables (object-usage-linter) is still a matter #1127

Closed
milanglacier opened this issue May 8, 2022 · 4 comments · Fixed by #1136
Closed

no visible global variables (object-usage-linter) is still a matter #1127

milanglacier opened this issue May 8, 2022 · 4 comments · Fixed by #1136
Labels
feature a feature request or enhancement

Comments

@milanglacier
Copy link

packageVersion('lintr'): ‘2.0.1.9000’
I installed lintr via github and I am at commit 4ca7e484

The following example will yield the object-usage-linter error:

library(tidyverse)

dog = function() {
    a = rnorm(5) %>% sum()
    a
}

yields no visible global function definition for ‘%>%’ object_usage_linter [4, 1]

R --version

R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)
@AshesITR
Copy link
Collaborator

AshesITR commented May 8, 2022

Thanks for reporting this. You can circumvent the issue by loading all packages before linting, but if the library call is in the same file as the function, we can do something about it.

@milanglacier
Copy link
Author

Thanks for reporting this. You can circumvent the issue by loading all packages before linting, but if the library call is in the same file as the function, we can do something about it.

Yes, the library call is definitely in the same file as the function.
I don't understand what is circumvent the issue by loading all packages before linting,
does it mean that I fire the R process that runs the language server with those packages loaded?
like R --slave -e "source('loadingPackage.R'); rlanguageserver::run()"?

@AshesITR
Copy link
Collaborator

AshesITR commented May 8, 2022

Yes, that should work.

@AshesITR AshesITR added the feature a feature request or enhancement label May 9, 2022
@AshesITR
Copy link
Collaborator

AshesITR commented May 9, 2022

Implementation should be straight-forward once #239 is merged.
That PR provides the necessary functions to find all exported objects, which could then be passed to checkUsage() as known globals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants