Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ jobs:
sudo apt update
sudo apt install -y -V \
pre-commit \
r-base \
ruby-dev \
libuv1-dev
- name: Cache pre-commit
uses: actions/cache@v6
with:
path: |
~/.cache/pre-commit
~/.local/share/renv/cache
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: |
Expand Down
17 changes: 4 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +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)$
name: R Lint (jarl)
- repo: https://github.com/posit-dev/air-pre-commit
rev: 0.8.2
hooks:
Expand Down
5 changes: 2 additions & 3 deletions docs/source/developers/guide/step_by_step/styling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ linters and styling of the code.
For the R package you can use
`air <https://posit-dev.github.io/air/>`_ to format the code,
and

``{lintr}``
`jarl <https://etiennebacher.github.io/jarl/>`_
to check if the code follows the
`tidyverse style <https://style.tidyverse.org/>`_.

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 <https://arrow.apache.org/docs/r/articles/developers/workflow.html#styling-and-linting>`_.

Expand Down
40 changes: 40 additions & 0 deletions r/jarl.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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"]

# 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",
]
17 changes: 9 additions & 8 deletions r/vignettes/developers/workflow.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://posit-dev.github.io/air/cli.html>.
Instructions for installing `air` can be found at <https://posit-dev.github.io/air/cli.html>,
and instructions for installing `jarl` can be found at <https://etiennebacher.github.io/jarl/#installation>.

You can install all the other additional dependencies by running:

```r
install.packages(c("lintr", "pkgdown", "roxygen2"))
install.packages(c("pkgdown", "roxygen2"))
```


Expand Down Expand Up @@ -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.

Expand All @@ -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

Expand Down
Loading