Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
085eaae
Add Selection tab Phase 3: replacement selection functionality
gazdagergo Mar 5, 2026
80a4eb4
Add manual test plan for replacement selection (Phase 3)
gazdagergo Mar 5, 2026
6ce4687
Fix BUG-001 and BUG-002 from replacement selection testing
gazdagergo Mar 6, 2026
e425fdd
Convert replacement selection to modal overlay on Selection page
gazdagergo Mar 10, 2026
43d3492
Fix BDD test failures caused by empty SERVER_NAME and ProxyFix
gazdagergo Mar 11, 2026
897f888
Fix linting errors: reduce complexity and fix JS formatting
gazdagergo Mar 13, 2026
9f3ae50
Potential fix for pull request finding 'Empty except'
gazdagergo Mar 13, 2026
ffa9977
Fix formatting and add code quality rules documentation
gazdagergo Mar 13, 2026
881ff8c
Remove unused taskPoller Alpine component
gazdagergo Mar 13, 2026
2e0968c
Move manual test reports out of version control
gazdagergo Mar 13, 2026
24e2206
Add progress modal to design system showcase
gazdagergo Mar 11, 2026
78f6ffa
Refactor replacement_modal to use design system macros
gazdagergo Mar 13, 2026
93dd67d
Add BDD tests for replacement selection modal
gazdagergo Mar 13, 2026
d4a0887
Merge main into replacement-selection
gazdagergo Mar 13, 2026
d59c302
Fix BDD test scenarios missing number entry step
gazdagergo Mar 13, 2026
e2fd303
Fix BDD test selector for Replacements button
gazdagergo Mar 13, 2026
9d14cbc
Fix modal visibility checks in BDD tests
gazdagergo Mar 13, 2026
550dea5
Fix heading selector ambiguity in modal display test
gazdagergo Mar 13, 2026
2f5d5ae
Scope all BDD test selectors to modal element
gazdagergo Mar 13, 2026
110929d
Fix scenario testing non-existent Full Run Report after load
gazdagergo Mar 13, 2026
f833494
Fix incorrect enum value REPLACE_GSHEET -> SELECT_REPLACEMENT_GSHEET
gazdagergo Mar 13, 2026
a4d14f6
Fix flaky cancellation test and task type text assertion
gazdagergo Mar 13, 2026
d8b662b
Scope task type assertion to history table
gazdagergo Mar 13, 2026
2e7ba17
Use .first to handle multiple matching elements in history table
gazdagergo Mar 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ backend/celerybeat-schedule.db
backend/thirdparty/
# this is a place for temporary files
backend/scratchpad/
# manual test reports - visible to LLMs but not version controlled
backend/tests/manual/reports/

# this file is generated, so we will not commit it
backend/static/css/application.css
2 changes: 2 additions & 0 deletions backend/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ This requirement also means that we MUST NOT have copies of details in long term

### Agent-Specific Documentation

- [Code Quality Rules](docs/agent/code_quality_rules.md) - Exception handling, complexity, and formatting rules

When working on frontend issues, see:

- [Frontend Design System](docs/agent/frontend_design_system.md) - GOV.UK styling and build pipeline
Expand Down
100 changes: 100 additions & 0 deletions backend/docs/agent/code_quality_rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Code Quality Rules

This document collects code quality rules and patterns to follow, gathered from code review feedback and linting issues.

## Exception Handling

### Never use bare `pass` in exception handlers

**Rule:** Exception handlers should never use a bare `pass` statement. Always log the exception, even if the behavior is to silently continue.

**Why:** Bare `pass` statements make debugging difficult because there's no trace of what happened. Even when silently ignoring an exception is the correct behavior, logging at `debug` level provides observability.

**Bad:**
```python
try:
value = uuid.UUID(some_param)
except (ValueError, TypeError):
pass # No trace of what happened
```

**Good:**
```python
try:
value = uuid.UUID(some_param)
except (ValueError, TypeError):
current_app.logger.debug("Invalid UUID parameter: %r", some_param)
```

**Log levels:**
- Use `debug` for expected invalid input that's gracefully handled
- Use `warning` for unexpected but recoverable situations
- Use `error` for failures that affect functionality

## Cyclomatic Complexity

### Keep functions under complexity threshold (C901)

**Rule:** Functions should have a cyclomatic complexity of 10 or less (configured in ruff).

**Why:** High complexity makes code harder to understand, test, and maintain.

**Solutions:**
1. Extract helper functions for distinct logical blocks
2. Use early returns to reduce nesting
3. Replace complex conditionals with lookup tables or strategy patterns

**Example refactoring:**
```python
# Before: Complex function with nested conditionals
def process_data(data, option_a, option_b):
if option_a:
if data.type == "x":
# 20 lines of logic
else:
# 20 lines of logic
if option_b:
# more nested logic
# ... complexity grows

# After: Extract helper functions
def _process_type_x(data):
# focused logic

def _process_other_types(data):
# focused logic

def process_data(data, option_a, option_b):
if option_a:
if data.type == "x":
return _process_type_x(data)
return _process_other_types(data)
# cleaner main function
```

## Import Organization

### Keep imports at module level (PLC0415)

**Rule:** All `import` statements should be at the top of the file, not inside functions.

**Why:**
- Imports inside functions hide dependencies
- Makes it harder to see what a module depends on
- Can cause unexpected performance issues (import on every call)

**Exceptions:** Circular import resolution may require local imports, but these should be documented.

## Code Formatting

### Run pre-commit hooks before committing

**Rule:** Always run `just check` before committing to catch formatting issues.

**Tools configured:**
- `ruff check` - Linting (includes complexity checks)
- `ruff format` - Code formatting
- `DjHTML` - HTML template formatting
- `DjCSS` - CSS formatting
- `DjJS` - JavaScript formatting
- `mypy` - Type checking
Loading
Loading