Files
nmon/scripts/lint-filesize.sh

15 lines
486 B
Bash
Executable File

#!/usr/bin/env bash
# Fails when a production Go file exceeds 600 lines (docs/MAINTAINABILITY.md).
set -euo pipefail
limit=600
fail=0
while IFS= read -r f; do
[ -f "$f" ] || continue # listed in the index but deleted in the working tree
n=$(wc -l <"$f")
if [ "$n" -gt "$limit" ]; then
echo "$f: $n lines (limit $limit): split it by concern"
fail=1
fi
done < <(git ls-files --cached --others --exclude-standard '*.go' | grep -v '_test\.go$' | grep -v '^web/')
exit $fail