The object_usage_linter won't acknowledge bindings from @import or @importFrom
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- r
- Ambito
- developer-experience, devtools
Direzione di ricerca
The issue is in the object_usage_linter's handling of @import and @importFrom roxygen tags within vscode-R's lintr integration. Start by examining the lintr package's object_usage_linter.R source to see how it resolves bindings. Compare the vscode-R bundled lintr version with the standalone lintr::lint() behavior. Look at the languageserver's linter configuration and how it invokes lintr. Check if the namespace parsing differs. A test can be added to reproduce the warning in the languageserver context.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
The object_usage_linter that comes installed with vscode-R's lintr won't recognize functions added to package scope via @import and @importFrom calls. The linter that runs via devtools::check() or calling lintr::lint() directly, however, will. As such, there seems to be a bug in the lintr that comes packaged with vscode-R but not in other instances of lintr.
To Reproduce
Steps to reproduce the behavior:
- Create an R package via the R console
usethis::create_package("Test") - Run
usethis::use_mit_license() - Open the package in VSCode where you have the R extension installed
- Import deplyr and ggplot2 in the
DESCRIPTIONfile
Package: Test
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R:
person("First", "Last", , "[email protected]", role = c("aut", "cre"))
Description: What the package does (one paragraph).
License: MIT + file LICENSE
Imports:
dplyr,
ggplot2,
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
- Create an R file called test in the R directory
R/test.R - Paste these functions into test.R
#' Group rows by name
#'
#' This function groups the rows of a data frame by the column "name"
#' @param df A data frame.
#'
#' @import ggplot2
#' @return A grouped data frame.
#' @export
group_by_name <- function(df) {
data_grouped <- df |>
dplyr::group_by(.data$name)
data_grouped
}
#' Group rows by size
#'
#' This function groups the rows of a data frame by the column "size"
#' @param df A data frame.
#'
#' @importFrom ggplot2 .data
#' @return A grouped data frame.
#' @export
group_by_size <- function(df) {
data_grouped <- df |>
dplyr::group_by(.data$size)
data_grouped
}
- Run
devtools::document()anddevtools::load_all() - Go to problems panel or hover over .data in each of the functions and note the
no visible binding for global variable '.data'warnings.
- Run
devtools::check()and see that no errors, warnings, or notes arise - Run
lintr::lint("R/test.R")and seeℹ No lints found.
Can you fix this issue by yourself? (We appreciate the help)
No, attempting to reinstall the R, the vscode-R extension, and rlanguageserver have not helped. Here is my settings.json file:
{
"git.autofetch": true,
"git.confirmSync": false,
"[r]": {
"editor.defaultFormatter": "REditorSupport.r"
},
"r.rterm.mac": "/usr/local/bin/R",
}
Expected behavior
An @import or @importFrom call should update the global namespace such that the imported function is defined for the object_usage_linter in the lintr package included by the vscode-R extension.
Screenshots
Environment (please complete the following information):
- OS: macOS
- VSCode Version: 1.99.0 (Universal)
- R Version: R version 4.4.2 (2024-10-31)
- vscode-R version: 2.8.4
Additional context
Folks have a lot of issues with the object_usage_linter in lintr but I didn't find any that pertain directly to this, and as mentioned above, this doesn't seem to be an issue when invoking lintr without the vscode-R extension.
- Lingua principale
- R
- Stelle
- 675
- Fork
- 118
- Merge medio
- 1g 11h
- PR unite (30g)
- 11
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di REditorSupport/languageserver
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
REditorSupport/languageserver#776 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
REditorSupport/languageserver#735 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
REditorSupport/languageserver#731 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
REditorSupport/languageserver#730 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
REditorSupport/languageserver#771 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di REditorSupport/languageserver
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
Open-Systems-Pharmacology/OSPSuite.ParameterIdentification#308 ·
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
datacarpentry/semester-biology#1266 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
REditorSupport/vscode-R#1785 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno