The object_usage_linter won't acknowledge bindings from @import or @importFrom
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- r, typescript, vscode
- Domaine
- tooling
Piste de recherche
Reproduisez l’avertissement avec la configuration du package et l’exemple R/test.R, puis comparez le panneau Problems de VSCode avec devtools::check() et lintr::lint("R/test.R"). Suivez la manière dont l’extension vscode-R invoque l’object_usage_linter fourni par lintr et la manière dont @import et @importFrom sont traités. Le travail est terminé lorsque les bindings importés ne produisent plus de faux avertissements .data dans VSCode et que les vérifications lintr existantes continuent de réussir.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- TypeScript
- Étoiles
- 1.2k
- Forks
- 151
- Merge moyen
- 21 h 40 min
- PR mergées (30 j)
- 83
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de REditorSupport/vscode-R
-
[Bug]: indentation clash (formatter vs lintr)Peut-être pris @renkun-ken l’a pris il y a 6 jours. Ouvertebug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 92/100
REditorSupport/vscode-R#1883 ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: `view` button sends explicit `.GlobalEnv` lookup to terminal instead of `View()` onlyOuvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
REditorSupport/vscode-R#1846 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
(feat) Additional Arrow supportPeut-être pris @Fred-Wu l’a pris il y a 11 jours. Ouverteenhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
REditorSupport/vscode-R#1785 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: vscode-R 3.0.1: code from other project files silently executed in R session via sessOuvertebug needs information
Difficulté 4/5 3-5 jours Accessibilité débutants 12/100
REditorSupport/vscode-R#1877 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Explore a standalone, dependency-free R package for the Data Viewer backendPeut-être pris @eitsupi l’a pris il y a 13 jours. Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
REditorSupport/vscode-R#1860 · 14 commentaires · 1 réaction · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de REditorSupport/vscode-R
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
awslabs/visual-asset-management-system#804 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
restatedev/sdk-typescript#813 ·
-
bug desktop P1 session XS
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Merit-Systems/x402scan#1312 ·
-
type:bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Azure/apiops-cli#331 ·
Les mainteneurs répondent en général sous 3 jours