2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
Specifying the default parameter values in a method call is redundant. Such values should be omitted in the interests of readability.
|
2020-06-30 12:48:39 +02:00
|
|
|
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== Noncompliant code example
|
|
|
|
|
|
|
|
[source,text]
|
|
|
|
----
|
|
|
|
public void M(int x, int y=5, int z = 7) { /* ... */ }
|
|
|
|
|
|
|
|
// ...
|
|
|
|
M(1, 5); //Noncompliant, y has the default value
|
|
|
|
M(1, z: 7); //Noncompliant, z has the default value
|
|
|
|
----
|
|
|
|
|
|
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
|
|
|
|
[source,text]
|
|
|
|
----
|
|
|
|
public void M(int x, int y=5, int z = 7) { /* ... */ }
|
|
|
|
|
|
|
|
// ...
|
|
|
|
M(1);
|
|
|
|
M(1);
|
|
|
|
----
|
|
|
|
|