refactor: the pod failure analysis checks each container in two flat steps
Summary
The last SonarCloud issue from #459 that wasn't a false positive: PodEventMapper._analyze_failure scores a cognitive complexity of 22 against the allowed 15 (issue). #459 replaced its two getattr calls but didn't flatten it.
Changes
The waiting reasons become a module constant instead of a dict built for each container, and each container's state is read once, so the checks sit one level deep. Messages and error types stay the same, including both default messages.
Type of Change
- Bug fix (non-breaking change that fixes an issue)
- New feature (non-breaking change that adds functionality)
- Breaking change (fix or feature that would cause existing functionality to change)
- Documentation update
- Refactoring (no functional changes)
- CI/CD or tooling changes
Test Plan
- Backend unit tests pass (
cd backend && uv run pytest tests/unit) - Frontend unit tests pass (
cd frontend && npm run test) - Backend E2E tests pass (
docker compose exec -T backend sh -c 'uv sync --group test --no-dev --frozen --no-install-project --no-build && pytest tests/e2e') - Frontend E2E tests pass (
cd frontend && npm run test:e2e) - API spec and client regenerated if routes or schemas changed (
uv run python -m scripts.export_openapiin backend/, thennpm run generate:apiin frontend/), never edited by hand - Manual testing performed
Validation: complexipy measures 13 (it measured 18 before), ruff and strict mypy pass, and the 44 pod monitor unit tests pass, test_analyze_failure_variants included.
Checklist
- My code follows the project's style guidelines
- I have run
pre-commit run --all-filesand all checks pass - I have added tests that prove my fix/feature works
- I have updated documentation if needed
- My changes don't introduce new warnings
Summary by cubic
Refactors pod failure analysis so its cognitive complexity drops from 22 to 13, under SonarCloud's limit of 15. The waiting-reason mapping is now a module constant instead of a dict built per container, and each container's state is read once so the checks sit one level deep. Behavior, messages, and error types are unchanged; all 44 pod monitor unit tests pass.