Skip to content

Submit PRs for CRAN packages with "Lost braces" NOTE on "Rd files" check #110

@hturner

Description

@hturner

This task has been proposed by R Core developer Kurt Hornik, @kurthornik.

Background

The R package check (R CMD check) includes an "Rd files" check that returns a NOTE if issues are found in the .Rd source files for package documentation.

One part of this check is for "Lost braces", meaning that braces have been incorrectly escaped resulting in incorrectly formatted documentation.

This task is to submit pull requests to CRAN packages that have such a note, where the package is hosted on GitHub or another public repo, prioritising the packages with a higher number of reverse dependencies.

Identifying relevant packages

We can get the check results from the "r-devel-linux-x86_64-debian-gcc" machine, which are regularly updated (https://cran.r-project.org/web/checks/check_details_r-devel-linux-x86_64-debian-gcc.html). They were updated just before I ran this code, which identifies packages with any note about Rd files:

library(tools)

# get check information and identify packages with Rd files NOTE
details <- CRAN_check_details(flavors = "r-devel-linux-x86_64-debian-gcc")
Rd_NOTE <- subset(details, Check == "Rd files" & Status == "NOTE")
dim(Rd_NOTE)
#> [1] 1297    8

we can merge in additional information about the package:

# merge in package info (lose a few that we don't have info for)
pdb <- CRAN_package_db()
Rd_NOTE <- merge(Rd_NOTE, pdb)
dim(Rd_NOTE)
#> [1] 1289   74

Now we can restrict to those hosted on GitHub, GitLab or Bitbucket, and only those packages with the "Lost Braces" NOTE (this could be adapted to pick up other issues, if there is time).

# restrict "Lost braces" and packages that use GitHub to report issues
TODO <- Rd_NOTE[grepl("^http?s://(github.com|gitlab.com|bitbucket.org).*issues", 
                      Rd_NOTE$BugReports),]
TODO <- TODO[grepl("Lost braces", TODO$Output),]
dim(TODO)
#> [1] 402  74

Finally we prioritize by number of reverse dependencies:

# prioritise by n revdeps
revdeps <- strsplit(TODO$`Reverse depends`, ",")
n_revdeps <- lengths(revdeps)
n_revdeps[is.na(revdeps)] <- 0
    
TODO <- cbind(n_revdeps = n_revdeps, TODO)[order(n_revdeps, decreasing = TRUE),]
head(TODO[, c("n_revdeps", "Package", "BugReports")], 15)
#>      n_revdeps       Package                                                   BugReports
#> 399         12   gamlss.dist https://github.com/mstasinopoulos/GAMLSS-Distibutions/issues
#> 532          7         irlba                      https://github.com/bwlewis/irlba/issues
#> 665          6     miscTools          https://github.com/arne-henningsen/miscTools/issues
#> 79           5        BBmisc                 https://github.com/berndbischl/BBmisc/issues
#> 1057         4       shinyjs                   https://github.com/daattali/shinyjs/issues
#> 574          3 LaplacesDemon       https://github.com/LaplacesDemonR/LaplacesDemon/issues
#> 926          3 reactablefmtr              https://github.com/kcuilla/reactablefmtr/issues
#> 1094         3         smoof                  https://github.com/jakobbossek/smoof/issues
#> 1127         3         sqldf                https://github.com/ggrothendieck/sqldf/issues
#> 1170         3         sylly                https://github.com/unDocUMeantIt/sylly/issues
#> 1254         3   viridisLite            https://github.com/sjmgarnier/viridisLite/issues/
#> 118          2         brglm                    https://github.com/ikosmidis/brglm/issues
#> 559          2        koRpus               https://github.com/unDocUMeantIt/koRpus/issues
#> 676          2        mlrMBO                     https://github.com/mlr-org/mlrMBO/issues
#> 171          1          cmna                     https://github.com/k3jph/cmna-pkg/issues

It turns out all the packages with >1 reverse dependency are hosted on GitHub.

Fixing the issues

Sign in to GitHub and clone the repo. Make a new branch e.g. "lost-braces" to make your changes.

View the issues for the package you are working on. You could do this from the check page e.g.
https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-debian-gcc/gamlss.dist-00check.html
or from the TODO dataframe:

cat(TODO["399", "Output"])
#> checkRd: (-1) GEOM.Rd:56: Lost braces
#>     56 | for eqn{y=0,1,2,3,...} and \eqn{\mu>0},   see pp 473-474 of Rigby et al. (2019).
#>        |        ^
#> checkRd: (-1) GU.rd:61: Lost braces
#>     61 | \emph{Journal of Statistical Software}, Vol. \bold{23}, Issue 7, Dec 2007, \\doi{10.18637/jss.v023.i07}.
#>        |                                                                                 ^
#> checkRd: (-1) IG.Rd:55: Lost braces
#>     55 | \emph{Journal of Statistical Software}, Vol. \bold{23}, Issue 7, Dec 2007, \\doi{10.18637/jss.v023.i07}.
#>        |                                                                                 ^
#> checkRd: (-1) LOGITNO.Rd:55: Lost braces
#>     55 | \emph{Journal of Statistical Software}, Vol. \bold{23}, Issue 7, Dec 2007, \\doi{10.18637/jss.v023.i07}.
#>        |                                                                                 ^
#> checkRd: (-1) Multinomial.Rd:69: Lost braces
#>     69 | The function \code{MULTIN()} can be used instead of code{MN3()}, \code{MN4()} and \code{MN5()} by specifying the number of levels of the response. Note that \code{MULTIN(2)} will produce a binomial fit. 
#>        |                                                         ^
#> checkRd: (-1) PARETO2.Rd:38: Lost braces
#>     38 | The parameters are  \code{mu} and \code{sigma} in both functions but the parameterasation different.  The \code{mu} is identical for both \code{PARETO2()} and  \code{PARETO2o()}. The \code{sigma} in  \code{PARETO2o()} is the inverse of the \code{sigma} in code{PARETO2()} and coresponse to the usual parameter \code{alpha} of the Patreto distribution. The functions \code{dPARETO2}, \code{pPARETO2}, \code{qPARETO2} and \code{rPARETO2} define the density, distribution function, quantile function and random generation for the \code{PARETO2} parameterization of the Pareto type 2 distribution while the functions \code{dPARETO2o}, \code{pPARETO2o}, \code{qPARETO2o} and \code{rPARETO2o} define the density, distribution function, quantile function and random generation for the original \code{PARETO2o} parameterization of the Pareto type 2 distribution
#>        |                                                                                                                                                                                                                                                                     ^
#> checkRd: (-1) PIG.Rd:31: Lost braces
#>     31 | generation for the Poisson-inverse Gaussian \code{PIG()}, distribution.  Also code{dPIG2}, \code{pPIG2}, \code{qPIG2} and \code{rPIG2} are the equivalent functions for code{PIG2()}
#>        |                                                                                   ^
#> checkRd: (-1) PIG.Rd:31: Lost braces
#>     31 | generation for the Poisson-inverse Gaussian \code{PIG()}, distribution.  Also code{dPIG2}, \code{pPIG2}, \code{qPIG2} and \code{rPIG2} are the equivalent functions for code{PIG2()}
#>        |                                                                                                                                                                             ^
#> checkRd: (-1) SI.Rd:70: Lost braces
#>     70 | \emph{Journal of Statistical Software}, Vol. \bold{23}, Issue 7, Dec 2007, \\doi{10.18637/jss.v023.i07}.
#>        |                                                                                 ^

The problems are indicated with a caret (^). In the first couple of examples:

  • for eqn{y=0,1,2,3,...} should be: for \eqn{y=0,1,2,3,...}
  • \\doi{10.18637/jss.v023.i07}. should be \doi{10.18637/jss.v023.i07}.

In these examples the author does not intend to include a literal brace character in the rendered help file. If they did, it would need to be escaped, i.e. \{ would be rendered as {. Refer to Writing R Extensions if you are unsure of the correct syntax.

Make corrections in the appropriate file: .R if the packages uses roxygen2, or .Rd otherwise. if the package uses roxygen2, regenerate the documentation, e.g. with roxygen2::roxygenize() or devtools::document(). Check the Rd file with tools::checkRd() and preview with tools::Rd2HTML() or with devtools::load_all() followed by opening/refreshing the help file.

Once you have fixed the issues, open a PR to the original repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions