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

CRAN submission issues #486

Closed
Robinlovelace opened this issue May 6, 2022 · 3 comments
Closed

CRAN submission issues #486

Robinlovelace opened this issue May 6, 2022 · 3 comments

Comments

@Robinlovelace
Copy link
Member

Flavor: r-devel-linux-x86_64-debian-gcc
Check: R code for possible problems, Result: NOTE
   File 'stplanr/R/zzz.R':
     .onLoad calls:
       packageStartupMessage(paste0("Loading stplanr v0.9.0.\n", "Note:
the next planned version, v1.0.0, will not support sp objects.\n",
"See the issue #332 and https://github.com/ropensci/stplanr/pull/481.",
    "Any feedback on GitHub: welcome. Thanks (Robin Lovelace, April
2022)!"))

   See section 'Good practice' in '?.onAttach'.

   Found if() conditions comparing class() to string:
   File 'stplanr/R/google-functions.R': if (class(from) ==
"SpatialPoints" | class(from) == "SpatialPointsDataFrame") ...
   File 'stplanr/R/google-functions.R': if (class(to) == "SpatialPoints"
| class(to) == "SpatialPointsDataFrame") ...
   File 'stplanr/R/oneway.R': if (class(x) == "factor") ...
   File 'stplanr/R/oneway.R': if (class(y) == "factor") ...
   File 'stplanr/R/oneway.R': if (class(x) == "factor") ...
   File 'stplanr/R/oneway.R': if (class(y) == "factor") ...
   File 'stplanr/R/route-transport-api.R': if (class(from) ==
"SpatialPoints" | class(from) == "SpatialPointsDataFrame") ...
   File 'stplanr/R/route-transport-api.R': if (class(to) ==
"SpatialPoints" | class(to) == "SpatialPointsDataFrame") ...
   File 'stplanr/R/route_cyclestreets.R': if (class(from) ==
"SpatialPoints" | class(from) == "SpatialPointsDataFrame") ...
   File 'stplanr/R/route_cyclestreets.R': if (class(to) ==
"SpatialPoints" | class(to) == "SpatialPointsDataFrame") ...
   Use inherits() (or maybe is()) instead.
@Robinlovelace
Copy link
Member Author

I think the .onAttach() message is a non-issue as we already follow best practice here:

Loading a namespace should where possible be silent, with startup messages given by .onAttach. These messages (and any essential ones from .onLoad) should use [packageStartupMessage](https://rstudio.robinlovelace.net/s/d5de8cf239dd2bbe73918/help/library/base/help/packageStartupMessage) so they can be silenced where they would be a distraction.

Robinlovelace added a commit that referenced this issue May 6, 2022
@agila5
Copy link
Collaborator

agila5 commented May 7, 2022

Hi Robin! I'm not sure if this is relevant, but I think the packageStartupMessage should be included in .onAttach not .onLoad:

stplanr/R/zzz.R

Lines 1 to 10 in 9d4b416

.onLoad <- function(libname, pkgname){
packageStartupMessage(
paste0(
"Loading stplanr v0.9.0.\n",
"Note: the next planned version, v1.0.0, will not support sp objects.\n",
"See the issue #332 and https://github.com/ropensci/stplanr/pull/481.",
"Any feedback on GitHub: welcome. Thanks (Robin Lovelace, April 2022)!"
)
)
}

@Robinlovelace
Copy link
Member Author

Hi Robin! I'm not sure if this is relevant, but I think the packageStartupMessage should be included in .onAttach not .onLoad:

Thanks for the tip but I'm not sure why you think that. From https://community.rstudio.com/t/when-to-use-onload-vs-onattach/21953 it seems that onAttach() seems to trigger more frequently.

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

No branches or pull requests

2 participants