You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FR: use_lintr function to help set up code linting for package #579
The package does not have a use_lintr helper, but I use the lintr package with all of my packages and it is helpful to have a function that can automate the set up of this piece of package scaffolding. Others may find it similarly useful.
I see three typical ways to use lintr with a package:
local interactive use
automatic use on Travis CI post-build (non-failing)
automatic local and Travis CI as a unit test (failing)
I think the first option should be the default. It is the simplest. The second option is the official recommended approach, which involves adding to .travis.yml:
after_success:
- R CMD INSTALL $PKG_TARBALL
- Rscript -e 'lintr::lint_package()'
but this option is specifically for cases where someone does not wish to have a unit test, or a build failure when the linter finds style issues.
The third option is the most rigorous and is intended to fail a build, locally and on Travis, if there are style issues present. Personally, I use this option almost exclusively in my packages, but it should not be the default because it is the most complex and also may not be desirable for long-running test suites.
I have an initial version of a function and will submit a pull request.
Example of a good thing to check for users of devtools/usethis:
Any top-level instance of usethis::use_SOMETHING() below R/ is almost certainly an error, i.e. some package development code has been left behind in the package source. An example of this came up during the usethis v1.5.0 submission vis-a-vis KSPM.
Activity
jennybc commentedon Apr 7, 2019
Example of a good thing to check for users of devtools/usethis:
Any top-level instance of
usethis::use_SOMETHING()belowR/is almost certainly an error, i.e. some package development code has been left behind in the package source. An example of this came up during the usethis v1.5.0 submission vis-a-vis KSPM.hadley commentedon Oct 21, 2019
In the not-to-distant future, I think the obvious way to implement this will be as a GitHub action.
jimhester commentedon Mar 17, 2020
There is now a linting workflow example (https://github.com/r-lib/actions/tree/master/examples#lint-workflow). You can use it from dev usethis with
usethis::use_github_action("lint")