| 1 | #!/usr/bin/env bash |
| 2 | set -euo pipefail |
| 3 | |
| 4 | threshold="${1:-1000}" |
| 5 | |
| 6 | allowed=' |
| 7 | crates/headroom-core/src/pw/registry.rs |
| 8 | crates/headroom-gui/src/app.rs |
| 9 | crates/headroom-core/src/profile_store.rs |
| 10 | crates/headroom-cli/src/tui.rs |
| 11 | crates/headroom-core/src/ipc/ops.rs |
| 12 | crates/headroom-dsp/src/limiter.rs |
| 13 | crates/headroom-core/src/app_level.rs |
| 14 | ' |
| 15 | |
| 16 | is_allowed() { |
| 17 | local file="$1" |
| 18 | grep -qxF "$file" <<<"$allowed" |
| 19 | } |
| 20 | |
| 21 | status=0 |
| 22 | while IFS= read -r -d '' file; do |
| 23 | lines="$(wc -l <"$file")" |
| 24 | if (( lines <= threshold )); then |
| 25 | continue |
| 26 | fi |
| 27 | if is_allowed "$file"; then |
| 28 | printf 'warn: %s has %s lines allowed over %s\n' "$file" "$lines" "$threshold" |
| 29 | else |
| 30 | printf 'error: %s has %s lines over %s\n' "$file" "$lines" "$threshold" >&2 |
| 31 | status=1 |
| 32 | fi |
| 33 | done < <(find crates -type f -name '*.rs' -print0 | sort -z) |
| 34 | |
| 35 | exit "$status" |