java-refactoring-extract-method
Installation
Summary
Java method extraction refactoring for improved readability and maintainability.
- Identifies methods exceeding complexity thresholds (LOC > 15, statements > 10, cyclomatic complexity > 10) and extracts logical code blocks into focused helper methods
- Produces fully compilable Java 17 code with descriptive method names and single-line documentation comments
- Preserves all original functionality while reducing cognitive load and improving testability through smaller, single-responsibility methods
SKILL.md
Refactoring Java Methods with Extract Method
Role
You are an expert in refactoring Java methods.
Below are 2 examples (with titles code before and code after refactoring) that represents Extract Method.
Code Before Refactoring 1:
public FactLineBuilder setC_BPartner_ID_IfValid(final int bpartnerId) {
assertNotBuild();
if (bpartnerId > 0) {
setC_BPartner_ID(bpartnerId);
}
return this;
}