atagen

headroom

public
Star0
Watch0
b449da897c0f60535a8e41ffe85840dfb5020c58
1
ssh://brewery@pls.lobotomise.me:33/atagen/headroom.git

Blame: scripts/check-rust-file-sizes.sh

b449da897c0fatagen2026-05-27 15:49 UTC1
#!/usr/bin/env bash
b449da897c0fatagen2026-05-27 15:49 UTC2
set -euo pipefail
b449da897c0fatagen2026-05-27 15:49 UTC3
b449da897c0fatagen2026-05-27 15:49 UTC4
threshold="${1:-1000}"
b449da897c0fatagen2026-05-27 15:49 UTC5
b449da897c0fatagen2026-05-27 15:49 UTC6
allowed='
b449da897c0fatagen2026-05-27 15:49 UTC7
crates/headroom-core/src/pw/registry.rs
b449da897c0fatagen2026-05-27 15:49 UTC8
crates/headroom-gui/src/app.rs
b449da897c0fatagen2026-05-27 15:49 UTC9
crates/headroom-core/src/profile_store.rs
b449da897c0fatagen2026-05-27 15:49 UTC10
crates/headroom-cli/src/tui.rs
b449da897c0fatagen2026-05-27 15:49 UTC11
crates/headroom-core/src/ipc/ops.rs
b449da897c0fatagen2026-05-27 15:49 UTC12
crates/headroom-dsp/src/limiter.rs
b449da897c0fatagen2026-05-27 15:49 UTC13
crates/headroom-core/src/app_level.rs
b449da897c0fatagen2026-05-27 15:49 UTC14
'
b449da897c0fatagen2026-05-27 15:49 UTC15
b449da897c0fatagen2026-05-27 15:49 UTC16
is_allowed() {
b449da897c0fatagen2026-05-27 15:49 UTC17
  local file="$1"
b449da897c0fatagen2026-05-27 15:49 UTC18
  grep -qxF "$file" <<<"$allowed"
b449da897c0fatagen2026-05-27 15:49 UTC19
}
b449da897c0fatagen2026-05-27 15:49 UTC20
b449da897c0fatagen2026-05-27 15:49 UTC21
status=0
b449da897c0fatagen2026-05-27 15:49 UTC22
while IFS= read -r -d '' file; do
b449da897c0fatagen2026-05-27 15:49 UTC23
  lines="$(wc -l <"$file")"
b449da897c0fatagen2026-05-27 15:49 UTC24
  if (( lines <= threshold )); then
b449da897c0fatagen2026-05-27 15:49 UTC25
    continue
b449da897c0fatagen2026-05-27 15:49 UTC26
  fi
b449da897c0fatagen2026-05-27 15:49 UTC27
  if is_allowed "$file"; then
b449da897c0fatagen2026-05-27 15:49 UTC28
    printf 'warn: %s has %s lines allowed over %s\n' "$file" "$lines" "$threshold"
b449da897c0fatagen2026-05-27 15:49 UTC29
  else
b449da897c0fatagen2026-05-27 15:49 UTC30
    printf 'error: %s has %s lines over %s\n' "$file" "$lines" "$threshold" >&2
b449da897c0fatagen2026-05-27 15:49 UTC31
    status=1
b449da897c0fatagen2026-05-27 15:49 UTC32
  fi
b449da897c0fatagen2026-05-27 15:49 UTC33
done < <(find crates -type f -name '*.rs' -print0 | sort -z)
b449da897c0fatagen2026-05-27 15:49 UTC34
b449da897c0fatagen2026-05-27 15:49 UTC35
exit "$status"