I have a use case where I need to return an implementation of Runnable
with the run
method annotated, like so:
public org.springframework.core.task.TaskDecorator myTaskDecorator () {
return runnable -> {
return new Runnable() { // S1604 flagged here
@CustomAnnotation
@Override
public void run() {
// Some logic
runnable.run();
}
}
};
}
Best I know, the new Runnable()
above cannot be turned into a lambda as S1604 wants, while still being able to annotate the run
method with @CustomAnnotation
. So, IMO, S1604 should ignore cases where the single method has annotations, other than @Override
.
Versions Used:
SonarQube Community Edition: v7.3.0
SonarJava: v5.6.1