ropensci-review-tools / pkgcheck

Check whether a package is ready for submission to rOpenSci's peer-review system
https://docs.ropensci.org/pkgcheck/
18 stars 6 forks source link

Print method not working when pkgcheck is not loaded #139

Closed maelle closed 2 years ago

maelle commented 2 years ago

Running pkgcheck on

── EMODnetWFS 2.0.1.9001 ────────────────────────────────────────────────────────────────────────────

✔ Package name is available
✔ has a 'codemeta.json' file.
✔ has a 'contributing' file.
✔ uses 'roxygen2'.
✔ 'DESCRIPTION' has a URL field.
✔ 'DESCRIPTION' has a BugReports field.
✔ Package has at least one HTML vignette
✖ These functions do not have examples: [emodnet_wfs].
✔ Package has continuous integration checks.
✖ Package coverage failed
✖ R CMD check found 1 error.
✖ R CMD check found 1 warning.

ℹ Current status:
✖ This package is not ready to be submitted.

── git ──

• HEAD: faff84b1
• Default branch: master
• Number of commits: 98
• First commit: 08-06-2020
• Number of authors: 4

── Package Structure ──

ℹ Package uses the following languages:
• R: 100%

ℹ Package has
• 2 authors.
• 3 vignettes.
• No internal data
• 16 imported packages.
• 11 exported functions (median 5 lines of code).
• 53 non-exported functions (median 8 lines of code).
• 4 parameters per function (median).
Erreur dans as.environment(pos) : 
  l'utilisation de 'as.environment(NULL)' n'est plus autorisée
Backtrace:
 1. base `<fn>`(x)
 2. pkgcheck:::print.pkgcheck(x)
 3. base::ls(env2namespace("pkgcheck"))
mpadge commented 2 years ago

Oh, that's just because you need to load the package for the print method to work

maelle commented 2 years ago

oooooh. Should there be a warning? Or even an error right at the beginning? (not urgent)

mpadge commented 2 years ago

Thanks @maelle and @assignUser, that was something I'd been wanting to solve for a while now, but really low-level. Solution is in that commit. This is how to list functions from a package regardless of whether the namespace is attached or not:

ls ("package:pkgcheck", envir = loadNamespace ("pkgcheck"))

Using a separate loadNamespace command does not work, but passing loadNamespace as the envir arg to ls() does. FYI.

maelle commented 2 years ago

Thank you, and nice trick!!

It reminds me of https://github.com/r-lib/usethis/issues/1579 solved in https://github.com/r-lib/usethis/pull/1597

mpadge commented 2 years ago

Yeah, except even tricker. The previous version was effectively the solution in your second link above, of tryCatch-ing to list a package environment, but this one goes one (tiny) step further through that envir parameter of ls.