2010-05-05

Code Findings

Found some bad code yesterday in our codebase. Will have to speak with the developer about it. Fortunately, Checkstyle caught this and failed the build due to the "SimplifyBooleanExpressionCheck".

Here's the code. Variables names have changed:
if (true == object1.isSomethingValid()) {
  object2.setSomethingValid(true);
} else {
  object2.setSomethingValid(false);
}

Obviously, the code needs to be refactored to:

object2.setSomethingValid(object1.isSomethingValid());

No comments: