Coding & Refactoringlow risk

java-refactoring-remove-parameter

Refactoring using Remove Parameter in Java Language

github/awesome-copilot·skills/java-refactoring-remove-parameter/SKILL.md
90/ 100质量分

导入这个 Skill

选择你的 coding agent,复制项目级或个人级安装命令。

固定到平台收录的 commit
导入当前项目.agents/skills/java-refactoring-remove-parameter
npx skills add https://github.com/github/awesome-copilot/tree/0aaced533251f5b86c69dfbc5e55db74c4b4d1af/skills/java-refactoring-remove-parameter -a codex -y
导入个人环境~/.agents/skills/java-refactoring-remove-parameter
npx skills add https://github.com/github/awesome-copilot/tree/0aaced533251f5b86c69dfbc5e55db74c4b4d1af/skills/java-refactoring-remove-parameter -a codex -g -y
手动放置目录.agents/skills/java-refactoring-remove-parameterOfficial docs ↗
导入当前项目.claude/skills/java-refactoring-remove-parameter
npx skills add https://github.com/github/awesome-copilot/tree/0aaced533251f5b86c69dfbc5e55db74c4b4d1af/skills/java-refactoring-remove-parameter -a claude-code -y
导入个人环境~/.claude/skills/java-refactoring-remove-parameter
npx skills add https://github.com/github/awesome-copilot/tree/0aaced533251f5b86c69dfbc5e55db74c4b4d1af/skills/java-refactoring-remove-parameter -a claude-code -g -y
手动放置目录.claude/skills/java-refactoring-remove-parameterOfficial docs ↗
导入当前项目.agents/skills/java-refactoring-remove-parameter
npx skills add https://github.com/github/awesome-copilot/tree/0aaced533251f5b86c69dfbc5e55db74c4b4d1af/skills/java-refactoring-remove-parameter -a github-copilot -y
导入个人环境~/.copilot/skills/java-refactoring-remove-parameter
npx skills add https://github.com/github/awesome-copilot/tree/0aaced533251f5b86c69dfbc5e55db74c4b4d1af/skills/java-refactoring-remove-parameter -a github-copilot -g -y
手动放置目录.agents/skills/java-refactoring-remove-parameterOfficial docs ↗
导入当前项目.agents/skills/java-refactoring-remove-parameter
npx skills add https://github.com/github/awesome-copilot/tree/0aaced533251f5b86c69dfbc5e55db74c4b4d1af/skills/java-refactoring-remove-parameter -a cursor -y
导入个人环境~/.cursor/skills/java-refactoring-remove-parameter
npx skills add https://github.com/github/awesome-copilot/tree/0aaced533251f5b86c69dfbc5e55db74c4b4d1af/skills/java-refactoring-remove-parameter -a cursor -g -y
手动放置目录.agents/skills/java-refactoring-remove-parameterOfficial docs ↗
导入当前项目.agents/skills/java-refactoring-remove-parameter
npx skills add https://github.com/github/awesome-copilot/tree/0aaced533251f5b86c69dfbc5e55db74c4b4d1af/skills/java-refactoring-remove-parameter -a gemini-cli -y
导入个人环境~/.gemini/skills/java-refactoring-remove-parameter
npx skills add https://github.com/github/awesome-copilot/tree/0aaced533251f5b86c69dfbc5e55db74c4b4d1af/skills/java-refactoring-remove-parameter -a gemini-cli -g -y
Native Gemini CLIgemini skills install https://github.com/github/awesome-copilot.git --scope workspace --path skills/java-refactoring-remove-parameter
手动放置目录.agents/skills/java-refactoring-remove-parameterOfficial docs ↗
⚠ 安装命令使用开源 skills CLI。执行前请检查来源、脚本和权限。
# 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**