Briefly, String's toUpperCase() and toLowerCase()
methods with no arguments should be flagged as dumb
methods. They cause particular problems for Java
programs running in Turkish locales because in Turkish
i is not the lower case form of I and vice versa. See
http://www.sys-con.com/story/?storyid=46241&DE=1 for
details. Normally one should use toUpperCase(Locale.EN)
and toLowerCase(Locale.EN) instead.
1 Exception:
toHexString().toUpperCase()/toLowerCase because hex
strings never contain the letters i/I.
I looked at the code for DumbMethods.java to see if I
could add this myself, but it wasn't immediately
obvious how to do that. This is probably low-hanging
fruit for someone who knows the FindBugs code though.
Logged In: YES
user_id=66596
The problem of course is, there are zillions of calls that don't
use the parameterized one. Often toLowerCase/toUpperCase
are not used for graphical reasons, but to circumvent String's
case sensitivity with regard to map keys, et. al. In this case,
it probably isn't a problem. I think this would produce a ton of
false positives. Just a guess, tho.
Logged In: YES
user_id=226817
No, it's exactly the opposite. These zillions of calls where
toLowercase/toUppercase are not used for graphical reasons,
but to circumvent String's case sensitivity with regard to
map keys, et. al. are exactly what breaks in Turkish
locales. toUpperCase()/toLowerCase() with no specified
locale should only be used for graphical display to the
user. Even then, this only works if the text has been
localized to the user's locale. English text displayed in a
Turkish locale should use toLowerCase(Locale.EN) instead of
the no-args version. And pretty much all cases not involving
display to the end user should use toLowerCase(Locale.EN)
instead of the no-args version (unless for some reason the
variables are in French, or Turkish or some such language,
in which case they should use Locale.FR, etc. but they still
shouldn't use the no-args version). The no-args version is
almost always wrong.
Logged In: YES
user_id=66596
Well, it's easy enough to put in. I can do that, and I guess
Dave and Bill can decide whether it will give too much pain.
Perhaps reporting at LOW_PRIORITY would be ok, dunno.
Logged In: YES
user_id=66596
added
Can I ask what version this is in? Is that the purpose of "Group" to the left? Sorry I do not understand this tracker...
This coding "technique" bites Hibernate a lot and I wanted to have this check. I just tried 3.0.1 using the Gradle plugin because http://findbugs.sourceforge.net/bugDescriptions.html says this check should be part of 3.0.1. But I do not get this reported.