Jarl

Just Another R Linter


Jarl is a fast linter for R: it does static code analysis to search for programming errors, bugs, and suspicious patterns of code.

Jarl is built on Air, a fast formatter for R written in Rust.


Quick start

You can use Jarl manually via the command line, or use extensions to have it integrated in your coding environment.

This shows how to use it in the terminal:

test.R:

any(is.na(x))

if (all.equal(x, y)) {
  print("x and y are equal")
}
# In the terminal:
$ jarl check test.R
warning: any_is_na
 --> test.R:1:1
  |
1 | any(is.na(x))
  | ------------- `any(is.na(...))` is inefficient.
  |
  = help: Use `anyNA(...)` instead.

warning: all_equal
 --> test.R:3:5
  |
3 | if (all.equal(x, y)) {
  |     --------------- `all.equal()` can return a string instead of FALSE.
  |
  = help: Wrap `all.equal()` in `isTRUE()`, or replace it by `identical()` if
    no tolerance is required.

Found 2 errors.
1 fixable with the `--fix` option (1 hidden fix can be enabled with the
`--unsafe-fixes` option).

Use --fix to automatically fix rule violations when possible:

$ jarl check test.R --fix

test.R:

anyNA(x)

if (all.equal(x, y)) {
  print("x and y are equal")
}

Installation

Binaries

Either get binaries from the Releases page or install Jarl from the existing installer scripts below.

macOS and Linux:

curl --proto '=https' --tlsv1.2 -LsSf \
  https://github.com/etiennebacher/jarl/releases/latest/download/jarl-installer.sh | sh

Windows:

powershell Set-ExecutionPolicy Bypass -Scope Process -Force; `
   iwr https://github.com/etiennebacher/jarl/releases/latest/download/jarl-installer.ps1 | iex

If you use Scoop, you can also install or update Jarl with these commands:

scoop bucket add r-bucket https://github.com/cderv/r-bucket.git

# install
scoop install jarl

# update
scoop update jarl

From source

Alternatively, if you have Rust installed, you can get the development version with:

cargo install --git https://github.com/etiennebacher/jarl jarl --profile=release

Acknowledgements

  • lintr authors and contributors: while the infrastructure is completely different, all the rule definitions and a large part of the tests are inspired or taken from lintr.
  • Davis Vaughan and Lionel Henry, both for their work on Air and for their advices and answers to my questions during the development of Jarl.
  • the design of Jarl is heavily inspired by Ruff and Cargo clippy.
  • R Consortium for funding part of the development of Jarl.

R Consortium logo

Footnotes

  1. Using 20 rules on the dplyr package (~25k lines of R code), Jarl took 0.131s, flir took 4.5s, and lintr took 18.5s (9s with caching enabled).↩︎