Inspectopedia Help

Method parameter always has the same value

Reports method parameters that always have the same constant value.

Example:

static void printPoint(int x, int y) { // x is always 0 System.out.println(x + ", " + y); } public static void main(String[] args) { printPoint(0, 1); printPoint(0, 2); }

The quick-fix inlines the constant value. This may simplify the method implementation.

Use the Ignore when a quick-fix can not be provided option to suppress the inspections when:

  • the parameter is modified inside the method

  • the parameter value that is being passed is a reference to an inaccessible field (Java ony)

  • the parameter is a vararg (Java only)

Use the Maximal method visibility option to control the maximum visibility of methods to be reported.

Use the Minimal method usage count to report parameter field to specify the minimal number of method usages with the same parameter value.

Inspection options

Option

Type

Default

Ignore when a quick-fix cannot be provided

Checkbox

true

Maximal method visibility

Dropdown

protected

Minimal method usage count to report parameter

Number

1

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023