Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace linter #548

Closed
renkun-ken opened this issue Oct 31, 2020 · 1 comment · Fixed by #551
Closed

Namespace linter #548

renkun-ken opened this issue Oct 31, 2020 · 1 comment · Fixed by #551

Comments

@renkun-ken
Copy link
Collaborator

#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?

@AshesITR
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants