-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lint-bash.sh
executable file
·29 lines (23 loc) · 1.01 KB
/
lint-bash.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
set -euo pipefail
### NOTES
# Linters called by this script are (where possible) configured to follow Google's shell style guide:
# https://google.github.io/styleguide/shell.xml
readonly FACTORIO_ROOT="$(cd "$(dirname "${BASH_SOURCE[-1]}")" &> /dev/null && git rev-parse --show-toplevel)"
# https://github.com/mvdan/sh
find -x "$FACTORIO_ROOT" -type f -iname "*sh" \
-not -path "*/.git/*" \
-print0 \
| xargs -0 -n 1 shfmt -w -s -ln=bash -i=2 -bn -ci -sr
# https://github.com/anordal/shellharden
find -x "$FACTORIO_ROOT" -type f -iname "*sh" \
-not -path "*/.git/*" \
-print0 \
| xargs -0 -n 1 shellharden --check --replace --
# https://github.com/koalaman/shellcheck
find -x "$FACTORIO_ROOT" -type f -iname "*sh" \
-not -path "*/.git/*" \
-print0 \
| xargs -0 -n 1 shellcheck --enable=all --exclude=SC2250 --severity=style --shell=bash --external-sources --
# Exclude: https://www.shellcheck.net/wiki/SC2250
# Prefer putting braces around variable references even when not strictly required.