From 54cf9fc5fe6eb9af3cec61e087910836a9a3f7ed Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 8 Oct 2019 13:08:01 +0200 Subject: [PATCH] fixed PMD warnings --- .../ethz/seb/sebserver/gbl/api/ProxyData.java | 2 +- .../sebserver/gbl/model/user/UserInfo.java | 5 ---- .../gui/content/InstitutionList.java | 1 - .../sebserver/gui/content/LmsSetupForm.java | 2 -- .../gui/content/activity/ActivitiesPane.java | 2 +- .../impl/CellFieldBuilderAdapter.java | 1 + .../examconfig/impl/TextFieldBuilder.java | 1 + .../service/page/impl/DefaultPageLayout.java | 2 +- .../service/page/impl/PageServiceImpl.java | 3 +- .../seb/sebserver/gui/table/EntityTable.java | 8 ++--- .../seb/sebserver/gui/widget/GridTable.java | 30 +++++++++---------- .../servicelayer/PaginationServiceImpl.java | 1 + .../authorization/impl/SEBServerUser.java | 5 ---- 13 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/api/ProxyData.java b/src/main/java/ch/ethz/seb/sebserver/gbl/api/ProxyData.java index c935bf66..f4ed9c55 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/api/ProxyData.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/api/ProxyData.java @@ -29,7 +29,7 @@ public class ProxyData { final int proxyPort, final CharSequence proxyAuthUsername, final CharSequence proxyAuthSecret) { - ; + this.proxyAuthType = proxyAuthType; this.proxyName = proxyName; this.proxyPort = proxyPort; diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/user/UserInfo.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/user/UserInfo.java index d8020861..d7672c62 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/user/UserInfo.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/user/UserInfo.java @@ -220,11 +220,6 @@ public final class UserInfo implements UserAccount, Activatable, Serializable { return new EntityKey(this.uuid, entityType()); } - @Override - public Object clone() throws CloneNotSupportedException { - return UserInfo.of(this); - } - @Override public int hashCode() { final int prime = 31; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/InstitutionList.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/InstitutionList.java index 9d7cd82f..f9b86e75 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/InstitutionList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/InstitutionList.java @@ -121,7 +121,6 @@ public class InstitutionList implements TemplateComposer { .newAction(ActionDefinition.INSTITUTION_MODIFY_FROM_LIST) .withSelect(table::getSelection, PageAction::applySingleSelection, EMPTY_SELECTION_TEXT_KEY) .publishIf(() -> instGrant.m() && table.hasAnyContent()); - ; } } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java index c3ad574b..6cfd01b4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java @@ -215,8 +215,6 @@ public class LmsSetupForm implements TemplateComposer { ? restService.getRestCall(NewLmsSetup.class) : restService.getRestCall(SaveLmsSetup.class)); - ; - // propagate content actions to action-pane this.pageService.pageActionBuilder(formContext.clearEntityKeys()) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java index 40f0d4bd..66c2b884 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java @@ -468,7 +468,7 @@ public class ActivitiesPane implements TemplateComposer { } for (final TreeItem item : items) { - if (item == currentSelection) { + if (item.equals(currentSelection)) { return true; } } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CellFieldBuilderAdapter.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CellFieldBuilderAdapter.java index d12c93a6..d258338e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CellFieldBuilderAdapter.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CellFieldBuilderAdapter.java @@ -107,6 +107,7 @@ interface CellFieldBuilderAdapter { default: { label.setAlignment(SWT.LEFT); + break; } } label.setLayoutData(gridData); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TextFieldBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TextFieldBuilder.java index 039d2007..c2804a2a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TextFieldBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TextFieldBuilder.java @@ -79,6 +79,7 @@ public class TextFieldBuilder implements InputFieldBuilder { } default: { text = new Text(innerGrid, SWT.LEFT | SWT.BORDER); + break; } } text.setLayoutData(gridData); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/DefaultPageLayout.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/DefaultPageLayout.java index 334f0052..809191ca 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/DefaultPageLayout.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/DefaultPageLayout.java @@ -312,7 +312,7 @@ public class DefaultPageLayout implements TemplateComposer { urlLauncher.openURL(link); } } catch (final Exception e) { - + log.error("Invalid Help link", e); } }); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java index e61793d1..b248ad67 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java @@ -233,7 +233,8 @@ public class PageServiceImpl implements PageService { .logout(); if (!logoutSuccessful) { - // TODO error handling + log.error("Failed to logout. See logfiles for more information"); + pageContext.notifyError(new RuntimeException("Failed to logout. See logfiles for more information")); } } catch (final Exception e) { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java index 4748a048..635a28cf 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java @@ -455,10 +455,10 @@ public class EntityTable { final Widget widget = event.widget; if (widget instanceof TableColumn) { final TableColumn tableColumn = ((TableColumn) widget); - if (this.filter != null && - this.filter.adaptColumnWidth( - this.table.indexOf(tableColumn), - tableColumn.getWidth())) { + if (this.filter != null) { + this.filter.adaptColumnWidth( + this.table.indexOf(tableColumn), + tableColumn.getWidth()); } } } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/GridTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/GridTable.java index ec2f9152..4c2d5aa4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/GridTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/GridTable.java @@ -352,33 +352,33 @@ public class GridTable extends Composite { private static class CheckBox implements ControlAdapter { - private final Button checkbox; + private final Button checkboxButton; private final ColumnDef columnDef; CheckBox(final Composite parent, final ColumnDef columnDef, final Listener listener) { - this.checkbox = new Button(parent, SWT.CHECK); - this.checkbox.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + this.checkboxButton = new Button(parent, SWT.CHECK); + this.checkboxButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); this.columnDef = columnDef; if (listener != null) { - this.checkbox.addListener(SWT.Selection, listener); + this.checkboxButton.addListener(SWT.Selection, listener); } } @Override public String getValue() { - return this.checkbox.getSelection() + return this.checkboxButton.getSelection() ? Constants.TRUE_STRING : Constants.FALSE_STRING; } @Override public void setValue(final String value) { - this.checkbox.setSelection(BooleanUtils.toBoolean(value)); + this.checkboxButton.setSelection(BooleanUtils.toBoolean(value)); } @Override public void dispose() { - this.checkbox.dispose(); + this.checkboxButton.dispose(); } @Override @@ -389,30 +389,30 @@ public class GridTable extends Composite { private static class TextField implements ControlAdapter { - private final Text textField; + private final Text _textField; private final ColumnDef columnDef; TextField(final Composite parent, final ColumnDef columnDef, final Listener listener) { - this.textField = new Text(parent, SWT.LEFT | SWT.BORDER); - this.textField.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + this._textField = new Text(parent, SWT.LEFT | SWT.BORDER); + this._textField.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); this.columnDef = columnDef; - this.textField.addListener(SWT.FocusOut, listener); - this.textField.addListener(SWT.Traverse, listener); + this._textField.addListener(SWT.FocusOut, listener); + this._textField.addListener(SWT.Traverse, listener); } @Override public String getValue() { - return this.textField.getText(); + return this._textField.getText(); } @Override public void setValue(final String value) { - this.textField.setText((value != null) ? value : ""); + this._textField.setText((value != null) ? value : ""); } @Override public void dispose() { - this.textField.dispose(); + this._textField.dispose(); } @Override diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationServiceImpl.java index 716b3ca0..07a2f366 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationServiceImpl.java @@ -183,6 +183,7 @@ public class PaginationServiceImpl implements PaginationService { } default: { PageHelper.orderBy(sortColumnName); + break; } } } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/SEBServerUser.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/SEBServerUser.java index 7ccb58ae..c31f841e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/SEBServerUser.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/SEBServerUser.java @@ -116,11 +116,6 @@ public final class SEBServerUser implements UserDetails, CredentialsContainer { this.password = null; } - @Override - protected Object clone() throws CloneNotSupportedException { - return SEBServerUser.of(this); - } - @Override public int hashCode() { final int prime = 31;