goodpractice suggested improvements

Issue #1 new
Finn Lindgren created an issue

Running goodpractice::gp() on the package reveals a few issues; some easily fixed, some more long term awareness issues:

goodpractice::gp("~/hg/pkg/excursions/")
#> Preparing: covr
#> Preparing: cyclocomp
#> 
#>   
   checking for file/tmp/RtmpbMlA9o/remotes17c379035df9/excursions/DESCRIPTION...checking for file/tmp/RtmpbMlA9o/remotes17c379035df9/excursions/DESCRIPTION#> preparingexcursions:
#> 

   checking DESCRIPTION meta-information ...checking DESCRIPTION meta-information
#> cleaning src
#> checking for LF line-endings in source and make files and shell scripts
#> checking for empty or unneeded directories
#> buildingexcursions_2.4.5.9000.tar.gz#> 


#> 
#> Preparing: description
#> Preparing: lintr
#> Warning in readLines(filename): incomplete final line found on '/home/flindgre/
#> hg/pkg/excursions/R/inlautils.R'
#> Warning in readLines(file): incomplete final line found on '/home/flindgre/hg/
#> pkg/excursions/R/inlautils.R'
#> Preparing: namespace
#> Preparing: rcmdcheck
#> ── GP excursions ───────────────────────────────────────────────────────────────
#> 
#> It is good practice to
#> 
#>   ✖ write unit tests for all functions, and all package code in
#>     general. 46% of code lines are covered by test cases.
#> 
#>     R/contourmap.inla.R:137:NA
#>     R/contourmap.inla.R:139:NA
#>     R/contourmap.inla.R:149:NA
#>     R/contourmap.inla.R:152:NA
#>     R/contourmap.inla.R:164:NA
#>     ... and 1939 more lines
#> 
#>   ✖ write short and simple functions. These functions have high
#>     cyclomatic complexity:contourmap (77), contourmap.inla (70),
#>     tricontour.list (64), excursions.inla (60).
#>   ✖ not use "Depends" in DESCRIPTION, as it can cause name clashes, and
#>     poor interaction with other packages. Use "Imports" instead.
#>   ✖ add a "URL" field to DESCRIPTION. It helps users find information
#>     about your package online. If your package does not have a
#>     homepage, add an URL to GitHub, or the CRAN package package page.
#>   ✖ add a "BugReports" field to DESCRIPTION, and point it to a bug
#>     tracker. Many online code hosting services provide bug trackers for
#>     free, <https://github.com,> <https://gitlab.com,> etc.
#>   ✖ use '<-' for assignment instead of '='. '<-' is the standard, and R
#>     users and developers are used it and it is easier to read your code
#>     for them if you use '<-'.
#> 
#>     R/contourmap.inla.R:144:11
#>     R/contourmap.inla.R:147:13
#>     R/contourmap.inla.R:149:13
#>     R/contourmap.inla.R:154:11
#>     R/contourmap.inla.R:163:15
#>     ... and 763 more lines
#> 
#>   ✖ avoid long code lines, it is bad for readability. Also, many people
#>     prefer editor windows that are about 80 characters wide. Try make
#>     your lines shorter than 80 characters
#> 
#>     R/contourmap.inla.R:20:1
#>     R/contourmap.inla.R:24:1
#>     R/contourmap.inla.R:25:1
#>     R/contourmap.inla.R:26:1
#>     R/contourmap.inla.R:30:1
#>     ... and 296 more lines
#> 
#>   ✖ omit trailing semicolons from code lines. They are not needed and
#>     most R coding standards forbid them
#> 
#>     R/contourmap.inla.R:306:33
#>     R/contourmap.inla.R:311:33
#>     R/contourmap.inla.R:318:33
#>     R/contourutil.R:353:12
#>     R/simconf.R:121:19
#>     ... and 1 more lines
#> 
#>   ✖ avoid sapply(), it is not type safe. It might return a vector, or a
#>     list, depending on the input data. Consider using vapply() instead.
#> 
#>     R/contourmap.inla.R:236:22
#>     R/contourmap.inla.R:242:22
#>     R/excursions.inla.R:199:13
#>     R/excursions.inla.R:224:16
#>     R/excursions.inla.R:228:16
#>     ... and 29 more lines
#> 
#>   ✖ avoid the library() and require() functions, they change the global
#>     search path. If you need to use other packages, import them. If you
#>     need to load them explicitly, then consider loadNamespace()
#>     instead, or as a last resort, declare them as 'Depends'
#>     dependencies.
#> 
#>     R/utils.R:510:5
#> 
#>   ✖ avoid 1:length(...), 1:nrow(...), 1:ncol(...), 1:NROW(...) and
#>     1:NCOL(...) expressions. They are error prone and result 1:0 if the
#>     expression on the right hand side is zero. Use seq_len() or
#>     seq_along() instead.
#> 
#>     R/contourmap.inla.R:230:15
#>     R/contourmap.inla.R:236:29
#>     R/contourmap.inla.R:242:29
#>     R/contourmap.R:209:15
#>     R/contourutil.R:271:23
#>     ... and 14 more lines
#> 
#>   ✖ not import packages as a whole, as this can cause name clashes
#>     between the imported packages. Instead, import only the specific
#>     functions you need.
#> ────────────────────────────────────────────────────────────────────────────────

<sup>Created on 2020-02-28 by the reprex package (v0.3.0)</sup>

Comments (0)

  1. Log in to comment