2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2021-01-27 13:42:22 +01:00
|
|
|
Since method parameters shouldn't be updated, it makes sense that that's both communicated and enforced with the use of ``++final++``.
|
2020-12-21 15:38:52 +01:00
|
|
|
|
2021-02-02 15:02:10 +01:00
|
|
|
|
2021-01-27 13:42:22 +01:00
|
|
|
This rule raises an issue for methods with non-``++final++`` parameters.
|
2020-12-21 15:38:52 +01:00
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2020-12-21 15:38:52 +01:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,text]
|
2020-12-21 15:38:52 +01:00
|
|
|
----
|
|
|
|
public void doSomething (String a, int b) { // Noncompliant
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2020-12-21 15:38:52 +01:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,text]
|
2020-12-21 15:38:52 +01:00
|
|
|
----
|
|
|
|
public void doSomething (final String a, final int b) { // Noncompliant
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
|
2022-01-25 18:36:46 +01:00
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== Highlighting
|
2022-01-25 18:36:46 +01:00
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
Highlight each non-final parameter.
|
|
|
|
|
|
|
|
No additional messages needed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
=== Message
|
|
|
|
|
|
|
|
Make these parameters "final"
|
2022-01-25 18:36:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|