My SonarLint version: 5.3.0.36775
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
and
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.