-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
Quality ChecksTasks that add to post-commit quality check systemTasks that add to post-commit quality check system
Description
Problem
Files that don't follow the step down rule are harder to read and maintain. The step down rule states that high-level functions should appear first, followed by lower-level private functions they call.
This is a follow-up to #46 which implements the sort-methods command. This issue focuses specifically on the quality check component.
Solution
Add a quality check that warns when files violate the step down rule by having functions that call other functions defined later in the file.
Acceptance Criteria
- Quality check detects step down rule violations using topological analysis
- Check identifies functions that call other functions defined later in the same file
- Violations include location information for the calling function
- Quality check suggests running
refakts sort-methods <file>to fix violations - Check handles recursive function calls appropriately (entry points should be first)
- Integration with existing quality system (baseline support, etc.)
Implementation Notes
The check should:
- Analyze call relationships within each file to build a dependency graph
- Detect violations where functions call other functions defined later
- Handle edge cases like recursive calls and mutual recursion
- Provide actionable feedback with specific function locations and suggested fix
Example Violation
// ❌ BAD: violates step down rule
function helper() {
return "processed";
}
function main() {
return helper(); // calls function defined above
}// ✅ GOOD: follows step down rule
function main() {
return helper(); // calls function defined below
}
function helper() {
return "processed";
}Related to
Metadata
Metadata
Assignees
Labels
Quality ChecksTasks that add to post-commit quality check systemTasks that add to post-commit quality check system