Loading...
Loading...
Provides refactoring recommendations and step-by-step improvement plans. Use when planning refactoring, improving code structure, or reducing technical debt.
npx skill4agent add armanzeroeight/fastagent-plugins refactoring-advisor| Problem | Strategy | Risk |
|---|---|---|
| Long Method | Extract Method | Low |
| God Class | Extract Class | Medium |
| Duplicated Code | Extract Method | Low |
| Switch Statement | Replace with Polymorphism | High |
| Long Parameter List | Introduce Parameter Object | Medium |
## Refactoring: [Name]
**Problem:** [Description]
**Goal:** [Desired outcome]
**Risk Level:** [Low/Medium/High]
### Prerequisites
- [ ] Tests exist and pass
- [ ] Code is committed
- [ ] Dependencies identified
### Steps
1. [First small change]
2. [Run tests]
3. [Next small change]
4. [Run tests]
...
### Validation
- [ ] All tests pass
- [ ] No functionality changed
- [ ] Code is cleanerfunction printOwing(invoice) {
let outstanding = 0;
console.log("***********************");
console.log("**** Customer Owes ****");
console.log("***********************");
for (const o of invoice.orders) {
outstanding += o.amount;
}
console.log(`name: ${invoice.customer}`);
console.log(`amount: ${outstanding}`);
}function printOwing(invoice) {
printBanner();
const outstanding = calculateOutstanding(invoice);
printDetails(invoice, outstanding);
}
function printBanner() {
console.log("***********************");
console.log("**** Customer Owes ****");
console.log("***********************");
}
function calculateOutstanding(invoice) {
return invoice.orders.reduce((sum, o) => sum + o.amount, 0);
}
function printDetails(invoice, outstanding) {
console.log(`name: ${invoice.customer}`);
console.log(`amount: ${outstanding}`);
}class Person {
name;
officeAreaCode;
officeNumber;
getTelephoneNumber() {
return `(${this.officeAreaCode}) ${this.officeNumber}`;
}
}class TelephoneNumber {
areaCode;
number;
toString() {
return `(${this.areaCode}) ${this.number}`;
}
}
class Person {
name;
telephoneNumber;
getTelephoneNumber() {
return this.telephoneNumber.toString();
}
}