From 4ada25994d11986fb59efb0b8cdd6c370ad65748 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Tue, 11 Aug 2026 15:50:44 +0200 Subject: [PATCH 1/2] GH-47937: [dev][R] Replace linr with jarl for R linting / pre-commit check --- .github/workflows/dev.yml | 2 -- .pre-commit-config.yaml | 13 +++--------- .../developers/guide/step_by_step/styling.rst | 5 ++--- r/jarl.toml | 20 +++++++++++++++++++ r/vignettes/developers/workflow.Rmd | 17 ++++++++-------- 5 files changed, 34 insertions(+), 23 deletions(-) create mode 100644 r/jarl.toml diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 4b69c4e0b46e..595ab9a933c5 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -56,7 +56,6 @@ jobs: sudo apt update sudo apt install -y -V \ pre-commit \ - r-base \ ruby-dev \ libuv1-dev - name: Cache pre-commit @@ -64,7 +63,6 @@ jobs: with: path: | ~/.cache/pre-commit - ~/.local/share/renv/cache key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - name: Run pre-commit run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8adc2275e5b5..4de68a739a52 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -188,19 +188,12 @@ repos: ?^python/pyarrow/util\.py$| ?^python/pyarrow/vendored/| ) - - repo: local + - repo: https://github.com/etiennebacher/jarl-pre-commit + rev: "0.5.0" hooks: - - id: lintr + - id: jarl-check alias: r name: R Lint - language: r - additional_dependencies: - - cyclocomp - - lintr - - testthat - entry: | - Rscript -e "Sys.setenv(NOT_CRAN = 'TRUE'); lintr::expect_lint_free('r')" - pass_filenames: false files: >- ^r/.*\.(R|Rmd)$ - repo: https://github.com/posit-dev/air-pre-commit diff --git a/docs/source/developers/guide/step_by_step/styling.rst b/docs/source/developers/guide/step_by_step/styling.rst index 060fb7922c08..10b57bf48d56 100644 --- a/docs/source/developers/guide/step_by_step/styling.rst +++ b/docs/source/developers/guide/step_by_step/styling.rst @@ -38,12 +38,11 @@ linters and styling of the code. For the R package you can use `air `_ to format the code, and - - ``{lintr}`` + `jarl `_ to check if the code follows the `tidyverse style `_. - The instructions on how to use `air` and ``{lintr}`` + The instructions on how to use `air` and `jarl` can be found in the `Styling and Linting section of the Common developer workflow tasks `_. diff --git a/r/jarl.toml b/r/jarl.toml new file mode 100644 index 000000000000..f6c49b785cec --- /dev/null +++ b/r/jarl.toml @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[lint] +# exclude below files as all are generated or used for generating other files +exclude = ["R/arrowExports.R", "R/dplyr-funcs-doc.R", "data-raw/codegen.R"] diff --git a/r/vignettes/developers/workflow.Rmd b/r/vignettes/developers/workflow.Rmd index 467cedc7004c..c980f56107be 100644 --- a/r/vignettes/developers/workflow.Rmd +++ b/r/vignettes/developers/workflow.Rmd @@ -13,17 +13,18 @@ knitr::opts_chunk$set(error = TRUE, eval = FALSE) The Arrow R package uses several additional development tools: * [`air`](https://posit-dev.github.io/air/) for code styling -* [`lintr`](https://github.com/r-lib/lintr) for code analysis +* [`jarl`](https://etiennebacher.github.io/jarl/) for code analysis * [`pkgdown`](https://pkgdown.r-lib.org) for building the website * [`roxygen2`](https://roxygen2.r-lib.org) for documenting the package - the R documentation uses the [`@examplesIf`](https://roxygen2.r-lib.org/articles/rd.html#functions) tag introduced in `roxygen2` version 7.1.2 -Instructions for installing `air` can be found at . +Instructions for installing `air` can be found at , +and instructions for installing `jarl` can be found at . You can install all the other additional dependencies by running: ```r -install.packages(c("lintr", "pkgdown", "roxygen2")) +install.packages(c("pkgdown", "roxygen2")) ``` @@ -68,7 +69,7 @@ The R code in the package follows [the tidyverse style](https://style.tidyverse. You can automatically change the formatting of the code in the package using the [air](https://posit-dev.github.io/air/cli.html) formatter. -The `air` formatter will fix many styling errors, thought not all lintr errors are automatically fixable with `air`. The list of files we intentionally do not style is in the `exclude` field in `r/air.toml`. +The `air` formatter will fix many styling errors, though not all `jarl` errors are automatically fixable with `air`. The list of files we intentionally do not style is in the `exclude` field in `r/air.toml`. Linting and styling with [pre-commit](https://pre-commit.com/) as described above is the best way to ensure your changes are being checked properly but you can also run the tools individually if you prefer, from the `arrow/r` directory of the repository. @@ -78,13 +79,13 @@ From the command line, run `air`: air format ``` -In R, run `lintr`: +From the command line, run `jarl`: -```r -lintr::lint_package() +``` +jarl check . ``` -Note: To run lintr, we require the `cyclocomp` package to be installed first. +Some `jarl` findings can be fixed automatically with `jarl check --fix .`. ### C++ code From 7e8efd1d241c483836287f1151d891e2f9e77a75 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Tue, 11 Aug 2026 16:31:13 +0200 Subject: [PATCH 2/2] simplify config + for now ignore failing rules --- .pre-commit-config.yaml | 4 +--- r/jarl.toml | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4de68a739a52..3ac6897f99aa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -193,9 +193,7 @@ repos: hooks: - id: jarl-check alias: r - name: R Lint - files: >- - ^r/.*\.(R|Rmd)$ + name: R Lint (jarl) - repo: https://github.com/posit-dev/air-pre-commit rev: 0.8.2 hooks: diff --git a/r/jarl.toml b/r/jarl.toml index f6c49b785cec..585c05fcd61e 100644 --- a/r/jarl.toml +++ b/r/jarl.toml @@ -18,3 +18,23 @@ [lint] # exclude below files as all are generated or used for generating other files exclude = ["R/arrowExports.R", "R/dplyr-funcs-doc.R", "data-raw/codegen.R"] + +# TODO: these rules currently fire on existing code; re-enable incrementally +# after triaging/fixing the findings (see GH-46646). +ignore = [ + "any_is_na", + "comparison_negation", + "download_file", + "duplicated_arguments", + "equals_null", + "implicit_assignment", + "internal_function", + "numeric_leading_zero", + "outer_negation", + "redundant_equals", + "redundant_ifelse", + "repeat", + "seq", + "sprintf", + "unused_function", +]