Contributing to flint
Source:.github/CONTRIBUTING.md
This outlines how to propose a change to flint.
Fixing typos
Small typos or grammatical errors in vignettes can be fixed directly on the Github interface since vignettes are automatically rendered by pkgdown
.
Fixing typos in the documentation of functions (those in the “Reference” page) requires editing the source in the corresponding .R
file and then run devtools::document()
. Do not edit an .Rd
file in man/
.
Filing an issue
The easiest way to propose a change or new feature is to file an issue. If you’ve found a bug, you may also create an associated issue. If possible, try to illustrate your proposal or the bug with a minimal reproducible example.
Pull requests
General information
- Please create a Git branch for each pull request (PR).
- flint uses roxygen2, with Markdown syntax, for documentation.
- If your PR is a user-visible change, you may add a bullet point in
NEWS.md
describing the changes made. You may optionally add your GitHub username, and links to relevant issue(s)/PR(s).
How to add a new lint rule in flint
?
Adding a rule that exists in lintr
:
- Create a new
.yml
file ininst
withnew_rule("<rule_name>")
, e.gnew_rule("expect_length")
. - Import the tests from
lintr
withget_tests_from_lintr("<rule_name>")
, e.gget_tests_from_lintr("expect_length")
. - Add
"<rule_name>"
in the list of linters located inR/list-linters.R
. - Load the package with
devtools::load_all()
, and then runupdate_linter_factory()
. This creates a new entry inR/linters_factory.R
. - Run
devtools::document()
to register this new entry. - Tweak the
.yml
file so that most tests pass (in some cases, somelintr
tests can be commented out). - If the rule comes with a fix, add additional snapshot tests for
fix_text()
, e.g.
test_that("fix works", {
linter <- expect_length_linter()
expect_snapshot(fix_text("expect_equal(length(x), 2L)", linters = linter))
expect_snapshot(fix_text("expect_identical(length(x), 2L)", linters = linter))
expect_snapshot(fix_text("expect_equal(2L, length(x))", linters = linter))
expect_snapshot(fix_text("expect_identical(2L, length(x))", linters = linter))
})