Contributing to flir
Source:.github/CONTRIBUTING.md
This outlines how to propose a change to flir.
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).
- flir uses roxygen2, with Markdown syntax, for documentation.
- If your PR is a user-visible change, you may add a bullet point in
NEWS.mddescribing the changes made. You may optionally add your GitHub username, and links to relevant issue(s)/PR(s).
Formatting
Formatting of R files is done by air, a command-line tool (not an R package). You can install it by following these instructions, and then run air format . in the folder.
How to add a new lint rule in flir?
Adding a rule that exists in lintr:
Create a new
.ymlfile ininstwithnew_rule("<rule_name>"), e.gnew_rule("expect_length").-
Import the tests from
lintrwithget_tests_from_lintr("<rule_name>"), e.gget_tests_from_lintr("expect_length"). Note that some tests use therex::rex()function. This is unnecessary in tests forflir. Instead ofmessage <- rex::rex("<message>")use
message <- "<part of message>" 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
.ymlfile so that most tests pass (in some cases, somelintrtests 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))
})