2020-06-30 12:47:33 +02:00
include::../description.adoc[]
== Noncompliant Code Example
----
void doSomething(int a, int b) { // "b" is unused
compute(a);
}
----
== Compliant Solution
----
void doSomething(int a) {
compute(a);
}
----
== Exceptions
The rule will not raise issues for unused parameters:
2020-06-30 14:49:38 +02:00
2021-01-27 13:42:22 +01:00
* that are annotated with ``++@javax.enterprise.event.Observes++``
2020-06-30 12:47:33 +02:00
* in overrides and implementation methods
2021-01-27 13:42:22 +01:00
* in interface ``++default++`` methods
* in non-private methods that only ``++throw++`` or that have empty bodies
* in annotated methods, unless the annotation is ``++@SuppressWarning("unchecked")++`` or ``++@SuppressWarning("rawtypes")++``, in which case the annotation will be ignored
2020-06-30 12:47:33 +02:00
* in overridable methods (non-final, or not member of a final class, non-static, non-private), if the parameter is documented with a proper javadoc.
----
@Override
void doSomething(int a, int b) { // no issue reported on b
compute(a);
}
public void foo(String s) {
// designed to be extended but noop in standard case
}
protected void bar(String s) {
//open-closed principle
}
public void qix(String s) {
throw new UnsupportedOperationException("This method should be implemented in subclasses");
}
/**
* @param s This string may be use for further computation in overriding classes
*/
protected void foobar(int a, String s) { // no issue, method is overridable and unused parameter has proper javadoc
compute(a);
}
----
include::../see.adoc[]
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]