inbo / checklist

An R package for checking R packages and R code
https://inbo.github.io/checklist
GNU General Public License v3.0
16 stars 2 forks source link

warnings appear in GitHub which are not reported by `check_project()` locally #122

Closed wlangera closed 1 month ago

wlangera commented 7 months ago

When I run the check_project() (or check_lintr()) locally I get no coding style problems. Yet, when I push this to my remote on GitHub, it reports warnings about no visible global function definition for 'st_cast'.

So there seems to be a mismatch between check check_project() locally and in the GitHub action. I use the latest release (checklist version 0.3.5).

Any ideas why this mismatch could occur?

ThierryO commented 7 months ago

Please compare the version numbers of checklist and lintr on both system. You find that information in the output of checklist.

When using a package in a custom function in a project you need to use the package::function notation for non base R functions. In your case sf::st_cast(). And add stopifnot(requireNamespace("sf", quietly = TRUE)) at the top of function. This makes the function gracefully halt when sf is not available.

wlangera commented 7 months ago

I notice indeed that i have locally:

version  R version 4.3.2 (2023-10-31 ucrt)

and

lintr          3.1.1.9000 2023-12-28 [1] https://inbo.r-universe.dev (R 4.3.2)

while on GitHub

version  R version 4.3.1 (2023-06-16)

and

lintr          3.0.2.9000 2023-07-14 [1] https://inbo.r-universe.dev/ (R 4.3.1)

How can I update this on GitHub such that it uses the same versions as me locally?

I use multiple sf-functions. Can I not use require(sf) instead of using sf:: all the time? (after stopifnot(requireNamespace("sf", quietly = TRUE)))

ThierryO commented 3 months ago

You can't update the versions on GitHub they are locked in the docker image

ThierryO commented 3 months ago

I use multiple sf-functions. Can I not use require(sf) instead of using sf:: all the time? (after stopifnot(requireNamespace("sf", quietly = TRUE)))

Unless your function is part of a package which Imports the required functions via the NAMESPACE, you always need to use the package::function notation. The NAMESPACE is the only thing that can guarantee that the function names are unique.