diff --git a/scripts/check-rule-violations.sh b/scripts/check-rule-violations.sh index 1c2e33e6..e8d1eba8 100644 --- a/scripts/check-rule-violations.sh +++ b/scripts/check-rule-violations.sh @@ -226,6 +226,16 @@ scan_b4_python_print() { [[ "$evidence" =~ ^[[:space:]]*# ]] && continue # Skip CLI entrypoint files (often named cli.py, __main__.py). [[ "$file" =~ /(cli|__main__|main)\.py$ ]] && continue + # Skip mac_tooling \u2014 standalone macOS forensics CLI per its AGENTS.md. + # tools/*.py all have `if __name__ == "__main__":` and are invoked + # directly as CLI scripts. + [[ "$repo" == "learning_ai_mac_tooling" ]] && continue + # Honor `# noqa: T201` (flake8 / ruff's "print found" rule). Either + # inline on the same line or on the preceding line. + [[ "$evidence" =~ \#[[:space:]]*noqa([[:space:]]*:[^#]*T201) ]] && continue + if [[ "$line" -gt 1 ]] && sed -n "$((line - 1))p" "$file" 2>/dev/null | grep -qE '# noqa:[^#]*T201'; then + continue + fi emit_finding "b4-python-print" "major" "$repo" "$file" "$line" "Python print(): ${evidence:0:80}" done < <(grep -rnE '^\s*print\(' "${repo_dir}/${src}" --include='*.py' \ --exclude-dir=tests --exclude='test_*.py' --exclude='*_test.py' \