# Known anti-patterns and recommended remediation (Phase 1 findings) anti_patterns: - id: broad_except_swallows_errors description: "Wide except: clauses that swallow exceptions without logging or re-raising." examples: - path: multiple note: "Observed in various pipeline and ingestion spots where except Exception: returns a default without context." remediation: - "Replace broad except with specific exceptions." - "When broad except is absolutely needed, call logger.exception(...) and re-raise or convert to a typed domain error." - "Add unit tests to ensure critical errors are visible in CI logs." - id: mixed_print_and_logging description: "Mixing print() and logging() for errors and info messages." examples: - path: api_client.py excerpt: | ```python print(f"Fetched {len(voting_records)} voting records from API") ... except Exception as e: print(f"Error fetching motions from API: {e}") ``` remediation: - "Use logging.getLogger(__name__) and logger.info/warning/exception consistently." - "Add a top-level logging configuration for Streamlit and scripts." - id: no_lockfile description: "No lockfile present -> unreproducible installs and CI unpredictability." remediation: - "Add a lockfile (poetry.lock, requirements.txt produced by pip-tools) and pin versions in CI." - "Make CI use the lockfile for reproducible builds." - id: declared_but_unused_dependency description: "Dependency declared but unused (openai in pyproject)." remediation: - "Either remove the dependency or add clear adapter code/tests that exercise it. Keep pyproject tidy." - id: brittle_identity_heuristics description: "Heuristics for MP identity (comma-based parsing) are brittle." remediation: - "Add robust parsing rules and unit tests; prefer canonical identifiers (persoon_id) where available."