Tool to find code that is not optimal, likely wrong, hard to read, etc.
It performs static analysis.
Most languages have at least one linter.
A linter is opinionated.
All possible violations:
x = y * .52
not important: use <- instead of =
not important: use 0.52 instead of .52
important: all.equal(x, z) doesn’t return FALSE if x != z
So far in R: lintr
any(is.na(x)) -> anyNA(x)But:
Three ways to use Jarl:
Basic usage:
Rules can come with safe fixes, unsafe fixes, or no fixes at all:
Note
By default, fixes are not applied if:
Use --allow-no-vcs and --allow-dirty carefully!
Install the “Jarl” extension in your editor (Positron, Zed, VS Code, Neovim, Helix, etc.). RStudio integration is not possible.
Using the extension enables code highlighting and code actions.
Use the GitHub actions workflow: setup-jarl

For the occasional false positive, use suppression comments:
For more important changes to Jarl’s output, you will need to configure Jarl.
With CLI arguments (temporary)
# Use the rules "any_is_na" and "any_duplicated" only
jarl check . --select any_is_na,any_duplicated
# Use all default rules + testthat rules except "expect_named"
jarl check . --extend-select TESTTHAT --ignore expect_named
# Get a more concise version of rule violations
jarl check . --output-format concise
# All commands
jarl check --helpWith jarl.toml (permanent)
jarl.toml
CLI arguments always override jarl.toml arguments.
Requirements to add rules:
need some knowledge of Rust
need basic knowledge of Abstract Syntax Trees (AST)
no plugin mechanism, changes must be integrated in Jarl directly.
Note
I’m not a Rust expert, other code improvements are also welcome!
General contributing guide:
https://jarl.etiennebacher.com/contributing
Tutorial on contributing a rule:
Some testthat rules to implement
Improve the coverage of lintr rules
Discuss existing suggestions, or propose your own rule!
You can install and run Jarl in three seconds (literally), give it a try!
Full docs: jarl.etiennebacher.com