22

Today at work I found this in the code...

if (argCount < 2 && argCount > 3) {
// log invalid arg count
return;
}

And this passed code inspection and has been sitting there unnoticed for about a year and a half... 😂

Whether it's mixing up and with or, or forgetting a semicolon, we've all done it at some point! 😊

Comments
  • 2
    if its not broken, dont fix it... haha it's a trap
  • 2
    Or, just throwing this out there, he was <i>really</i> concerned about a number that is somehow simultaneously less than 2 but greater than 3...
  • 0
    Maybe it's a multi threaded environment, and the ArgsBuilder thread keeps changing the shared argsList counter.
  • 0
    So code simply accepts 2 or max 3 arguments.
  • 1
    @dhruv notice the &&...

    Even the obvious sections should be tested, apparently
  • 0
    @andersoyvind you are right. Just noticed them.
Add Comment