Remove Unused Parameters in Private Methods

Properties

Property Value
First seen in jSparrow version 3.4.0
Minimum Java version 1.1
Remediation cost 5 min
Links squid:S1172

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.

Requirement & Tags

Requirements

Java 1.1

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.

Automatic Application of This Rule

The automatic application of this rule is supported in the following jSparrow version: