[java] S1188 should differentiate between Lambdas and anonymous classes


(Oliver Goroll) #1

The rule S1188 has only one setting for the maximum allowed lines of a lambda or an anonymous class, hence treats both constructs the same. But I don’t think they should be treated the same.
When passing a lambda to a method, I’m implementing a functional interface with a single method; further the lambda should be as short as possible, ideally a method reference.
When creating an anonymous class I can override multiple methods, sometimes I have to (e.g. implementing a MouseListener or extending a MouseAdapter). Anonymous classes should be short, too, but there is more overhead (override annotations, method signatures,…).
Therefore, the rule should allow different settings for lambdas and anonymous classes.