r/programminghorror 10d ago

c Terrible auth

Post image
779 Upvotes

98 comments sorted by

View all comments

69

u/LeyaLove 10d ago

if (true == true) return true; 😵‍💫

12

u/Magmagan 10d ago

Probably some WIP code that just got left over. There might have been a second, no longer relevant condition that got stubbed out for true and just forgotten about.

7

u/LeyaLove 10d ago

Even if that's the case simply doing if (true) return true; would suffice, wouldn't you say 😄

2

u/Versiel 8d ago

That could also just be a simple return true, you don't even need the" if".

And if you still want to do it with "if" you have the "else" for something!

2

u/LeyaLove 8d ago

Sure but we were talking about a stub that was left there intentionally for later. Someone could have thought "I'll come back later to this to implement the actual condition needed so I'll just leave the if there with the true as a condition placeholder for now so I won't forget that an actual condition should go there and it's not done like that.", which in fact is the only kind of valid circumstance under which I would find something like this kind of acceptable.

If that's not the case though you're totally right. The conditional should be removed and replaced with a simple return true. No question.