toUpperCase() should compare to a capitalized string

This commit is contained in:
ciufudean
2023-10-19 11:09:45 +03:00
committed by GitHub
parent 2bbb193d4e
commit 453685d6c4

View File

@ -3204,9 +3204,9 @@ Using equalsIgnoreCase() is faster than using toUpperCase/toLowerCase().equals()
<priority>3</priority>
<example>
<![CDATA[
boolean answer1 = buz.toUpperCase().equals("baz"); // should be buz.equalsIgnoreCase("baz")
boolean answer1 = buz.toUpperCase().equals("BAZ"); // should be buz.equalsIgnoreCase("BAZ")
boolean answer2 = buz.toUpperCase().equalsIgnoreCase("baz"); // another unnecessary toUpperCase()
boolean answer2 = buz.toUpperCase().equalsIgnoreCase("BAZ"); // another unnecessary toUpperCase()
]]>
</example>
</rule>