goodpractice v1.0.2
0
Monthly downloads
Advice on R Package Building
Give advice about good practices when building R packages.
Advice includes functions and syntax to avoid, package structure,
code complexity, code formatting, etc.
Readme
goodpractice
Advice on R Package Building
Give advice about good practices when building R packages. Advice includes functions and syntax to avoid, package structure, code complexity, code formatting, etc.
Installation
source("https://install-github.me/MangoTheCat/goodpractice")
# or
# install.packages("devtools")
devtools::install_github("mangothecat/goodpractice")
Usage
library(goodpractice)
gp("<my-package>")
Example
library(goodpractice)
# use example package contained in the goodpractice package
pkg_path <- system.file("bad1", package = "goodpractice")
g <- gp(pkg_path)
g
#> ── GP badpackage ──────────────────────────────────────────────────────────
#>
#> It is good practice to
#>
#> ✖ not use "Depends" in DESCRIPTION, as it can cause name
#> clashes, and poor interaction with other packages. Use
#> "Imports" instead.
#> ✖ omit "Date" in DESCRIPTION. It is not required and it gets
#> invalid quite often. A build date will be added to the package
#> when you perform `R CMD build` on it.
#> ✖ 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.
#> ✖ omit trailing semicolons from code lines. They are not needed
#> and most R coding standards forbid them
#>
#> R/semicolons.R:4:30
#> R/semicolons.R:5:29
#> R/semicolons.R:9:38
#>
#> ✖ not import packages as a whole, as this can cause name clashes
#> between the imported packages. Instead, import only the
#> specific functions you need.
#> ✖ fix this R CMD check ERROR: VignetteBuilder package not
#> declared: ‘knitr’ See section ‘The DESCRIPTION file’ in the
#> ‘Writing R Extensions’ manual.
#> ✖ avoid 'T' and 'F', as they are just variables which are set to
#> the logicals 'TRUE' and 'FALSE' by default, but are not
#> reserved words and hence can be overwritten by the user.
#> Hence, one should always use 'TRUE' and 'FALSE' for the
#> logicals.
#>
#> R/tf.R:NA:NA
#> R/tf.R:NA:NA
#> R/tf.R:NA:NA
#> R/tf.R:NA:NA
#> R/tf.R:NA:NA
#> ... and 4 more lines
#>
#> ───────────────────────────────────────────────────────────────────────────
# show all available checks
# all_checks()
# run only a specific check
g_url <- gp(pkg_path, checks = "description_url")
g_url
#> ── GP badpackage ──────────────────────────────────────────────────────────
#>
#> It is good practice to
#>
#> ✖ 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.
#> ───────────────────────────────────────────────────────────────────────────
# which checks were carried out?
checks(g_url)
#> [1] "description_url"
# which checks failed?
failed_checks(g)
#> [1] "no_description_depends"
#> [2] "no_description_date"
#> [3] "description_url"
#> [4] "description_bugreports"
#> [5] "lintr_trailing_semicolon_linter"
#> [6] "no_import_package_as_a_whole"
#> [7] "rcmdcheck_package_dependencies_present"
#> [8] "truefalse_not_tf"
# show the first 5 checks carried out and their results
results(g)[1:5,]
#> check result
#> 1 covr NA
#> 2 cyclocomp TRUE
#> 3 no_description_depends FALSE
#> 4 no_description_date FALSE
#> 5 description_url FALSE
License
MIT © Mango Solutions
Functions in goodpractice
Name | Description | |
failed_checks | Names of the failed checks | |
goodpractice-package | goodpractice: Advice on R Package Building | |
gp | Run good practice checks | |
make_check | Create a check function | |
default_r_file_pattern | Default pattern for R files | |
export_json | Export failed checks to JSON | |
all_checks | List the names of all checks | |
make_prep | Create a preparation function | |
checks | List all checks performed | |
seq_linter | Find dangerous 1:x expressions | |
package_collate | `Collate` field from `DESCRIPTION` | |
prep_expressions | Extract all closures from a package | |
make_rcmd_check | Wrapper on make_check, specific to R CMD check | |
failed_positions | Positions of check failures in the source code | |
get_marker | Get a marker from the positions of a check | |
r_package_files | Get all source files of a package, in the right order | |
results | Return all check results in a data frame | |
No Results! |
Vignettes of goodpractice
Name | ||
custom_checks.Rmd | ||
goodpractice.Rmd | ||
No Results! |
Last month downloads
Details
License | MIT + file LICENSE |
LazyData | true |
URL | https://github.com/mangothecat/goodpractice |
BugReports | https://github.com/mangothecat/goodpractice/issues |
RoxygenNote | 6.0.1 |
Collate | 'api.R' 'customization.R' 'lists.R' 'chk_covr.R' 'chk_cyclocomp.R' 'chk_description.R' 'chk_lintr.R' 'chk_namespace.R' 'chk_rcmdcheck.R' 'chk_tnf.R' 'gp.R' 'my_linters.R' 'package.R' 'prep_covr.R' 'prep_cyclocomp.R' 'prep_description.R' 'prep_expressions.R' 'prep_lintr.R' 'prep_namespace.R' 'prep_rcmdcheck.R' 'print.R' 'rstudio_markers.R' 'utils.R' |
VignetteBuilder | knitr |
NeedsCompilation | no |
Packaged | 2018-05-01 10:54:47 UTC; hfrick |
Repository | CRAN |
Date/Publication | 2018-05-02 19:03:36 UTC |
imports | clisymbols , covr , crayon , cyclocomp (>= 1.1.0) , desc , jsonlite , lintr , praise , rcmdcheck , rstudioapi , tools , utils , whoami , withr , xml2 , xmlparsedata (>= 1.0.1) |
suggests | knitr , rmarkdown , testthat |
Contributors | Gabor Csardi |
Include our badge in your README
[](http://www.rdocumentation.org/packages/goodpractice)