23 lines
666 B
Bash
Executable File
23 lines
666 B
Bash
Executable File
#!/bin/sh
|
|
# Fails if any *.rs file under ROOT/crates has more than 500 lines.
|
|
# Files under any target/ directory are ignored. Test files count.
|
|
ROOT="${1:-.}"
|
|
max=500
|
|
|
|
# Fail closed: there is nothing to check without a crates directory.
|
|
if [ ! -d "$ROOT/crates" ]; then
|
|
echo "check-lines: $ROOT/crates is not a directory" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# -prune stops find descending into target/ trees.
|
|
find "$ROOT/crates" -type d -name target -prune -o -type f -name '*.rs' -print \
|
|
| while read -r f; do
|
|
n=$(awk 'END { print NR }' "$f")
|
|
if [ "$n" -gt "$max" ]; then
|
|
echo "check-lines: $f has $n lines (limit $max)" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
exit $?
|