Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Violations of Always Use Braces #4400

Merged
merged 2 commits into from
Oct 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/main/java/org/jabref/gui/edit/ReplaceStringViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntry;

public class ReplaceStringViewModel extends AbstractViewModel
{
public class ReplaceStringViewModel extends AbstractViewModel {
private boolean allFieldReplace;
private String findString;
private String replaceString;
Expand All @@ -29,8 +28,7 @@ public class ReplaceStringViewModel extends AbstractViewModel
private BooleanProperty selectOnlyProperty = new SimpleBooleanProperty();


public ReplaceStringViewModel(BasePanel basePanel)
{
public ReplaceStringViewModel(BasePanel basePanel) {
Objects.requireNonNull(basePanel);
this.panel = basePanel;
}
Expand All @@ -45,20 +43,20 @@ public int replace() {
final NamedCompound compound = new NamedCompound(Localization.lang("Replace string"));
int counter = 0;
if (selOnly) {
for (BibEntry bibEntry: this.panel.getSelectedEntries())
for (BibEntry bibEntry : this.panel.getSelectedEntries()) {
counter += replaceItem(bibEntry, compound);
}
else {
for (BibEntry bibEntry: this.panel.getDatabase().getEntries())
}
} else {
for (BibEntry bibEntry : this.panel.getDatabase().getEntries()) {
counter += replaceItem(bibEntry, compound);
}
}
return counter;
}

/**
* Does the actual operation on a Bibtex entry based on the
* settings specified in this same dialog. Returns the number of
* occurrences replaced.
* Does the actual operation on a Bibtex entry based on the settings specified in this same dialog. Returns the
* number of occurrences replaced.
*/
private int replaceItem(BibEntry entry, NamedCompound compound) {
int counter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ public AppearancePrefsTab(DialogService dialogService, JabRefPreferences prefs)
darkTheme = new RadioButton("Dark theme");
darkTheme.setToggleGroup(themeGroup);

if (prefs.get(JabRefPreferences.FX_THEME).equals(BASE_CSS))
if (prefs.get(JabRefPreferences.FX_THEME).equals(BASE_CSS)) {
lightTheme.setSelected(true);
else if (prefs.get(JabRefPreferences.FX_THEME).equals(DARK_CSS))
} else if (prefs.get(JabRefPreferences.FX_THEME).equals(DARK_CSS)) {
darkTheme.setSelected(true);

}
container.getChildren().addAll(overrideFonts, fontSizeContainer, fontTweaksLAF, lightTheme, darkTheme);

}

public Node getBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ public Object clone() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
IntegrityMessage that = (IntegrityMessage) o;
return Objects.equals(entry, that.entry) &&
Objects.equals(fieldName, that.fieldName) &&
Expand All @@ -53,5 +57,4 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(entry, fieldName, message);
}

}
11 changes: 7 additions & 4 deletions src/main/java/org/jabref/model/entry/BibtexString.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public boolean hasChanged() {
}

/*
* Returns user comments (arbitrary text before the string) if there are any. If not returns the empty string
* Returns user comments (arbitrary text before the string) if there are any. If not returns the empty string
*/
public String getUserComments() {
if (parsedSerialization != null) {
Expand Down Expand Up @@ -173,8 +173,12 @@ public String toString() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
BibtexString that = (BibtexString) o;
return hasChanged == that.hasChanged &&
Objects.equals(name, that.name) &&
Expand All @@ -188,5 +192,4 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(name, content, id, type, parsedSerialization, hasChanged);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public static Optional<MathSciNetId> parse(String mrNumberRaw) {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MathSciNetId that = (MathSciNetId) o;
return Objects.equals(identifier, that.identifier);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ public AbstractGroup deepCopy() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AutomaticKeywordGroup that = (AutomaticKeywordGroup) o;
return Objects.equals(keywordDelimiter, that.keywordDelimiter) &&
Objects.equals(field, that.field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ public AutomaticPersonsGroup(String name, GroupHierarchyType context, String fie

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AutomaticPersonsGroup that = (AutomaticPersonsGroup) o;
return Objects.equals(field, that.field);
}
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/org/jabref/model/groups/TexGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ public AbstractGroup deepCopy() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
LinusDietz marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
TexGroup group = (TexGroup) o;
return Objects.equals(filePath, group.filePath);
}
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/org/jabref/model/metadata/ContentSelectors.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void addContentSelector(ContentSelector contentSelector) {
}

public List<String> getSelectorValuesForField(String fieldName) {
for (ContentSelector selector: contentSelectors) {
for (ContentSelector selector : contentSelectors) {
if (selector.getFieldName().equals(fieldName)) {
return selector.getValues();
}
Expand All @@ -33,7 +33,7 @@ public List<String> getSelectorValuesForField(String fieldName) {
public void removeSelector(String fieldName) {
ContentSelector toRemove = null;

for (ContentSelector selector: contentSelectors) {
for (ContentSelector selector : contentSelectors) {
if (selector.getFieldName().equals(fieldName)) {
toRemove = selector;
break;
Expand Down Expand Up @@ -61,7 +61,7 @@ public static ContentSelector parse(String key, String values) {
public List<String> getFieldNamesWithSelectors() {
List<String> result = new ArrayList<>(contentSelectors.size());

for (ContentSelector selector: contentSelectors) {
for (ContentSelector selector : contentSelectors) {
result.add(selector.getFieldName());
}

Expand All @@ -70,8 +70,12 @@ public List<String> getFieldNamesWithSelectors() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ContentSelectors that = (ContentSelectors) o;
return Objects.equals(contentSelectors, that.contentSelectors);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ public static void assertEquals(List<Text> expectedTexts, TextFlow description)
}

public static boolean checkIfTextsEqualsExpectedTexts(List<Text> texts, List<Text> expectedTexts) {
if (expectedTexts.size() != texts.size())
if (expectedTexts.size() != texts.size()) {
return false;
}
Text expectedText;
for (int i = 0; i < expectedTexts.size(); i++) {
expectedText = expectedTexts.get(i);
// the strings contain not only the text but also the font and other properties
// so comparing them compares the Text object as a whole
// the equals method is not implemented...
if (!expectedText.toString().equals(texts.get(i).toString()))
if (!expectedText.toString().equals(texts.get(i).toString())) {
return false;
}
}
return true;
}
Expand Down