Closed Bug 1081597 Opened 10 years ago Closed 10 years ago

Unwrap confusing else statements

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 35

People

(Reporter: ckitching, Assigned: ckitching)

Details

Attachments

(1 file)

When you have something like:

if (...) {
   ...
   return;
} else {
   // Stuff
}

You can remove the Stuff out of the else branch. Such else statements seem to exist only to confuse people.
... Sometimes.

In related news, a bunch of these are crying out to be converted to switch statements, so I did that, too. (Now we have source level 7 we can switch on strings. Still compiles to the same thing but is rather nicer to read).

... Maybe useful? Prettymuch automated, anyway...
Attachment #8503704 - Flags: review?(rnewman)
Early return and no 'else' is our coding style, so yup.
Hardware: ARM → All
Comment on attachment 8503704 [details] [diff] [review]
Refactor some branches

Review of attachment 8503704 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good.

Upstream needed.

::: mobile/android/base/prompts/PromptInput.java
@@ +367,3 @@
>                  }
> +
> +                break;

Just `return null` right here and not below.
Attachment #8503704 - Flags: review?(rnewman) → review+
https://hg.mozilla.org/mozilla-central/rev/0fcf464736d7
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 35
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.