S1612: Class name in method reference can be irrelevant

My SonarLint version:

This is also a reaction to this closed topic:

It’s obvious that method references are cleaner in general. But in some cases they add not only unnnecessary complexity and verbosity, but irrelevant information. In reality, class names can be long, and I don’t want to know them (compare this desire with the motivations behind the var keyword).

As an example, compare these two snippets:

copy(sourceData, d -> d.transform(), queue::put); // type of d is totally irrelevant


copy(sourceData, UncleGeorgesFancyConversionLibrarysTransformable::transform, queue::put);

Also, in your example class names are A and B, which are very short (just like nicely fitting “lorem ipsum” texts on design blueprints).

So, please rethink this rule. This is my suggestion:

IF the target class is in an other package
AND the name is longer than a predefined constant,
THEN skip the rule.

Hi Dávid,
I agree that we should not encourage longer code, so I created this ticket SONARJAVA-4098.
Thanks for your feedback,