Skip to content

Commit c9e6405

Browse files
asashourlukeis
authored andcommitted
Remove unneeded 'else' (#2142)
1 parent bdabcc0 commit c9e6405

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+179
-278
lines changed

java/client/src/com/thoughtworks/selenium/condition/Condition.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,13 @@ private String simulateStringDotFormatMethod(String message, Object[] args) {
7373
}
7474
}
7575
throw new RuntimeException("String.format(..) can't be that hard to call");
76-
} else {
77-
String msg = "";
78-
msg = message;
79-
for (int i = 0; i < args.length; i++) {
80-
msg = msg + " " + args[i];
81-
}
82-
return msg;
83-
8476
}
85-
77+
String msg = "";
78+
msg = message;
79+
for (int i = 0; i < args.length; i++) {
80+
msg = msg + " " + args[i];
81+
}
82+
return msg;
8683
}
8784

8885
// drop these for var-args in another year.

java/client/src/com/thoughtworks/selenium/condition/Text.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ public Text(String expectedText, String locator) {
4949
public boolean isTrue(ConditionRunner.Context context) {
5050
if (null == locator) {
5151
return context.getSelenium().isTextPresent(expectedText);
52-
} else {
53-
return context.getSelenium().getText(locator).equalsIgnoreCase(expectedText);
5452
}
53+
return context.getSelenium().getText(locator).equalsIgnoreCase(expectedText);
5554
}
5655
}

java/client/src/com/thoughtworks/selenium/webdriven/WebDriverCommandProcessor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,9 @@ public void start(Object o) {
9595
if (driver != null) {
9696
if (maker != null) {
9797
throw new SeleniumException("You may not start more than one session at a time");
98-
} else {
99-
// The command processor was instantiated with an already started driver
100-
return;
10198
}
99+
// The command processor was instantiated with an already started driver
100+
return;
102101
}
103102

104103
driver = maker.get();

java/client/src/com/thoughtworks/selenium/webdriven/commands/CaptureScreenshotToString.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ protected String handleSeleneseCommand(WebDriver driver, String locator, String
3030
if (driver instanceof TakesScreenshot) {
3131
TakesScreenshot tsDriver = (TakesScreenshot) driver;
3232
return tsDriver.getScreenshotAs(OutputType.BASE64);
33-
} else {
34-
throw new UnsupportedOperationException("WebDriver does not implement TakeScreenshot");
3533
}
34+
throw new UnsupportedOperationException("WebDriver does not implement TakeScreenshot");
3635
}
3736
}

java/client/src/com/thoughtworks/selenium/webdriven/commands/GetValue.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ protected String handleSeleneseCommand(WebDriver driver, String locator, String
4242
{
4343
if (element.getAttribute("checked") == null) {
4444
return "off";
45-
} else {
46-
return "on";
4745
}
46+
return "on";
4847
}
4948

5049
return element.getAttribute("value");

java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,10 @@ private static final CommandExecutor createCommandExecutor(Capabilities desiredC
228228
Object marionette = desiredCapabilities.getCapability(MARIONETTE);
229229
if (marionette instanceof Boolean && !(Boolean) marionette) {
230230
return new LazyCommandExecutor(binary, profile);
231-
} else {
232-
GeckoDriverService.Builder builder = new GeckoDriverService.Builder();
233-
builder.usingPort(0);
234-
return new DriverCommandExecutor(builder.build());
235231
}
232+
GeckoDriverService.Builder builder = new GeckoDriverService.Builder();
233+
builder.usingPort(0);
234+
return new DriverCommandExecutor(builder.build());
236235
}
237236

238237
@Override

java/client/src/org/openqa/selenium/firefox/Preferences.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,8 @@ public void writeTo(Writer writer) throws IOException {
181181
private String valueAsPreference(Object value) {
182182
if (value instanceof String) {
183183
return "\"" + escapeValueAsPreference((String) value) + "\"";
184-
} else {
185-
return escapeValueAsPreference(String.valueOf(value));
186184
}
187-
185+
return escapeValueAsPreference(String.valueOf(value));
188186
}
189187

190188
private String escapeValueAsPreference(String value) {

java/client/src/org/openqa/selenium/lift/Finders.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,8 @@ public Collection<WebElement> findFrom(WebDriver context) {
133133
Iterator<WebElement> iter = collection.iterator();
134134
iter.hasNext();
135135
return Collections.singletonList(iter.next());
136-
} else {
137-
return collection;
138136
}
137+
return collection;
139138
}
140139

141140
@Override

java/client/src/org/openqa/selenium/lift/find/BaseFinder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ public Collection<S> findFrom(T context) {
3939

4040
if (matchers.isEmpty()) {
4141
return found;
42-
} else {
43-
return allMatching(matchers, found);
4442
}
43+
return allMatching(matchers, found);
4544
}
4645

4746
public Finder<S, T> with(Matcher<S> matcher) {

java/client/src/org/openqa/selenium/os/ProcessUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ private static int waitForProcessDeath(Process p, long timeout) {
7979
public static int killProcess(Process process) {
8080
if (thisIsWindows()) {
8181
return killWinProcess(process);
82-
} else {
83-
return killUnixProcess(process);
8482
}
83+
return killUnixProcess(process);
8584
}
8685

8786
private static int killUnixProcess(Process process) {

0 commit comments

Comments
 (0)