Skip to content

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

Closed

Description

@milanglacier

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)

Activity

  1. AshesITR commented on May 8, 2022

    @AshesITR
    Collaborator

    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.

  2. milanglacier commented on May 8, 2022

    @milanglacier
    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()"?

  3. AshesITR commented on May 8, 2022

    @AshesITR
    Collaborator

    Yes, that should work.

  4. added
    feature
    on May 9, 2022
  5. AshesITR commented on May 9, 2022

    @AshesITR
    Collaborator

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions