Spurious lintr message ?
Apologies in advance if this is the wrong place to raise this. I am making the assumption the issue is from how this extension is using lintr rather than with lintr itself.
Describe the bug
When developing a package the lintr warns of "no visible bindings" if a function is defined in another file
To Reproduce
- create an R package
- define a function in 1 file
- use that function in another file
- lintr complains that there is "no visible binding" for that function
Do you want to fix by self? (We hope your help!)
No (Well yes but it is likely to be multiple months before I get around to it sorry ! 😢 )
Settings
All settings are left as defaults as of v2.1.0
Expected behavior
Not to raise the warning
Screenshots

Environment (please complete the following information):
- OS: macOS Catalina
- VSCode Version: 1.58.2
- R Version: 4.1.0
- vscode-R version: 2.1.0
object_usage_linter does not well via lintr::lint() for package functions and multi-file cases. Please disable it in your project or global .lintr at the moment according to https://github.com/jimhester/lintr#lintr-file-example.
Arr ok so you guys are running it per file. I guess there is no solution to this then. I'd rather avoid disabling object_usage_linter as it can help identfy areas where functions truely haven't been defined. Hmmm I can't think of anyway of resolving this :( feel free to close I guess !
Are you using the latest dev of lintr? I'm running the latest lintr and object_usage_linter seems to work correctly.
I'm using "2.0.1" apparently which is the most recent CRAN version
Please try the latest development version via remotes::install_github("jimhester/lintr").
The current CRAN release is too old. A lot has been improved and fixed.
Installed the github version and restarted VScode, still am getting the same warning messages :( Are there any other meaningful diagnostics I could provide ?
Had the same issue (ton of "no visible binding" messages) - e.g. when using tags$div(...) from htmltools
Installing the most current dev-version devtools::install_github("r-lib/lintr") solved the issue for me (thank´s for the hint @renkun-ken 👏)
Seems version 3.0.0 is currently worked on and will hopefully be released soon 😀
Weird things happen: Today I opened my shiny-project (with shiny modules) and get a flood of warnings like:
no visible global function definition for ‘%>%’ object_usage_linter
I have the current lintr dev version 2.0.1.9000 and I´m pretty shure those warnings where not there before.
Maybe this is somehow related to this issue.
I have this too with lintr 3.0.0 in VS Code. ~Calling lintr::lint_package() works just fine~, and the LSP finds the object definitions in my R/ folder. However, lintr still throws object_usage_linter warnings for "no visible global function" and "no visible binding" for function calls and symbols, respectively. lintr doesn't seem to honor "NAMESPACE" either as imported names are not resolved.
sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.4
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
loaded via a namespace (and not attached):
[1] ps_1.7.0 crayon_1.5.1 withr_2.5.0
[4] rprojroot_2.0.3 R6_2.5.1 jsonlite_1.8.0
[7] rlang_1.0.3 cli_3.3.0 lazyeval_0.2.2
[10] remotes_2.4.2 callr_3.7.0 rex_1.2.1
[13] xml2_1.3.3 cyclocomp_1.1.0 desc_1.4.1
[16] tools_4.2.0 lintr_3.0.0 compiler_4.2.0
[19] processx_3.6.0
Relevant settings.json configuration
{
"[r]": {
"editor.defaultFormatter": "REditorSupport.r"
},
"r.alwaysUseActiveTerminal": true,
"r.bracketedPaste": true,
"r.rmarkdown.enableCodeLens": true,
"r.rterm.mac": "/usr/local/bin/radian",
"r.sessionWatcher": true,
"r.workspaceViewer.removeHiddenItems": true,
"r.lsp.args": [ "--no-save", "--no-restore" ],
"r.rpath.mac": "/usr/local/bin/R",
"r.rterm.option": [
"--no-save",
"--no-restore",
"--r-binary=/usr/local/bin/R"
]
}
Using reditorsupport.r version 2.5.2 with Visual Studio Code 1.70.2.
Edit: calling lintr::lint_package() actually is not okay. This might be a lintr problem?
@gowerc @psanker Would you like to try https://github.com/REditorSupport/languageserver/pull/568 and see if it works for you?
Works for me!