.PHONY: check check-fmt check-test check-clippy check-lines

# Run all quality gates
check: check-fmt check-test check-clippy check-lines

check-fmt:
	cargo fmt --check

check-test:
	cargo test

check-clippy:
	cargo clippy --all-targets -- -D warnings

# Ensure no Rust source file exceeds 500 lines
check-lines:
	@exit_code=0; \
	max=500; \
	for f in src/**/*.rs src/*.rs; do \
		[ -f "$$f" ] || continue; \
		lines=$$(wc -l < "$$f"); \
		if [ "$$lines" -gt "$$max" ]; then \
			echo "FAIL: $$f has $$lines lines (max $$max)"; \
			exit_code=1; \
		fi; \
	done; \
	if [ "$$exit_code" -eq 0 ]; then \
		echo "✅ All Rust source files are under $$max lines"; \
	else \
		exit "$$exit_code"; \
	fi
