bisq-network / bisq-network/style

Do not use `else if` and `else` clauses where `return` statements make them redundant

Open
#12 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
2
Forks
2
PR merge metrics
No merged PRs in 30d

Description

For example, in the following code, the `else if` and `else` clauses are redundant:

```java
if (someCondition) {
return X;
} else if (otherCondition) {
return Y;
} else {
return Z;
}
```

This code can and should be simplified to read as follows:

```java
if (someCondition)
return X;

if (otherCondition)
return Y;

return Z;
```

Whether or not braces are used for single-line conditionals is a matter for a different style rule, but in any case, the second code block is easier to read, uses fewer conditional constructs, and makes it all the more obvious that returning "Z" is the fallback / default case if no preceding conditionals are matched.

Contributor guide

No contributing guide indexed for this repository

Research direction

No file or test is named in the issue. Start by locating the repository's Java style-guide entry point and compare its existing rules with the proposed redundant-else example; it is done when the convention is documented consistently and the example is represented in the appropriate guide.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.