ホーム/AI コード生成・品質/java-refactoring-remove-parameter
J

java-refactoring-remove-parameter

by @githubv
4.5(291)

Java言語で「パラメータの削除」を使用してリファクタリングを行い、メソッドシグネチャとコード構造を簡素化します。

java-refactoringremove-parametercode-smellside-toolsGitHub
インストール方法
npx skills add github/awesome-copilot --skill java-refactoring-remove-parameter
compare_arrows

Before / After 効果比較

1
使用前

Javaのメソッドシグネチャにパラメータが多すぎると、コードの可読性と保守性が低下し、呼び出しの複雑さが増します。コード構造が肥大化し、可読性が悪いです。

使用後

「パラメータの削除」リファクタリング手法を適用することで、Javaのメソッドシグネチャとコード構造を簡素化します。これにより、コードの可読性と保守性が大幅に向上し、理解コストが削減されます。

SKILL.md

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

ユーザーレビュー (0)

レビューを書く

効果
使いやすさ
ドキュメント
互換性

レビューなし

統計データ

インストール数8.5K
評価4.5 / 5.0
バージョン
更新日2026年5月17日
比較事例1 件

ユーザー評価

4.5(291)
5
23%
4
51%
3
23%
2
2%
1
0%

この Skill を評価

0.0

対応プラットフォーム

🔧Claude Code
🔧OpenClaw
🔧OpenCode
🔧Codex
🔧Gemini CLI
🔧GitHub Copilot
🔧Amp
🔧Kimi CLI

タイムライン

作成2026年3月16日
最終更新2026年5月17日