traitecoevo / plant

Trait-Driven Models of Ecology and Evolution :evergreen_tree:
https://traitecoevo.github.io/plant
53 stars 20 forks source link

Various fixes for Rcmdcheck #351

Closed dfalster closed 1 year ago

dfalster commented 2 years ago

Rcmdcheck complains about lots of issues. For example, see mentions at

https://github.com/traitecoevo/plant/actions/runs/3263550975/jobs/5362669197

or rund rcmdcheck::rcmdcheck() locally

These fixes try to rectify

Locally I'm still getting a fail, possibly due to request for specific version of tidyselect

I only get the fail when running tests via rcmdcheck::rcmdcheck() and not via devtools::test(). Worse am yet to isolate the cause. I've tried reverting functions in the R/tidy_outputs.R but it was still occurring.

@aornugent Can you run rcmdcheck::rcmdcheck() at your end and let me know how it goes?

aornugent commented 2 years ago

Hi - these are my local results. Looks like there's still a few warnings. I'll try chase them down.

 rcmdcheck::rcmdcheck()
── R CMD build ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file ‘.../DESCRIPTION’ ...
─  preparing ‘plant’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  installing the package to build vignettes
✔  creating vignettes (2m 11.4s)
─  cleaning src
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
   Removed empty directory ‘plant/tests/testthat/_snaps’
─  building ‘plant_2.0.0.9000.tar.gz’

── R CMD check ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─  using log directory ‘/tmp/RtmpzRrYRV/file71167f62abe7/plant.Rcheck’
─  using R version 4.2.1 (2022-06-23)
─  using platform: x86_64-pc-linux-gnu (64-bit)
─  using session charset: UTF-8
✔  checking for file ‘plant/DESCRIPTION’ ...
─  this is package ‘plant’ version ‘2.0.0.9000’
─  package encoding: UTF-8
✔  checking package namespace information
✔  checking package dependencies (1.8s)
✔  checking if this is a source package ...
✔  checking if there is a namespace
✔  checking for executable files (387ms)
✔  checking for hidden files and directories
✔  checking for portable file names
✔  checking for sufficient/correct file permissions
✔  checking whether package ‘plant’ can be installed (2m 4.8s)
N  checking installed package size ...
     installed size is 47.2Mb
     sub-directories of 1Mb or more:
       R      2.3Mb
       libs  43.8Mb
✔  checking package directory
✔  checking ‘build’ directory
✔  checking DESCRIPTION meta-information ...
✔  checking top-level files ...
✔  checking for left-over files
✔  checking index information ...
✔  checking package subdirectories ...
✔  checking R files for non-ASCII characters ...
✔  checking R files for syntax errors ...
✔  checking whether the package can be loaded ...
✔  checking whether the package can be loaded with stated dependencies ...
✔  checking whether the package can be unloaded cleanly ...
✔  checking whether the namespace can be loaded with stated dependencies ...
✔  checking whether the namespace can be unloaded cleanly ...
✔  checking loading without being on the library search path ...
✔  checking dependencies in R code (954ms)
✔  checking S3 generic/method consistency (633ms)
✔  checking replacement functions ...
✔  checking foreign function calls (649ms)
N  checking R code for possible problems (5s)
   run_resource_consumption_benchmarks: no visible binding for global
     variable ‘soil_layers’
   tidy_env : <anonymous>: no visible global function definition for
     ‘across’
   tidy_patch: no visible binding for global variable ‘.’
   Undefined global functions or variables:
     . across soil_layers
✔  checking Rd files ...
✔  checking Rd metadata ...
✔  checking Rd cross-references ...
✔  checking for missing documentation entries ...
✔  checking for code/documentation mismatches (1.1s)
W  checking Rd \usage sections ...
   Undocumented arguments in documentation object 'FF16_Environment'
     ‘canopy_light_tol’ ‘canopy_light_nbase’ ‘canopy_light_max_depth’
     ‘soil_initial_state’

   Undocumented arguments in documentation object 'K93_Environment'
     ‘canopy_light_tol’ ‘canopy_light_nbase’ ‘canopy_light_max_depth’
     ‘canopy_rescale_usually’

   Functions with \usage entries need to have the appropriate \alias
   entries, and all their arguments documented.
   The \usage entries must correspond to syntactically valid R code.
   See chapter ‘Writing R documentation files’ in the ‘Writing R
   Extensions’ manual.
✔  checking Rd contents (804ms)
✔  checking for unstated dependencies in examples ...
✔  checking line endings in C/C++/Fortran sources/headers ...
✔  checking line endings in Makefiles
✔  checking compilation flags in Makevars ...
✔  checking for GNU extensions in Makefiles ...
✔  checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS)
✔  checking use of PKG_*FLAGS in Makefiles
✔  checking compiled code ...
✔  checking installed files from ‘inst/doc’ ...
✔  checking files in ‘vignettes’
✔  checking examples (535ms)
✔  checking for unstated dependencies in ‘tests’ ...
─  checking tests ...
E  Running ‘testthat.R’ (41.3s)
   Running the tests in ‘tests/testthat.R’ failed.
   Complete output:
     > library(testthat)
     > library(plant)
     > 
     > test_check("plant")
     [ FAIL 1 | WARN 4 | SKIP 0 | PASS 2154 ]

     ══ Failed tests ════════════════════════════════════════════════════════════════
     ── Failure (test-tidy-outputs.R:125:7): Tidy outputs FF16 ──────────────────────
     `... <- NULL` produced warnings.

     [ FAIL 1 | WARN 4 | SKIP 0 | PASS 2154 ]
     Error: Test failures
     Execution halted
✔  checking for unstated dependencies in vignettes ...
✔  checking package vignettes in ‘inst/doc’ ...
─  checking running R code from vignettes
     ‘plant.Rmd’ using ‘UTF-8’... OK
    NONE
✔  checking re-building of vignette outputs (10.5s)
W  checking PDF version of manual (1.2s)
   LaTeX errors when creating PDF version.
   This typically indicates Rd problems.
   LaTeX errors found:
E  checking PDF version of manual without index (1.7s)

   See
     ‘/tmp/RtmpzRrYRV/file71167f62abe7/plant.Rcheck/00check.log’
   for details.

── R CMD check results ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── plant 2.0.0.9000 ────
Duration: 3m 16.9s

❯ checking tests ...
  See below...

❯ checking Rd \usage sections ... WARNING
  Undocumented arguments in documentation object 'FF16_Environment'
    ‘canopy_light_tol’ ‘canopy_light_nbase’ ‘canopy_light_max_depth’
    ‘soil_initial_state’

  Undocumented arguments in documentation object 'K93_Environment'
    ‘canopy_light_tol’ ‘canopy_light_nbase’ ‘canopy_light_max_depth’
    ‘canopy_rescale_usually’

  Functions with \usage entries need to have the appropriate \alias
  entries, and all their arguments documented.
  The \usage entries must correspond to syntactically valid R code.
  See chapter ‘Writing R documentation files’ in the ‘Writing R
  Extensions’ manual.

❯ checking PDF version of manual ... WARNING
  LaTeX errors when creating PDF version.
  This typically indicates Rd problems.
  LaTeX errors found:

❯ checking installed package size ... NOTE
    installed size is 47.2Mb
    sub-directories of 1Mb or more:
      R      2.3Mb
      libs  43.8Mb

❯ checking R code for possible problems ... NOTE
  run_resource_consumption_benchmarks: no visible binding for global
    variable ‘soil_layers’
  tidy_env : <anonymous>: no visible global function definition for
    ‘across’
  tidy_patch: no visible binding for global variable ‘.’
  Undefined global functions or variables:
    . across soil_layers

── Test failures ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── testthat ────

> library(testthat)
> library(plant)
> 
> test_check("plant")
[ FAIL 1 | WARN 4 | SKIP 0 | PASS 2154 ]

══ Failed tests ════════════════════════════════════════════════════════════════
── Failure (test-tidy-outputs.R:125:7): Tidy outputs FF16 ──────────────────────
`... <- NULL` produced warnings.

[ FAIL 1 | WARN 4 | SKIP 0 | PASS 2154 ]
Error: Test failures
Execution halted

1 error ✖ | 2 warnings ✖ | 2 notes ✖
aornugent commented 1 year ago

I'm not quite sure where this got up to, but I think we want to resolve in favour of the pass_checks branch?

#' @export
#'
#' @importFrom rlang .data
integrate_over_size_distribution <- function(tidy_species_data) {
  tidy_species_data  %>%
    dplyr::select(-.data$node) %>% stats::na.omit() %>%
    dplyr::filter(.data$step > 1) %>% 
    dplyr::group_by(.data$step, .data$time, .data$patch_density, .data$species) %>% 
    dplyr::summarise(

<<<<<<< pass_checks

      density_integrated = -trapezium(.data$height, .data$density), 
      min_height = min(.data$height),
      dplyr::across(tidyselect::where(is.double) & !c(.data$density, .data$density_integrated, .data$min_height) , ~-trapezium(height, density * .x)), 

=======

      density_integrated = -trapezium(height, density), 
      min_height = min(height),
      dplyr::across(where(is.double) & !c(density, density_integrated, min_height), 
                    ~-trapezium(height, density * .x)), 

>>>>>>> develop

      .groups = "drop"
    ) %>% 
    dplyr::rename(density = .data$density_integrated)
}