Opposite Operator
Opened this issue · 0 comments
FMCalisto commented
Use opposite operator instead of the logic complement operator.
376 }
377 // If not, then display error dialog
378 else {
379 final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
380 me.runOnUiThread(new Runnable() {
381 public void run() {
Why is this an issue?
Use opposite operator instead of negating the whole expression with a logic complement operator. It makes code easier to read and understand.
Ex:
public boolean bar(int a, int b) {
if (!(a == b)) { // use !=
return false;
}
if (!(a < b)) { // use >=
return false;
}
return true;
}
Related code pattern
Enforces opposite operator instead of negating
Enforces the usage of the opposite operator instead of negating the whole expression with a logic complement operator.