#!/bin/sh # Mechanical checks for the Modified Allman style (code_style_guide.md). # Only rules grep can verify without false positives are enforced here — # brace placement and paren spacing stay a review concern. Run via # `make stylecheck`; CI runs it on every push. set -u fail=0 files=$( find src examples tests benches -name '*.rs' ) # 1. Tabs for indentation: no source line may start with a space. hits=$( grep -nE '^ ' $files /dev/null ) if [ -n "$hits" ] then printf '%s\n' "$hits" echo "style: space indentation found — this tree indents with tabs" fail=1 fi # 2. Spaces inside attribute brackets: #[ derive( Clone ) ], #[ test ], # #![ deny( … ) ]. Comment lines are skipped so prose may mention raw # attribute syntax like `#[doc(hidden)]`. hits=$( grep -nE '#!?\[[a-zA-Z_]' $files /dev/null | grep -vE '^[^:]+:[0-9]+:[[:space:]]*(///|//!|//)' ) if [ -n "$hits" ] then printf '%s\n' "$hits" echo "style: unspaced attribute brackets — write #[ derive( … ) ], #[ test ]" fail=1 fi exit $fail