Skip to content

Namespace linter #548

Closed
Closed

Description

@renkun-ken

#547 implements a missing_package_linter() which checks if all packages loaded by library(), require(), loadNamespace(), and requireNamespace() are installed.

Apart from that, we could also check the usage of ns::obj and ns:::obj as they also used to access objects in a namespace (provided by package).

We could implement a separate linter (as suggested at #547 (comment)) to check if

  1. The package ns in ns::obj and ns:::obj are installed.
  2. The obj in ns::obj is exported from namespace ns.
  3. The obj in ns:::obj exists in namespace ns.

While checking 1 does not load any new package, checking 2 and 3 might load the package being checked. I'm not sure if we allow loading extra packages from user code?

Activity

  1. AshesITR commented on Oct 31, 2020

    @AshesITR
    Collaborator

    We already run user code for some linters:

    https://github.com/jimhester/lintr/blob/1a618f3f7df4889fe39eff5e0ce4e5c0fc6eadfd/R/object_usage_linter.R#L1-L4

    Maybe make these checks optional with a parameter and document that it may load packages if the parameter (check_exports = TRUE?) is set?

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions