Review Criteria (Bad Smell Analysis)
Analyze each commit for these code quality issues:
Testing Patterns (refer to docs/testing.md)
- Check for AP-4 violations (mocking internal code with relative paths)
- Verify MSW usage for HTTP mocking (not direct fetch mocking)
- Verify real filesystem usage (not fs mocks)
- Check test initialization follows production flow
- Evaluate test quality and completeness
- Check for fake timers, partial mocks, implementation detail testing
- Verify proper mock cleanup (vi.clearAllMocks)
Error Handling (Bad Smell #3)
- Identify unnecessary try/catch blocks
- Flag defensive programming patterns:
- Log + return generic error
- Silent failure (return null/undefined)
- Log and re-throw without recovery
- Suggest fail-fast improvements
Interface Changes (Bad Smell #4)
- Document new/modified public interfaces
- Highlight breaking changes
- Review API design decisions
Timer and Delay Analysis (Bad Smell #5)
- Identify artificial delays in production code
- Flag useFakeTimers/advanceTimers in tests
- Flag timeout increases to pass tests
- Suggest deterministic alternatives
Dynamic Imports (Bad Smell #6)
- Flag all dynamic import() usage
- Suggest static import alternatives
- Zero tolerance unless truly justified
Database Mocking in Route Tests (Bad Smell #7)
- Flag database or internal-service mocking in apps/api route tests
- Verify real database connections are used
Test Mock Cleanup (Bad Smell #8)
- Verify vi.clearAllMocks() in beforeEach hooks
- Check for potential mock state leakage
TypeScript any Usage (Bad Smell #9)
- Flag all
any type usage
- Suggest
unknown with type narrowing
Artificial Delays in Tests (Bad Smell #10)
- Flag setTimeout, sleep, delay in tests
- Flag fake timer usage
- Suggest proper async/await patterns
Hardcoded URLs (Bad Smell #11)
- Flag hardcoded URLs and environment values
- Verify usage of env() configuration
Direct Database Operations in Tests (Bad Smell #12)
- Flag direct DB operations for test setup
- Suggest using API endpoints instead
Fallback Patterns (Bad Smell #13)
- Flag fallback/recovery logic
- Suggest fail-fast alternatives
- Verify configuration errors fail visibly
Lint/Type Suppressions (Bad Smell #14)
- Flag eslint-disable, @ts-ignore, @ts-nocheck
- Zero tolerance for suppressions
- Require fixing root cause
Bad Tests (Bad Smell #15)
- Flag tests that only verify mocks
- Flag tests that duplicate implementation
- Flag over-testing of error responses and schemas
- Flag testing UI implementation details
- Flag testing specific UI text content
Mocking Internal Code - AP-4 (Bad Smell #16)
- Flag vi.mock() of relative paths (../../ or ../)
- Flag mocking of globalThis.services.db
- Flag mocking of internal services
- Only accept mocking of third-party node_modules packages
Filesystem Mocks (Bad Smell #17)
- Flag filesystem mocking in tests
- Suggest using real filesystem with temp directories
- Note: One known exception in ip-pool.test.ts (technical debt)
Unit Tests for Internal Functions (Bad Smell #18)
- Flag test files that directly import and test internal/private functions
- Tests should only exercise public entry points (API routes, CLI commands, exported module interfaces)
- Internal logic should be covered indirectly through integration tests
- Only integration tests are acceptable — no unit tests for internal functions
Test Initialization Flow (Bad Smell #19)
- Flag tests that bypass production initialization flow
- Platform tests must use
setupPage() or equivalent production initialization
- Tests should not manually construct internal state that production code initializes differently
- Test setup should mirror how the code actually runs in production