The object_usage_linter won't acknowledge bindings from @import or @importFrom
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- r, typescript, vscode
- Área
- tooling
Línea de trabajo
Reproduce la advertencia con la configuración del paquete y el ejemplo R/test.R, y compara el panel Problems de VSCode con devtools::check() y lintr::lint("R/test.R"). Rastrea cómo la extensión vscode-R invoca el object_usage_linter empaquetado de lintr y cómo se gestionan @import y @importFrom. Se considera terminado cuando los bindings importados ya no producen advertencias falsas de .data en VSCode y las comprobaciones existentes de lintr siguen pasando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.2k
- Forks
- 139
- Merge medio
- 23 h 31 min
- PR fusionados (30 d)
- 13
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de REditorSupport/vscode-R
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
REditorSupport/vscode-R#1687 · 4 comentarios · 3 reacciones ·
Los mantenedores suelen responder en 1 día
-
feature-request
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
REditorSupport/vscode-R#1763 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
REditorSupport/vscode-R#1755 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
REditorSupport/vscode-R#1751 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
REditorSupport/vscode-R#1749 · 5 comentarios · 3 reacciones ·
Los mantenedores suelen responder en 1 día
Todos los issues de REditorSupport/vscode-R
Issues similares
-
docs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
remix-run/react-router#15558 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
solana-foundation/pay-kit#341 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
supabase/agent-skills#607 ·
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día