aboutsummaryrefslogtreecommitdiff
path: root/scripts/check-line-length.bash
blob: 20f66d92f76d4acad602ad0937ca2cbb29eff29e (plain)
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
30
31
#!/usr/bin/env bash

set -e
set -o pipefail

find=(
    find .
    -name .git -prune -o
    -name .log -prune -o
    -path ./scripts/pnp-bin.js -prune -o
    -path ./test/formatters -prune -o
    -path ./test/unit -prune -o
    -path ./vendor -prune -o
    -name "*.elc" -o
    -type f -print
)

readarray -t files < <("${find[@]}" | sed 's#./##' | sort)

code="$(cat <<"EOF"

(length($0) >= 80 && $0 !~ /https?:\/\//) \
{ printf "%s:%d: %s\n", FILENAME, NR, $0 }

EOF
)"

for file in "${files[@]}"; do
    echo "[longlines] $file" >&2
    awk "$code" "$file"
done | (! grep .)