Recommend new name for java:S5411

Rule java:S5411 (SonarSource Code Analyzers Rules Explorer) has the name ‘Boxed “Boolean” should be avoided in boolean expressions’ but this is misleading. The Compliant Solution still uses a Boolean within a boolean expression, but does so SAFELY by “converting” it to a boolean by wrapping it in a call to Boolean.TRUE.equals().

So I think a better name would be something like ‘Boxed “Boolean” should not be directly used where a primitive boolean expression is expected’ – the example has “if” which “expects” a primitve boolean expression.

And the specific message for each issue is “Use the primitive boolean expression here” – I’m nitpicking but I’d change ‘the’ to ‘a’.

Hello Mister Pi,

Thanks for the feedback. I agree with you, there is something we can do here to make it a bit clearer and well-worded. I have created a ticket to update the rule.

1 Like

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