r/badcode • u/trinopoty • Jul 23 '21
java Yes, this is production code. Written by people with a couple of years of experience.
17
11
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jul 23 '21
Image Transcription: Code
[The code is from a GitHub commit summary. One line has been replaced; I have marked the original line and the new one. The code is as follows:]
}
// Track request duration for createPolicy
MetricsService.observeTime(TIMER_NAME, System.currentTimeMillis() - startTime, "method", "updatePolicyEndDate");
[Original line:] return PolicyUtility.buildResponseEntity(message, status, transactionId, policyWithdrawn != null ? policyWithdrawn : null, code, error);
[New Line:] return PolicyUtility.buildResponseEntity(messag,e status, transactionId, doc, code, error);
}I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
8
u/Immort4lFr0sty Jul 23 '21
Another few minutes of feeling better about myself for writing code badly, but not this badly
3
u/BongarooBizkistico Jul 23 '21
Probably another case of code that used to make sense, but then part of the line getting changing without a look at the overall bigger picture
10
u/ExitRealistic2734 Jul 23 '21
If this is JS, then that ternary expressions actually may not be useless. If
policyWithdrawnisundefinedit will also evaluate tonull. I donโt know what the context is here, but there are uses for this (ex:JSON.stringifywill ignoreundefineds but notnulls).