I have written:
public static final int MY_GREAT_COLOR = (91 << 16) + (155 << 8) + 213 + (255 << 32);
And sonar says:
New: Squid:S2183 Severity: CRITICAL, Message: Remove this useless shift
Could anybody tell me why? Is that only the fact that there should be no calculations on literals, even if it adds to readability?
I guess 255 is your alpha channel, in that case I guess you wanted 255 << 24
.
SonarQube doesn't know your intentions, but it has a valid point, as Toby stated.
As for readability, you can also try hexa code (e.g. 0xFF5B9BD5
), many devs are used to that already. Of course, a decimal number would be totally unreadable and ugly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With