ropensci-review-tools / goodpractice

Advice on R Package Building
https://docs.ropensci.org/goodpractice/
Other
461 stars 35 forks source link

Error in mypaste(...) : Need character strings on print with some tests #58

Closed barryrowlingson closed 3 months ago

barryrowlingson commented 7 years ago

Running cyclocomp check on its own gives an object that doesn't print. Also it seems to download cyclocomp everytime despite me already having it downloaded:

> all_checks()[2:10]
[1] "cyclocomp"                       "no_description_depends"         
[3] "no_description_date"             "description_url"                
[5] "description_bugreports"          "lintr_assignment_linter"        
[7] "lintr_line_length_linter"        "lintr_trailing_semicolon_linter"
[9] "lintr_attach_detach_linter"     
> g2 = gp(checks=all_checks()[2])
Preparing: cyclocomp
Downloading GitHub repo MangoTheCat/cyclocomp@master
* installing *source* package ‘cyclocomp’ ...
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (cyclocomp)
* installing *source* package ‘goodpractice’ ...
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (goodpractice)
> g2
Error in mypaste(...) : Need character strings

But if I run it and some other checks, it seems okay:

> g2_10 = gp(checks=all_checks()[2:10],quiet=FALSE)
Preparing: cyclocomp
Downloading GitHub repo MangoTheCat/cyclocomp@master
* installing *source* package ‘cyclocomp’ ...
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (cyclocomp)
* installing *source* package ‘goodpractice’ ...
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (goodpractice)
Preparing: description
Preparing: lintr
> g2_10
── GP goodpractice ─────────────────────────────────────────────────────────────

It is good practice to
[etc etc]

test 3 also makes a fail:

> all_checks()[2:3]
[1] "cyclocomp"              "no_description_depends"
> g3 = gp(checks=all_checks()[3],quiet=FALSE)
Preparing: description
> g3
Error in mypaste(...) : Need character strings

My g2 object is like this:

> dput(g2)
structure(list(path = ".", package = structure("goodpractice", .Names = "Package"), 
    cyclocomp = structure(list(name = c("print.goodPractice", 
    "linters_to_lint", "get_marker", "seq_linter", "CHECKS", 
    "goodpractice", "gp", "header_line", "check_passed", "gp_advice", 
    "gp_positions", "rstudio_source_markers", "trailing_semicolon_linter", 
    "%||%", "get_position", "package_collate", "r_package_files", 
    "all_checks", "attach_detach_linter", "check_failed", "checks", 
    "cyclocomp_limit", "dangerous_functions_linter", "default_r_file_pattern", 
    "drop_nulls", "export_json", "failed_checks", "failed_positions", 
    "get_lintr_position", "get_lintr_state", "get_markers", "get_package_name", 
    "gp_footer", "gp_header", "library_require_linter", "lines", 
    "loaded_pkg_version", "make_check", "make_line", "make_rcmd_check", 
    "prep_expressions", "PREPS", "results", "sapply_linter", 
    "setwd_linter", "trim_ws"), cyclocomp = c(10L, 9L, 8L, 7L, 
    5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L)), .Names = c("name", 
    "cyclocomp"), row.names = c(38L, 30L, 17L, 43L, 7L, 21L, 
    22L, 27L, 5L, 23L, 26L, 41L, 45L, 1L, 20L, 35L, 39L, 2L, 
    3L, 4L, 6L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 18L, 
    19L, 24L, 25L, 28L, 29L, 31L, 32L, 33L, 34L, 36L, 37L, 40L, 
    42L, 44L, 46L), class = "data.frame"), checks = structure(list(
        cyclocomp = TRUE), .Names = "cyclocomp")), .Names = c("path", 
"package", "cyclocomp", "checks"), class = "goodPractice")
gaborcsardi commented 7 years ago

Wait, are you running gp() on goodpractice itself?

gaborcsardi commented 7 years ago

Which is fine, just asking. :)

barryrowlingson commented 7 years ago

Yes, because that saves us having to agree on what we are testing!

Actually, its not fine is it? I get different (better) behaviour when running against another package source:

> g2_s = gp("~/Work/R/Stpp/Dev/stpp",checks=all_checks()[2],quiet=FALSE)
Preparing: cyclocomp
* installing *source* package ‘stpp’ ...
** libs
[etc]
* DONE (stpp)
> g2_s
── GP stpp ─────────────────────────────────────────────────────────────────────

It is good practice to

  x write short and simple functions. These functions have
    high cyclomatic complexity:rinfec (73).
──────────────────────────────────────────────────────────────────────────────── 
gaborcsardi commented 7 years ago

So, for goodpractice it is downloading cyclocomp every time, because goodpractice depends on the GitHub version of cyclocomp. (And remotes is not very smart to notice that the version on GitHub is still the same.)

The mypaste() error is another bug that seems familiar, but I cannot reproduce it now, even with the dput-ted object. Can you send a traceback? and a devtools::session_info()? Thanks.

barryrowlingson commented 7 years ago

traceback and sesh info:

> g2
Error in mypaste(...) : Need character strings
> traceback()
8: stop("Need character strings")
7: mypaste(...)
6: red(symbol$heart)
5: mypaste(...)
4: bold(red(symbol$heart))
3: cat("\n", sep = "", bold(red(symbol$heart)), praise(paste0(" ${Exclamation}! ${Adjective} package! ", 
       "Keep up the ${adjective} work!")), "\n")
2: print.goodPractice(x)
1: function (x, ...) 
   UseMethod("print")(x)
> devtools::session_info()
Session info -------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.0 (2016-05-03)
 system   x86_64, linux-gnu           
 ui       X11                         
 language (EN)                        
 collate  en_GB.utf8                  
 tz       <NA>                        
 date     2017-01-27                  

Packages -----------------------------------------------------------------------
 package      * version date       source                                   
 assertthat     0.1     2013-12-06 CRAN (R 3.3.0)                           
 backports      1.0.5   2017-01-18 CRAN (R 3.3.0)                           
 callr          1.0.0   2016-06-18 CRAN (R 3.3.0)                           
 clisymbols     1.0.0   2015-06-08 CRAN (R 3.3.0)                           
 covr           2.2.2   2017-01-05 CRAN (R 3.3.0)                           
 crayon         1.3.2   2016-06-28 CRAN (R 3.3.0)                           
 cyclocomp      1.1.0   2017-01-27 Github (MangoTheCat/cyclocomp@6156a12)   
 desc           1.1.0   2017-01-27 CRAN (R 3.3.0)                           
 devtools       1.12.0  2016-12-05 CRAN (R 3.3.0)                           
 digest         0.6.12  2017-01-27 CRAN (R 3.3.0)                           
 goodpractice * 1.0.0   2017-01-27 Github (MangoTheCat/goodpractice@e6ea88f)
 httr           1.2.1   2016-07-03 CRAN (R 3.3.0)                           
 jsonlite       1.2     2016-12-31 CRAN (R 3.3.0)                           
 lazyeval       0.2.0   2016-06-12 CRAN (R 3.3.0)                           
 lintr          1.0.0   2016-04-16 CRAN (R 3.3.0)                           
 magrittr       1.5     2014-11-22 CRAN (R 3.3.0)                           
 memoise        1.0.0   2016-01-29 CRAN (R 3.3.0)                           
 praise         1.0.0   2015-08-11 CRAN (R 3.3.0)                           
 R6             2.2.0   2016-10-05 CRAN (R 3.3.0)                           
 rcmdcheck      1.2.1   2016-09-28 CRAN (R 3.3.0)                           
 Rcpp           0.12.9  2017-01-14 cran (@0.12.9)                           
 remotes        1.0.0   2016-09-10 CRAN (R 3.3.0)                           
 rex            1.1.1   2016-12-05 CRAN (R 3.3.0)                           
 rprojroot      1.2     2017-01-16 CRAN (R 3.3.0)                           
 rstudioapi     0.6     2016-06-27 CRAN (R 3.3.0)                           
 whoami         1.1.1   2015-07-13 CRAN (R 3.3.0)                           
 withr          1.0.2   2016-06-20 CRAN (R 3.3.0)                           
 xml2           1.1.1   2017-01-24 CRAN (R 3.3.0)                           
 xmlparsedata   1.0.1   2016-06-18 CRAN (R 3.3.0)           
barryrowlingson commented 7 years ago

If I only had a heart:

clisymbols::symbol$heart NULL

gaborcsardi commented 7 years ago

LOL. Bug in the clisymbols package, for now, you need to install from GitHub:

source("https://install-github.me/gaborcsardi/clisymbols")

I wanted to add some symbols to it, anyway, so I'll submit to CRAN soon.