fix sonar issues

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-08-05 14:58:17 +02:00
parent 59490d80cd
commit c71cf4852a
5 changed files with 26 additions and 53 deletions

View File

@@ -104,7 +104,7 @@ public class EntityInterceptorListener {
notifyAll(interceptor -> interceptor.postUpdate(entity)); notifyAll(interceptor -> interceptor.postUpdate(entity));
} }
private void notifyAll(final Consumer<? super EntityInterceptor> action) { private static void notifyAll(final Consumer<? super EntityInterceptor> action) {
EntityInterceptorHolder.getInstance().getEntityInterceptors().forEach(action); EntityInterceptorHolder.getInstance().getEntityInterceptors().forEach(action);
} }
} }

View File

@@ -69,13 +69,10 @@ public class ByteRange {
return total; return total;
} }
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override @Override
public int hashCode() { // NOSONAR - as this is generated // NOSONAR - as this is generated
@SuppressWarnings("squid:S864")
public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + (int) (end ^ end >>> 32); result = prime * result + (int) (end ^ end >>> 32);
@@ -85,11 +82,6 @@ public class ByteRange {
return result; return result;
} }
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override @Override
public boolean equals(final Object obj) { // NOSONAR - as this is generated public boolean equals(final Object obj) { // NOSONAR - as this is generated
if (this == obj) { if (this == obj) {

View File

@@ -8,7 +8,10 @@
*/ */
package org.eclipse.hawkbit.ui.artifacts.smtype; package org.eclipse.hawkbit.ui.artifacts.smtype;
import java.util.EnumSet;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria; import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
@@ -46,12 +49,11 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleTypeEvent event) { void onEvent(final SoftwareModuleTypeEvent event) {
if (event.getSoftwareModuleTypeEnum() == SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.ADD_SOFTWARE_MODULE_TYPE if (event.getSoftwareModuleType() != null
|| event.getSoftwareModuleTypeEnum() == SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.UPDATE_SOFTWARE_MODULE_TYPE && EnumSet.allOf(SoftwareModuleTypeEnum.class).contains(event.getSoftwareModuleTypeEnum())) {
|| event.getSoftwareModuleTypeEnum() == SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.DELETE_SOFTWARE_MODULE_TYPE
&& event.getSoftwareModuleType() != null) {
refreshTable(); refreshTable();
} }
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)

View File

@@ -108,7 +108,7 @@ public class UploadConfirmationwindow implements Button.ClickListener {
private UploadResultWindow currentUploadResultWindow; private UploadResultWindow currentUploadResultWindow;
private int redErrorLabelCount = 0; private int redErrorLabelCount;
private final ArtifactUploadState artifactUploadState; private final ArtifactUploadState artifactUploadState;
@@ -353,11 +353,8 @@ public class UploadConfirmationwindow implements Button.ClickListener {
* label * label
* @return Boolean * @return Boolean
*/ */
private Boolean isWarningIcon(final Label icon) { private static Boolean isWarningIcon(final Label icon) {
if (icon.isVisible() && !icon.getStyleName().contains(SPUIStyleDefinitions.ERROR_LABEL)) { return !isErrorIcon(icon);
return true;
}
return false;
} }
/** /**
@@ -367,14 +364,11 @@ public class UploadConfirmationwindow implements Button.ClickListener {
* label * label
* @return Boolean * @return Boolean
*/ */
private Boolean isErrorIcon(final Label icon) { private static Boolean isErrorIcon(final Label icon) {
if (icon.isVisible() && icon.getStyleName().contains(SPUIStyleDefinitions.ERROR_LABEL)) { return icon.isVisible() && icon.getStyleName().contains(SPUIStyleDefinitions.ERROR_LABEL);
return true;
}
return false;
} }
private Label getWarningLabel() { private static Label getWarningLabel() {
final Label warningIconLabel = new Label(); final Label warningIconLabel = new Label();
warningIconLabel.addStyleName(ValoTheme.LABEL_SMALL); warningIconLabel.addStyleName(ValoTheme.LABEL_SMALL);
warningIconLabel.setHeightUndefined(); warningIconLabel.setHeightUndefined();
@@ -436,7 +430,7 @@ public class UploadConfirmationwindow implements Button.ClickListener {
private void hideErrorIcon(final Label warningLabel, final int errorLabelCount, final int duplicateCount, private void hideErrorIcon(final Label warningLabel, final int errorLabelCount, final int duplicateCount,
final Label errorLabel, final String oldFileName, final Long currentSwId) { final Label errorLabel, final String oldFileName, final Long currentSwId) {
if (warningLabel == null && (errorLabelCount > 1 || duplicateCount == 1 && errorLabelCount == 1)) { if (warningLabel == null && (errorLabelCount > 1 || (duplicateCount == 1 && errorLabelCount == 1))) {
final ArtifactManagement artifactManagement = SpringContextHelper.getBean(ArtifactManagement.class); final ArtifactManagement artifactManagement = SpringContextHelper.getBean(ArtifactManagement.class);
final List<LocalArtifact> artifactList = artifactManagement.findByFilenameAndSoftwareModule(oldFileName, final List<LocalArtifact> artifactList = artifactManagement.findByFilenameAndSoftwareModule(oldFileName,
currentSwId); currentSwId);
@@ -486,12 +480,12 @@ public class UploadConfirmationwindow implements Button.ClickListener {
uploadDetailsTable.setColumnHeader(SIZE, i18n.get("upload.size")); uploadDetailsTable.setColumnHeader(SIZE, i18n.get("upload.size"));
uploadDetailsTable.setColumnHeader(ACTION, i18n.get("upload.action")); uploadDetailsTable.setColumnHeader(ACTION, i18n.get("upload.action"));
uploadDetailsTable.setColumnExpandRatio(FILE_NAME_LAYOUT, 0.25f); uploadDetailsTable.setColumnExpandRatio(FILE_NAME_LAYOUT, 0.25F);
uploadDetailsTable.setColumnExpandRatio(SW_MODULE_NAME, 0.17f); uploadDetailsTable.setColumnExpandRatio(SW_MODULE_NAME, 0.17F);
uploadDetailsTable.setColumnExpandRatio(SHA1_CHECKSUM, 0.2f); uploadDetailsTable.setColumnExpandRatio(SHA1_CHECKSUM, 0.2F);
uploadDetailsTable.setColumnExpandRatio(MD5_CHECKSUM, 0.2f); uploadDetailsTable.setColumnExpandRatio(MD5_CHECKSUM, 0.2F);
uploadDetailsTable.setColumnExpandRatio(SIZE, 0.12f); uploadDetailsTable.setColumnExpandRatio(SIZE, 0.12F);
uploadDetailsTable.setColumnExpandRatio(ACTION, 0.06f); uploadDetailsTable.setColumnExpandRatio(ACTION, 0.06F);
final Object[] visibileColumn = { FILE_NAME_LAYOUT, SW_MODULE_NAME, SHA1_CHECKSUM, MD5_CHECKSUM, SIZE, ACTION }; final Object[] visibileColumn = { FILE_NAME_LAYOUT, SW_MODULE_NAME, SHA1_CHECKSUM, MD5_CHECKSUM, SIZE, ACTION };
uploadDetailsTable.setVisibleColumns(visibileColumn); uploadDetailsTable.setVisibleColumns(visibileColumn);
@@ -548,9 +542,7 @@ public class UploadConfirmationwindow implements Button.ClickListener {
uploadConfrimationWindow.close(); uploadConfrimationWindow.close();
} else if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_BUTTON)) { } else if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_BUTTON)) {
processArtifactUpload(); processArtifactUpload();
} } else if (event.getComponent().getId().startsWith(SPUIComponentIdProvider.UPLOAD_DELETE_ICON)) {
else if (event.getComponent().getId().startsWith(SPUIComponentIdProvider.UPLOAD_DELETE_ICON)) {
final String itemId = ((Button) event.getComponent()).getData().toString(); final String itemId = ((Button) event.getComponent()).getData().toString();
final Item item = uploadDetailsTable.getItem(((Button) event.getComponent()).getData()); final Item item = uploadDetailsTable.getItem(((Button) event.getComponent()).getData());
final Long swId = (Long) item.getItemProperty(BASE_SOFTWARE_ID).getValue(); final Long swId = (Long) item.getItemProperty(BASE_SOFTWARE_ID).getValue();
@@ -667,7 +659,7 @@ public class UploadConfirmationwindow implements Button.ClickListener {
} }
private void closeFileStream(final FileInputStream fis, final File newFile) { private static void closeFileStream(final FileInputStream fis, final File newFile) {
if (fis != null) { if (fis != null) {
try { try {

View File

@@ -8,7 +8,6 @@
*/ */
package org.eclipse.hawkbit.ui.common.tagdetails; package org.eclipse.hawkbit.ui.common.tagdetails;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -86,23 +85,11 @@ public class DistributionTagToken extends AbstractTagToken<DistributionSet> {
@Override @Override
protected void unassignTag(final String tagName) { protected void unassignTag(final String tagName) {
final DistributionSetTagAssignmentResult result = toggleAssignment(tagName); final DistributionSetTagAssignmentResult result = toggleAssignment(tagName);
if (result.getUnassigned() >= 1 && (isClickedTagListEmpty() || getClickedTagList().contains(tagName))) { if (result.getUnassigned() >= 1) {
eventBus.publish(this, ManagementUIEvent.UNASSIGN_DISTRIBUTION_TAG); eventBus.publish(this, ManagementUIEvent.UNASSIGN_DISTRIBUTION_TAG);
} }
} }
private Boolean isClickedTagListEmpty() {
if (getClickedTagList() == null || getClickedTagList() != null && !getClickedTagList().isEmpty()) {
return true;
}
return false;
}
/* To Be Done : this implementation will vary in views */
private List<String> getClickedTagList() {
return new ArrayList<>();
}
@Override @Override
protected Boolean isToggleTagAssignmentAllowed() { protected Boolean isToggleTagAssignmentAllowed() {
return checker.hasUpdateDistributionPermission(); return checker.hasUpdateDistributionPermission();