Skip to content

Improving use_spell_check() to address R CMD check error "Possibly misspelled words in DESCRIPTION" #1466

@coatless

Description

@coatless

Brief description of the problem

The usethis::use_spell_check() option creates a WORDLIST that is interpreted by only the {spelliing} package. Unfortunately, CRAN does not use the {spelling} package as part of the check. So, any words added to the custom dictionary provided by WORDLIST will come up as a dreaded note:

  • checking CRAN incoming feasibility ... NOTE
    Possibly misspelled words in DESCRIPTION:

Instead, they prefer the approach listed in ?"aspell-utils" that uses the .aspell top-level directory. That is, they check inside the .aspell for the inclusion of defaults.R alongside a user-defined RDS. A sample structure would look like:

├── .aspell
│   ├── defaults.R
│   ├── zspelling.rds
│   └── words.pws
├── DESCRIPTION
├── NAMESPACE
├── R
│   └── zspelling-package.R
├── inst
│   └── WORDLIST
├── man
│   └── zspelling-package.Rd
└── zspelling.Rproj

We can see where Kurt Hornik also used a similar structure: {relations} and {clue}. Dirk wrote this up a while back and, then, implemented it in {RcppArmadillo}. For a more recent addition, please see tmsalab/edmdata@45b4ec6.

With this being said, the workflow used is not documented in Writing R Extensions nor CRAN Repository Policies. Though, we can implement the desired functionality by adding a pre-commit hook to regenerate the package dictionary RDS when WORDLIST changes (i.e., in the case of the example above, zspelling.rds would be rebuilt). However, this technique only works with R versions starting from 3.0.0 onwards per the R 3.0.0 News Release Note:

aspell() gains filters for R code, Debian Control Format and message catalog files, and support for R level dictionaries. In addition, package utils now provides functions aspell_package_R_files() and aspell_package_C_files() for spell checking R and C level message strings in packages.

(Note, the lowest level of support for usethis is tagged to R 3.6.* at the moment.)

To support earlier versions, there would need to be a words.pws file generated and placed under .aspell/ directory. In particular, the .pws file is generated using an external dependency on either aspell, hunspell, or ispell; but, I'm not sure this is needed as the flat version would look like:

personal_ws-1.1 en 4 UTF-8
et
al

Perhaps only the metadata line would need to be prepended to WORDLIST?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions