Unused method parameter in the base class implementation
Brought to you by:
chrismair
Ref: https://sourceforge.net/mailarchive/message.php?msg_id=28546328
For the code below, CodeNarc complains that A.foo() does not use method parameter 'x'. In the base implementation, there is no need to use 'x', but the subclasses do.
Discussion on the CodeNarc mailing list in the thread above confirmed that for the base class, the warning should not be raised. Or, there should be some way to supress the warning in such a case.
class A {
protected foo(x) {
// base implementation leaves x unused
}
}
class B extends A {
protected foo(x) {
// this overridden implementation uses x
}
}
The workaround for this issue is to specify the
@SuppressWarnings('UnusedMethodParameter')
annotation above the method declaration.
As of yet, I see no way to "fix" this problem.