Catalog
github/java-refactoring-remove-parameter

github

java-refactoring-remove-parameter

Refactoring using Remove Parameter in Java Language

v1.0Latest
New~722Updated Jun 26, 2026

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:

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:

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:

NodeImpl( long id, long firstRel, long firstProp )
{
     this( id, false );
}

Code After Refactoring 2:

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

Files1
1 files · 1.0 KB

Select a file to preview

Overall Score

86/100

Grade

A

Excellent

Safety

92

Quality

87

Clarity

85

Completeness

78

Summary

This skill guides an AI agent to refactor Java methods using the "Remove Parameter" technique. It provides two detailed examples showing before/after code patterns and instructs the agent to identify and eliminate unused or redundant parameters while maintaining method functionality and generating compilable Java 17 code.

Detected Capabilities

code analysispattern matchingjava code generationmethod signature transformationread-only file analysis

Trigger Keywords

Phrases that MCP clients use to match this skill to user intent.

remove unused parametersjava refactoringclean method signatureseliminate dead parameterssimplify java methods

Use Cases

  • Refactor Java methods to remove unused parameters and improve code clarity
  • Enhance method maintainability by eliminating redundant parameter passing
  • Increase code testability by reducing method complexity through parameter removal
  • Improve API consistency by standardizing method signatures across a codebase
  • Analyze legacy Java code to identify and eliminate dead parameters

Quality Notes

  • Skill provides two concrete, well-documented examples that clearly illustrate the Remove Parameter refactoring pattern
  • Instructions are methodical and break the task into logical intermediate steps (analyze → identify → remove → validate)
  • Specifies output requirements clearly: single code block, Java 17, compilable, with inline comments explaining changes
  • Explicitly preserves functionality ('do not remove any functionality'), preventing overly aggressive refactoring
  • No file system writes, no shell execution, no external dependencies — pure code analysis and generation
  • Examples use realistic production-quality Java code (exception handling, method chaining), lending credibility
  • Task is well-scoped to a single refactoring pattern, reducing cognitive load and errors
Model: claude-haiku-4-5-20251001Analyzed: Jun 26, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Use github/java-refactoring-remove-parameter in your dev environment

Command Palette

Search for a command to run...

github/java-refactoring-remove-parameter | SkillRepo