- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Frist!
WooH!
Admin
When you move to a new town, someone has to be FRIST
Admin
Funny how the regex matches too if only one of the character is in the allowed range. The error message should be
Admin
I always wondered about how to type those uppercase digits...
Admin
I like how it only cares about one cause of fail...
Admin
Holy "Magic Button"!
Admin
This is a very LAME submission. There are prioritized error codes returned for each test. How else could it be done if not like that? Please don't touch the code in that function! You clearly have no clue what and why it does what it does. And, please, uninstall your Submit-to-WTF Visual Studio Add-In! It encourages trigger happy WTFers to submit crappy TDWTF entries...
Admin
It doesn't.
In Java (well, ok, Android...) String.matches() always tests the whole input against the regex.
Admin
TRWTF is catch (Exception e) { e.printStackTrace() }.
Should be catch (Exception e) { error = 11 }
Admin
Yawn. If this is an example of filthy and monstrous to you, I think you better get your job back at reputable $company_name and don't travel far from home ever again.
Admin
I particularly like when they use result.equalsIgnoreCase on a bunch of numbers. Gotta watch out for those uppercase 2s!
Admin
Somebody sounds like a sad panda!
Admin
(Hint: they shouldn't be. The first looks for at least zero digits somewhere, so should match any string whatsoever, while the second will match any string (including the empty string) that contains no non-digits.)
Admin
Also on empty strings. Clearly cut'n'paste-coding.
But it works, so why spend time "fixing" it?
TRWTF is quoting "password" when there is no variable actually named "password".
Admin
Admin
I have to agree. This is not particularly pretty code, but it's hardly "Oh God, what were they thinking?!" code.
Admin
Ignoring the try/catch that eats all Exceptions (they forgot to also eat all Errors!)...
Way to use R.string.dialog_title_oops for the dialog title but then proceed to put hard coded strings for all of the messages.
I agree with others commenting, this is a weak WTF. Could it stand to be improved? Certainly. WTF-worthy? imo, no.
Admin
There only needs to be one set of if/then statements...
Bah! The entire error variable is unnecessary!
Captcha: genitus. Sounds like a disease that causes genius. Shame whoever wrote this code didn't have it.
Admin
You know, the documentation for Java methods is available online.
String.matches(), Pattern.matches(), and Matcher.matches() all behave the same way and attempt to match the entire input sequence against the regular expression. So yes, depending on what flags you have set in your regular expression, ^ and $ won't do anything because they're already implicitly there.
The method you're looking for is find()...
...which is what I end up telling everyone who thinks that Java's easily-accessible regex method works the same way as most other languages' without bothering to look at the documentation.
Admin
Yeah, the method has a bit of a butter face, but I'd touch it.
Admin
Admin
So TRWTF is a language which requires you to write 8 lines of boiler-plate just to read the entirety of an input stream (be it network, file, process IO, etc)
Just give me the string and be done with it: Reader reader = new ...; String result = reader.readAllString(); (I'm sorry, that's too high-level for our high-level IO library :P ). You'd think that at least you could hook up the reader to the writer and say go and it would take care of the direct IO under the covers (looks like java.nio does this, but it's still more convoluted than it needs to be)
Admin
Admin
I like best when he makes sure to check for upper and lower case empty strings
Admin
Well, uh, I'm going to have to disagree with you there...
Here's some of the things that should get this code a firm rejection.
Admin
Maynard is writing an Android application and he used a Visual Studio plug-in to submit this to TDWTF?
Is Maynard using Visual Studio to create an Android application?
WTF.
Admin
Admin
Admin
Admin
TRWTF is VB!
Wait, what language is this again?
Admin
Admin
I agree. I would put UX as number one reason for rewrite.
Admin
After a lecture in a C class on using strupr (and the other string functions) I assigned the simple task of reading in a line and making it upper case. One student added a loop to main to walk the string and in the loop was:
switch (c) { case 'a': case 'A': c = 'A'; break; case 'b': // continue ad nauseum }
I guess now I know where that student went to work.
Admin
Wow! Coming from a Delphi background, where "LoadFromStream" methods are idiomatic and can be found on pretty much any object that could conceivably make use of them, that's incredibly ugly.
Admin
Admin
TRWTF is Welsh.
Admin
Not sure how this made thedailywtf. This is a typical sample of the majority of code out there. Sad but true.
Admin
Is it unnecessary, or is it Java?
Admin
This is android... a lot of your 'grievances' are API code.
Yes, it's a little ugly, but you're making assumptions about the writer without knowing what the problem they're trying to solve is and taking this code snippet out of context, which is TRWTF...
Admin
Funny that they go out of their way to disallow anything other than letters and digits in passwords. Certainly wouldn't want passwords to be too secure now, would we?
Hey, that gives me an idea. I think my next app I'll check if the password is the same as the user name, is the string "password" or "password1", is the user's phone number or other data included in the user record, maybe a few other truly lame passwords, and if it's none of these, reject it with an error, "Password is too secure."
Admin
I was interviewing someone recently and they were using Java to write the functions (I don't have a preference which language they use as long as it is a sane language, e.g. no brainfck). Anyway, he was writing a regex and using .matches(). So I asked a similar question (he had ".(something).", and mentioned that it matches on the whole string, so the . part would be needed). I didn't question it as python has re.search and re.match, the former being the find() and latter being matches()
Admin
Admin
OMG, the barbarians from ! have invaded my codebase.
But at least I'm earning my double miles
--Joe
Admin
But anyway, even given this quirk of String.matches(), I don't think the code does what is intended, because it allows the both the username and password to be empty strings.
Admin
Correction: I see where it prevents empty strings now. Still kind of weird. Like someone else said, why don't they check the easy things first? (Like checking the length of the password before checking what's in it.)
Admin
I wouldn't call this GOOD code; it could certainly be improved. But it appears to work and mostly do what the author intended. Sure, it could be slightly more efficient (both in implementation and execution) but really... not a WTF.
Admin
Because then the error numbers would have been in the wrong order. Duh.
Admin
So all you need to do is send your own request to the server to add a new user account.
Admin
That's what I thought, too! Where's the XML? Wooden Table anyone?
Admin
Just like any other registration form in the web... What do you think happens when you sign up for some other account in the internet? There's a request sent to the server...
And if they're using HTTPS, at least the password is transmitted securely, otherwise that would be a much bigger WTF.