Sonar smells Java code wrongly for String concatenation

String text = “Hello” + “World”;

Sonar smells the above line. However, Java compiler converts this to (new StringBuilder()).append(“Hello”).append(“World”).toString();
I agree with you if we are placing the code in for loop. But in this case, it should not throw any alarm.

Can you please verify this.

Hello @Pavan

I’m not sure to understand, the code you provided does not raise any issue on my side.

Are you sure you did not oversimplified the example?