
Java Refactoring Remove Parameter
Apply the Remove Parameter refactoring to Java methods when a flag or argument is redundant after simplifying call paths.
Overview
Java Refactoring Remove Parameter is an agent skill for the Build phase that guides Remove Parameter refactors on Java methods using documented before-and-after examples.
Install
npx skills add https://github.com/github/awesome-copilot --skill java-refactoring-remove-parameterWhat is this skill?
- Teaches Remove Parameter with two titled before/after Java examples in the skill body
- Shows eliminating boolean cloud flags by folding behavior into context or internal selection
- Positions the agent as an expert Java refactoring partner for signature cleanup
- Illustrates master versus non-master code paths where parameters only existed for branching
- Pattern-focused: compare full method bodies pre- and post-refactor for safe renames
- 2 before/after refactoring examples in the skill documentation
Adoption & trust: 8.6k installs on skills.sh; 34.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
A Java method signature carries a parameter that every caller passes redundantly or that only served obsolete branching.
Who is it for?
Indie SaaS or data-plane Java codebases cleaning up boolean or context-duplicating arguments after a behavior change.
Skip if: Greenfield projects with no legacy callers, or languages other than Java—use language-specific refactor skills instead.
When should I use this skill?
You are refactoring Java methods and need to remove a parameter safely using the Remove Parameter pattern.
What do I get? / Deliverables
Call sites and method bodies are updated to drop the parameter while preserving behavior, following the skill’s exemplar transformations.
- Refactored Java methods with removed parameters
- Updated call sites consistent with skill exemplars
Recommended Skills
Journey fit
Backend build work is where Java service methods accrue parameters; this skill targets that editing context. Remove Parameter is a classic backend refactor affecting signatures, callers, and overloads—not frontend or docs tasks.
How it compares
Narrow refactor recipe with examples—not a general Java linter or automated IDE refactor across the whole repo.
Common Questions / FAQ
Who is java-refactoring-remove-parameter for?
Solo builders and backend developers editing Java services who want agent-guided Remove Parameter refactors aligned to real code patterns.
When should I use java-refactoring-remove-parameter?
During Build when simplifying method APIs; during Ship review when pruning dead parameters before merge; sparingly in Operate when hotfixing signature debt in legacy modules.
Is java-refactoring-remove-parameter safe to install?
It only instructs refactoring patterns—verify compilations and tests locally and review the Security Audits panel on this Prism page.
SKILL.md
READMESKILL.md - Java Refactoring Remove Parameter
# Refactoring Java Methods with Remove Parameter ## Role You are an expert in refactoring Java methods. Below are **2 examples** (with titles code before and code after refactoring) that represents **Remove Parameter**. ## Code Before Refactoring 1: ```java public Backend selectBackendForGroupCommit(long tableId, ConnectContext context, boolean isCloud) throws LoadException, DdlException { if (!Env.getCurrentEnv().isMaster()) { try { long backendId = new MasterOpExecutor(context) .getGroupCommitLoadBeId(tableId, context.getCloudCluster(), isCloud); return Env.getCurrentSystemInfo().getBackend(backendId); } catch (Exception e) { throw new LoadException(e.getMessage()); } } else { return Env.getCurrentSystemInfo() .getBackend(selectBackendForGroupCommitInternal(tableId, context.getCloudCluster(), isCloud)); } } ``` ## Code After Refactoring 1: ```java public Backend selectBackendForGroupCommit(long tableId, ConnectContext context) throws LoadException, DdlException { if (!Env.getCurrentEnv().isMaster()) { try { long backendId = new MasterOpExecutor(context) .getGroupCommitLoadBeId(tableId, context.getCloudCluster()); return Env.getCurrentSystemInfo().getBackend(backendId); } catch (Exception e) { throw new LoadException(e.getMessage()); } } else { return Env.getCurrentSystemInfo() .getBackend(selectBackendForGroupCommitInternal(tableId, context.getCloudCluster())); } } ``` ## Code Before Refactoring 2: ```java NodeImpl( long id, long firstRel, long firstProp ) { this( id, false ); } ``` ## Code After Refactoring 2: ```java NodeImpl( long id) { this( id, false ); } ``` ## Task Apply **Remove Parameter** to improve readability, testability, maintainability, reusability, modularity, cohesion, low coupling, and consistency. Always return a complete and compilable method (Java 17). Perform intermediate steps internally: - First, analyze each method and identify parameters that are unused or redundant (i.e., values that can be obtained from class fields, constants, or other method calls). - For each qualifying method, remove the unnecessary parameters from its definition and from all its internal calls. - Ensure that the method continues to function correctly after parameter removal. - Output only the refactored code inside a single ```java``` block. - Do not remove any functionality from the original method. - Include a one-line comment above each modified method indicating which parameter was removed and why. ## Code to be Refactored: Now, assess all methods with unused parameters and refactor them using **Remove Parameter**