[java:S1612] FP when arguments are swapped

Qube: Community 9.9

The Java rule S1612 produces a FP when the arguments of the lambda code are swapped.

func(str -> "true".equalsIgnoreCase(str));

str can be null. Hence I went for the swapped notation where the constant value is written first and equalsIgnoreCase() is executed on that value (that cannot be null).

S1612 wants me to use a function reference, which is necessarily executed on the nullable argument.

Btw. a function reference cannot be used here at all anyway.

Hi @mfroehlich,

I think you can write it like that: func("true"::equalsIgnoreCase). The message may be a bit confusing, so I will create a ticket to update it.

1 Like

Nice! Thanks for the heads up.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.