Allow for more flexibility in R lint checks in pre-commit hook
The current R lint check in the pre-commit hook has the following settings hard-coded:
linters=lintr::with_defaults(
object_name_linter=NULL,
commented_code_linter=NULL,
infix_spaces_linter=NULL
)
These are mainly based on my personal preference and may or may not make sense for all projects that can/do make use of the pre-commit hook.
Although I think it is wise to agree on a BIF-wide set of rules I don't think it is wise to hard-code those in the lint checks. Therefore I propose the following:
The lintr
package allows one to set the default lint checks on a pre-project (i.e. per Git repository) basis by creating a .lintr
file in the toplevel directory. A typical example of such a .lintr
file in line with the rules above would be:
linters: with_defaults(
object_name_linter=NULL,
commented_code_linter=NULL,
infix_spaces_linter=NULL
)
exclude: "# Exclude Linting"
exclude_start: "# Begin Exclude Linting"
exclude_end: "# End Exclude Linting"
This code also adds examples of to exclude linting for a given (next) line or a whole block of code.
I have tested this in the humanomics repo and it works.
Practically, removing the aforementioned defaults from the pre-commit hook means that the checks will be more strict (e.g. forcing SnakeCase
variables) than we have now. But each project can then define its own .lintr
file where we can (temporarily) deviate from the defaults.
For Humanomics specifically this means we would need to
- create the
.lintr
file - remove the hard-coded defaults from the script that runs the CI/CD lint checks
@lpalmeira @Benoit.Charloteaux what do you think of this proposal?