# Remove Unused Parameters in Private Methods

# Description

This rule finds and removes unused parameters in private method declarations. Consequently, all the invocations of the affected methods are updated accordingly.

# Benefits

Removes the clutter and simplifies the method declarations.

# Tags

# Code Changes

Pre

/**
 * Java doc for the affected method
 *
 * @param first  discarded parameter
 * @param second used parameter
 * @param third  discarded parameter
 */
private void discardedParameters(String first, String second, String third) {
    consume(second);
}

void invocationSample() {
    discardedParameters("first", "second", "third");
}

Post

/**
 * Java doc for the affected method
 *
 * @param second used parameter
 */
private void discardedParameters(String second) {
    consume(second);
}

void invocationSample() {
    discardedParameters("second");
}

# Limitations

The non-private methods are not modified by this rule because they could be invoked or overridden in locations that are not reachable by jSparrow.

Use a Java Refactoring Tool

No license required

You can review this refactoring on your code without a license by installing jSparrow to your Eclipse IDE. Install the plug-in from Eclipse IDE: Eclipse Marketplace.

System-wide Refactoring

Do you want to automate this refactoring (and many more) to your system-wide code? The automatic application of this system-wide refactoring can be unlocked by acquiring your jSparrow license.

a drawn cute bird pointing at a graph that shows positive results

# Properties

Property Value
Rule ID RemoveUnusedParameter
First seen in jSparrow version 3.4.0
Minimum Java version 1.1
Remediation cost 5 min
Links