Refactor
Improve code structure without changing behavior.
Constraints
| Rule | Limit |
|---|---|
| Function length | < 40 lines |
| Cyclomatic complexity | < 10 |
| Nesting depth | < 4 levels |
Actions
- Break large functions into small, pure functions
- Add type annotations (no
Any, nointerface{}) - Rename variables descriptively (no
x,data,temp) - Extract magic numbers to constants
- Use modern language idioms (Python 3.12+, Go 1.22+, ESNext)
Output
Full refactored code only. No explanations.
For significant changes, add a comment header:
# Refactored:
# - Extracted validation logic
# - Added type hints
# - Renamed variables
