nmfs-fish-tools / ghactions4r

Reusable github actions workflows for R packages
https://nmfs-fish-tools.github.io/ghactions4r/
12 stars 1 forks source link

add devtools::spell_check() to new or existing workflow? #36

Closed iantaylor-NOAA closed 1 year ago

iantaylor-NOAA commented 2 years ago

In recent preparation of {r4ss} for CRAN, I was prompted by devtools::release() to use devtools::spell_check().

I hadn't ever found it very useful in the past because it's a pain to search through the large number of acronyms and variable names that aren't in the standard dictionary. However, this time I took the time to read the documentation at https://devtools.r-lib.org/reference/spell_check.html, and learned about the very easy process of automatically creating a custom list of correctly spelled words in inst/WORDLIST via spelling::get_wordlist().

An example of the numerous misspellings in the {r4ss} (including "NFMS", "Mone Carlo", and "mangagement") as well as the new WORDLIST file can be seen in this commit https://github.com/r4ss/r4ss/commit/1ab5a4bb30b41eb1b395225651f1759cc4310cf9. Once the WORDLIST is created, then future runs of devtools::spell_check() will either return "No spelling errors found" or a short list of actual errors or new words added to the code that are not standard.

I don't think it makes sense for the action to fail if the spell check finds things, but automatically reporting the list of words not in the dictionary or WORDLIST would be helpful and save users from remembering to runt the check themselves. Users can expand their WORDLIST via spelling::update_wordlist() or manually adding words to the file.

k-doering-NOAA commented 2 years ago

This is a good idea! I always forget to run this as well. It seems like it would be best as it's own stand-alone workflow to me.

I also think it should error if spelling errors are found, otherwise I don't think people will remember to check the output (well, at least this is true for me!)

k-doering-NOAA commented 1 year ago

@iantaylor-NOAA I finally tried out this tool and it is amazing! So easy to use. I didn't get a chance to set up the workflow yet, but now I'm really eager to.

iantaylor-NOAA commented 1 year ago

@k-doering-NOAA, good to hear!

I now think I was a fool to suggest that the action could pass if possible misspellings are found where the user would have to remember to check the results. As you suggest in your first comment, nobody will ever do that. Fixing a failing action by adding to WORDLIST or correcting the misspellings will be easy enough.

k-doering-NOAA commented 1 year ago

The spelling::update_wordlist() really lowers the barrier of entry, to using this! I now want to use this for all my R packages because it is so easy :)

k-doering-NOAA commented 1 year ago

I got this working on the add-spell-check branch, but am still missing the part that fails the job if errors were found. Should be able to add this next week!

iantaylor-NOAA commented 1 year ago

Thanks for adding this @k-doering-NOAA. ghactions4r::use_spell_check() worked flawlessly to add this github action to {r4ss}. It failed on the first try because of 4 new words (like "Tweedie") which were easily added via spelling::update_wordlist(). I hadn't realized that update_wordlist() also removes words that are no longer in use in the package, which is nice.

k-doering-NOAA commented 1 year ago

That's awesome!

I'm adding one more note here that there is an alternative way of running spell check, which can be set up with usethis::use_spell_check(). Instead of adding a separate Github action, it adds in spell check to R CMD Check.