I am using Eclipse v3.5.
In previous Eclipse versions i remember if i have defined a method with a parameter and didn't use it internally a warning appears, like this :
public void myMethod( int x ) {
// Didn't use x here so a warning appears at the x parameter.
}
But in v3.5 i do not see this warning. How can i enable it in Eclipse ?
Solution: If variable <variable_name> or function <function_name> is not used, it can be removed. If it is only used sometimes, you can use __attribute__((unused)) . This attribute suppresses these warnings.
You can also use @Suppress in Kotlin or @SuppressWarnings in Java. To suppress a lint warning with a comment, add a //noinspection id comment on the line before the statement with the error.
Reports the parameters that are considered unused in the following cases: The parameter is passed by value, and the value is not used anywhere or is overwritten immediately. The parameter is passed by reference, and the reference is not used anywhere or is overwritten immediately.
See
Window / Preferences / Java / Compiler / ErrorsWarnings / Unnecessary Code / Value of parameter is not used
In old versions (before Eclipse Juno?) the setting was called "Parameter is never read".
Note:
If there is a valid reason for not using a parameter (e.g. it is used via reflection), you can suppress the warning by annotating the method with
@SuppressWarnings("unused")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With