A typical code smell known as unused function parameters refers to parameters declared in a function but not used anywhere within the function’s
body. While this might seem harmless at first glance, it can lead to confusion and potential errors in your code. Disregarding the values passed to
such parameters, the function’s behavior will be the same, but the programmer’s intention won’t be clearly expressed anymore. Therefore, removing
function parameters that are not being utilized is considered best practice.
Exceptions
The rule will not raise issues for unused parameters:
- that are annotated with
@javax.enterprise.event.Observes
- in overrides and implementation methods
- 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
- 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.