ropensci / spelling

Tools for Spell Checking in R
https://docs.ropensci.org/spelling
Other
105 stars 27 forks source link

Spellcheck fails in R CMD check due to fixed WORDLIST link #40

Closed zappingseb closed 4 years ago

zappingseb commented 4 years ago

We created a test running:

spell_check_package(pkg, vignettes = TRUE, use_wordlist = TRUE)

In case this runs in R CMD check it fails on words which are obviously in the WORDLIST, This is the case for our NEWS.md and DESCRIPTION file. Not for .Rd files.

We noticed upon creating inst/inst/WORDLIST this error disappears. Can you make the location of the wordlist flexible in the call of spell_check_package? We can insert an if clause to check the mode (test / R CMD check) on our own.

Thanks

jeroen commented 4 years ago

I can't reproduce this problem. When I run spell_check_package(".", vignettes = TRUE) in a pkg dir, the results do not include words from the README.md or DESCRIPTION if those words are in the wordlist.

I find it very strange that inst/inst/WORDLIST solves your problem. Are you running this inside a source package or installed package?

zappingseb commented 4 years ago

Hi. I created a repo to show our thing:

https://github.com/zappingseb/test_spelling

Inside this repo everything is fine on devtools::test() but it fails in devtools::check()

We created a second branch with the duplicated inst directory, where devtools::check works fine.

jeroen commented 4 years ago

You have a very broken test setup. You are using testthat in which you load devtools and then you call spelling.

Your code doesn't work at all because you are running it on the installed package, which doesn't have the source code for the manual pages.

Can you please try instead to use spell_check_setup() to create the unit test? Or just copy the unit tests from any of the other packages that use spelling? So it looks like this: https://github.com/cran/curl/tree/master/tests

zappingseb commented 4 years ago

Thank you @jeroen

we noticed that our setup did not suite the spelling package

We changed the setup to this:

pkg <- get_package_info(source = TRUE)
if (grepl("lib", pkg$path)) {
  dir.create(file.path(pkg$path, "inst"))
  file.copy(file.path(pkg$path, "WORDLIST"), file.path(pkg$path, "inst/WORDLIST"))
}

test_that("misspelling", {
  spell_error <- spelling::spell_check_package(pkg, vignettes = TRUE, use_wordlist = TRUE)
  expect(
    nrow(spell_error) == 0,
    failure_message = apply(
      spell_error, 1,
      function(word) paste0("\nmisspelled word '", word[1], "' in ", word[2])
    ) %>%
      paste(collapse = "")
    )
})

This allowed us working with installed packages without screwing with your package.

Sorry for the inconvenience