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
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
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-methodscommand. 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
refakts sort-methods <file>to fix violationsImplementation Notes
The check should:
Example Violation
Related to