Skip to content

Commit 7c09d65

Browse files
jameslambRAMitchell
authored andcommitted
add shellcheck to pre-commit (rapidsai#54)
## Description Contributes to rapidsai/build-planning#135 Adds `shellcheck` to `pre-commit`, to catch issues like unsafe access patterns, unused variables, etc. in shell scripts. Fixes these warnings: ```text SC2046 (warning): Quote this to prevent word splitting. SC2068 (error): Double quote array expansions to avoid re-splitting elements ``` ## Checklist - [x] New or existing tests cover these changes. - [x] The documentation is up to date with these changes. - [ ] Run `./build.sh test` for local testing, see [CONTRIBUTING.md](https://github.com/rapidsai/legate-dataframe/blob/main/CONTRIBUTING.md#testing). - [x] Ensure `pre-commit` checks are passing see [CONTRIBUTING.md](https://github.com/rapidsai/legate-dataframe/blob/main/CONTRIBUTING.md#Pre-commit-hooks). Signed-off-by: James Lamb <[email protected]> Signed-off-by: Rory Mitchell <[email protected]>
1 parent 21b673d commit 7c09d65

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ repos:
3939
hooks:
4040
- id: clang-format
4141
types_or: [c, c++, cuda]
42+
- repo: https://github.com/shellcheck-py/shellcheck-py
43+
rev: v0.10.0.1
44+
hooks:
45+
- id: shellcheck
46+
args: ["--severity=warning"]
4247
- repo: https://github.com/rapidsai/pre-commit-hooks
4348
rev: v0.6.0
4449
hooks:
@@ -78,7 +83,7 @@ repos:
7883
^CHANGELOG.md$
7984
)
8085
- repo: https://github.com/rapidsai/dependency-file-generator
81-
rev: v1.17.1
86+
rev: v1.18.1
8287
hooks:
8388
- id: rapids-dependency-file-generator
8489
args: ["--clean"]

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ARGS=$*
1616

1717
# NOTE: ensure all dir changes are relative to the location of this
1818
# script, and that this script resides in the repo dir!
19-
REPODIR=$(cd $(dirname $0); pwd)
19+
REPODIR=$(cd "$(dirname "$0")"; pwd)
2020

2121
VALIDARGS="clean liblegate_dataframe legate_dataframe test -v -g -n -s --ptds -h -e"
2222
HELP="$0 [clean] [liblegate_dataframe] [legate_dataframe] [legate] [-v] [-g] [-n] [-s] [--ptds] [--cmake-args=\"<args>\"] [-h]

scripts/run-cmake-format.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Copyright (c) 2021-2024, NVIDIA CORPORATION.
3+
# Copyright (c) 2021-2025, NVIDIA CORPORATION.
44
# SPDX-License-Identifier: Apache-2.0
55

66
# This script is a wrapper for cmakelang that may be used with pre-commit. The
@@ -49,7 +49,7 @@ DEFAULT_FORMAT_FILE_LOCATIONS=(
4949
)
5050

5151
if [ -z ${RAPIDS_CMAKE_FORMAT_FILE:+PLACEHOLDER} ]; then
52-
for file_path in ${DEFAULT_FORMAT_FILE_LOCATIONS[@]}; do
52+
for file_path in "${DEFAULT_FORMAT_FILE_LOCATIONS[@]}"; do
5353
if [ -f ${file_path} ]; then
5454
RAPIDS_CMAKE_FORMAT_FILE=${file_path}
5555
break
@@ -69,12 +69,12 @@ else
6969
fi
7070

7171
if [[ $1 == "cmake-format" ]]; then
72-
cmake-format -i --config-files cmake/config.json ${RAPIDS_CMAKE_FORMAT_FILE} -- ${@:2}
72+
cmake-format -i --config-files cmake/config.json ${RAPIDS_CMAKE_FORMAT_FILE} -- "${@:2}"
7373
elif [[ $1 == "cmake-lint" ]]; then
7474
# Since the pre-commit hook is verbose, we have to be careful to only
7575
# present cmake-lint's output (which is quite verbose) if we actually
7676
# observe a failure.
77-
OUTPUT=$(cmake-lint --config-files cmake/config.json ${RAPIDS_CMAKE_FORMAT_FILE} -- ${@:2})
77+
OUTPUT=$(cmake-lint --config-files cmake/config.json ${RAPIDS_CMAKE_FORMAT_FILE} -- "${@:2}")
7878
status=$?
7979

8080
if ! [ ${status} -eq 0 ]; then

0 commit comments

Comments
 (0)