Files
noteflow/.claude/hooks/hookify.block-test-loops-conditionals.local.md
Travis Vasceannie 1ce24cdf7b feat: reorganize Claude hooks and add RAG documentation structure with error handling policies
- Moved all hookify configuration files from `.claude/` to `.claude/hooks/` subdirectory for better organization
- Added four new blocking hooks to prevent common error handling anti-patterns:
  - `block-broad-exception-handler`: Prevents catching generic `Exception` with only logging
  - `block-datetime-now-fallback`: Blocks returning `datetime.now()` as fallback on parse failures to prevent data corruption
  - `block-default
2026-01-15 15:58:06 +00:00

1.2 KiB

name, enabled, event, action, conditions
name enabled event action conditions
block-test-loops-conditionals true file block
field operator pattern
file_path regex_match tests?/.*.py$
field operator pattern
new_text regex_match def test_[^(]+([^)]*)[^:]*:[\s\S]*?\b(for|while|if)\s+[^:]+:[\s\S]*?assert

🚫 Test Quality Violation: Loops or Conditionals in Tests

Your edit contains a loop (for/while) or conditional (if) combined with assertions in a test file.

Why this is blocked:

  • Tests should be deterministic and explicit
  • Loops hide which iteration failed
  • Conditionals make test behavior unpredictable
  • This violates the project's test quality standards (see tests/quality/)

Alternatives:

  1. Use @pytest.mark.parametrize for multiple test cases:

    @pytest.mark.parametrize("input,expected", [
        ("a", 1),
        ("b", 2),
    ])
    def test_example(input, expected):
        assert process(input) == expected
    
  2. Create separate test functions for distinct scenarios

  3. Use fixtures for setup variations

Project reference: See tests/quality/ for the 23 test smell checks enforced on this codebase.