blob: 186277edf40aaec227dc71850647393ccc748fad [file] [log] [blame]
# 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.
# To use this, install the python package `pre-commit` and
# run once `pre-commit install`. This will setup a git pre-commit-hook
# that is executed on each commit and will report the linting problems.
# To run all hooks on all files use `pre-commit run -a`
repos:
- repo: local
hooks:
- id: rat
name: Release Audit Tool
language: system
entry: |
bash -c " \
git archive HEAD \
--prefix=apache-arrow/ \
--output=apache-arrow.tar.gz && \
dev/release/run-rat.sh apache-arrow.tar.gz && \
rm -f apache-arrow.tar.gz"
always_run: true
pass_filenames: false
- repo: https://github.com/hadolint/hadolint
rev: v2.12.0
hooks:
- id: hadolint-docker
alias: docker
name: Docker Format
# We can enable this after we fix all existing lint failures.
# files: (/Dockerfile|\.dockerfile)$
files: >-
(
?^ci/docker/conda-python-emscripten\.dockerfile$|
?^ci/docker/python-.*-wheel-windows-test-vs2022.*\.dockerfile$|
)
types: []
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
name: C++ Format
alias: cpp
types_or:
- c++
# - json
# - proto
files: >-
^cpp/
exclude: >-
(
?\.grpc\.fb\.(cc|h)$|
?\.pb\.(cc|h)$|
?_generated.*\.(cc|h)$|
?^cpp/src/arrow/vendored/|
?^cpp/src/generated/|
?^cpp/thirdparty/|
)
- repo: https://github.com/cpplint/cpplint
rev: 1.6.1
hooks:
- id: cpplint
alias: cpp
name: C++ Lint
args:
- "--quiet"
- "--verbose=2"
types_or:
- c++
files: >-
^cpp/
exclude: >-
(
?\.grpc\.fb\.(cc|h)$|
?\.pb\.(cc|h)$|
?_generated.*\.(cc|h)$|
?^cpp/src/arrow/vendored/|
?^cpp/src/generated/|
?^cpp/thirdparty/|
)
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
alias: c-glib
name: C/GLib Format
files: >-
^c_glib/
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
name: MATLAB (C++) Format
alias: matlab-cpp-format
files: >-
^matlab/src/cpp/
- repo: https://github.com/hhatto/autopep8
rev: v2.3.2
hooks:
- id: autopep8
alias: python
name: Python Format
args:
- "--global-config"
- "python/setup.cfg"
- "--ignore-local-config"
- "--in-place"
files: >-
^(c_glib|dev|python)/
types:
- file
types_or:
- cython
- python
exclude: >-
(
?^python/pyarrow/vendored/|
)
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
alias: python
name: Python Lint
args:
- "--config"
- "python/setup.cfg"
files: >-
^(c_glib|dev|python)/
exclude: >-
(
?^python/pyarrow/vendored/|
)
- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.16.2
hooks:
- id: cython-lint
alias: python
name: Python (Cython) Lint
args:
- "--no-pycodestyle"
files: >-
^python/
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
alias: python
name: Python (C++) Format
files: >-
^python/pyarrow/src/
exclude: >-
(
?\.grpc\.fb\.(cc|h)$|
?.pb\.(cc|h)$|
?^cpp/src/generated/|
)
- repo: https://github.com/numpy/numpydoc
rev: v1.8.0
hooks:
- id: numpydoc-validation
name: Python (NumPy doc) Lint
alias: python-doc-lint
args:
- "--config=python"
files: >-
^python/pyarrow/
exclude: >-
(
?^python/pyarrow/interchange/from_dataframe\.py$|
?^python/pyarrow/jvm\.py$|
?^python/pyarrow/pandas_compat\.py$|
?^python/pyarrow/tests/|
?^python/pyarrow/util\.py$|
?^python/pyarrow/vendored/|
)
- repo: local
hooks:
- id: lintr
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: local
hooks:
- id: air-format
alias: r
name: R Format (Air)
language: system
entry: air format r --check
files: >-
^r/.*\.R$
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
alias: r
name: R (C++) Format
files: >-
^r/src/
exclude: >-
(
?^r/src/arrowExports\.cpp$|
)
- repo: https://github.com/cpplint/cpplint
rev: 1.6.1
hooks:
- id: cpplint
alias: r
name: R (C++) Lint
args:
- "--verbose=2"
types_or:
- c++
files: >-
^r/src/
exclude: >-
(
?^r/src/arrowExports\.cpp$|
)
- repo: https://github.com/rubocop/rubocop
rev: "v1.71.0"
hooks:
- id: rubocop
name: Ruby Format
alias: ruby
args:
- "--autocorrect"
exclude: >-
(
?^dev/tasks/homebrew-formulae/.*\.rb$|
?^ruby/red-arrow-format/lib/arrow-format/org/.*\.rb$|
)
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
alias: cpp
name: CMake Format
files: >-
(
?.*CMakeLists\.txt$|
?^ci/.*/.*\.cmake$|
?^cpp/.*/.*\.cmake\.in$|
?^cpp/.*/.*\.cmake$|
)
exclude: >-
(
?^ci/conan/all/.*CMakeLists\.txt$|
?^cpp/cmake_modules/FindNumPy\.cmake$|
?^cpp/cmake_modules/FindPythonLibsNew\.cmake$|
?^cpp/cmake_modules/UseCython\.cmake$|
?^cpp/src/arrow/util/.*\.h\.cmake$|
)
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v0.9.1
hooks:
- id: sphinx-lint
alias: docs
files: ^docs/source
exclude: ^docs/source/python/generated
args: [
'--enable',
'all',
'--disable',
'dangling-hyphen,line-too-long',
]
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: shellcheck
alias: shell
# TODO: Remove this when we fix all lint failures
files: >-
(
?^c_glib/test/run-test\.sh$|
?^ci/scripts/c_glib_build\.sh$|
?^ci/scripts/c_glib_test\.sh$|
?^ci/scripts/ccache_setup\.sh$|
?^ci/scripts/conan_build\.sh$|
?^ci/scripts/conan_setup\.sh$|
?^ci/scripts/cpp_test\.sh$|
?^ci/scripts/download_tz_database\.sh$|
?^ci/scripts/install_azurite\.sh$|
?^ci/scripts/install_ccache\.sh$|
?^ci/scripts/install_ceph\.sh$|
?^ci/scripts/install_chromedriver\.sh$|
?^ci/scripts/install_cmake\.sh$|
?^ci/scripts/install_conda\.sh$|
?^ci/scripts/install_dask\.sh$|
?^ci/scripts/install_emscripten\.sh$|
?^ci/scripts/install_gcs_testbench\.sh$|
?^ci/scripts/install_iwyu\.sh$|
?^ci/scripts/install_minio\.sh$|
?^ci/scripts/install_ninja\.sh$|
?^ci/scripts/install_numba\.sh$|
?^ci/scripts/install_numpy\.sh$|
?^ci/scripts/install_pandas\.sh$|
?^ci/scripts/install_python\.sh$|
?^ci/scripts/install_sccache\.sh$|
?^ci/scripts/install_spark\.sh$|
?^ci/scripts/install_vcpkg\.sh$|
?^ci/scripts/integration_arrow_build\.sh$|
?^ci/scripts/integration_arrow\.sh$|
?^ci/scripts/integration_dask\.sh$|
?^ci/scripts/integration_hdfs\.sh$|
?^ci/scripts/integration_spark\.sh$|
?^ci/scripts/matlab_build\.sh$|
?^ci/scripts/msys2_setup\.sh$|
?^ci/scripts/msys2_system_clean\.sh$|
?^ci/scripts/msys2_system_upgrade\.sh$|
?^ci/scripts/nanoarrow_build\.sh$|
?^ci/scripts/python_build_emscripten\.sh$|
?^ci/scripts/python_build\.sh$|
?^ci/scripts/python_sdist_build\.sh$|
?^ci/scripts/python_sdist_test\.sh$|
?^ci/scripts/python_wheel_unix_test\.sh$|
?^ci/scripts/r_build\.sh$|
?^ci/scripts/r_revdepcheck\.sh$|
?^ci/scripts/release_test\.sh$|
?^ci/scripts/ruby_test\.sh$|
?^ci/scripts/rust_build\.sh$|
?^ci/scripts/util_download_apache\.sh$|
?^ci/scripts/util_enable_core_dumps\.sh$|
?^ci/scripts/util_free_space\.sh$|
?^ci/scripts/util_log\.sh$|
?^cpp/build-support/build-lz4-lib\.sh$|
?^cpp/build-support/build-zstd-lib\.sh$|
?^cpp/build-support/get-upstream-commit\.sh$|
?^cpp/build-support/update-thrift\.sh$|
?^cpp/examples/minimal_build/run\.sh$|
?^cpp/examples/tutorial_examples/run\.sh$|
?^dev/release/05-binary-upload\.sh$|
?^dev/release/07-binary-verify\.sh$|
?^dev/release/binary-recover\.sh$|
?^dev/release/post-03-binary\.sh$|
?^dev/release/post-08-docs\.sh$|
?^dev/release/post-09-python\.sh$|
?^dev/release/setup-rhel-rebuilds\.sh$|
?^dev/release/utils-generate-checksum\.sh$|
?^python/asv-install\.sh$|
?^python/asv-uninstall\.sh$|
?^swift/gen-protobuffers\.sh$|
)
- repo: https://github.com/scop/pre-commit-shfmt
# v3.11.0-1 or later requires pre-commit 3.2.0 or later but Ubuntu
# 22.04 ships pre-commit 2.17.0. We can use update this rev after
# Ubuntu 22.04 reached EOL (June 2027).
rev: v3.10.0-1
hooks:
- id: shfmt
alias: shell
args:
# The default args is "--write --simplify" but we don't use
# "--simplify". Because it's conflicted will ShellCheck.
- "--write"
# TODO: Remove this when we fix all lint failures
files: >-
(
?^dev/release/05-binary-upload\.sh$|
?^dev/release/binary-recover\.sh$|
?^dev/release/post-03-binary\.sh$|
?^dev/release/post-08-docs\.sh$|
?^dev/release/post-09-python\.sh$|
)
- repo: https://github.com/trim21/pre-commit-mirror-meson
rev: v1.9.0
hooks:
- id: meson-fmt
alias: cpp
args: ['--inplace']
files: >-
(
?.*meson\.build$|
?.*meson\.options$|
)