From: Simon Brandhof Date: Wed, 30 Sep 2015 13:28:12 +0000 (+0200) Subject: Fix quality flaws X-Git-Tag: 5.2-RC1~180 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c3d9ca2c7e8db8e188f15dbc0db2278c5303e906;p=sonarqube.git Fix quality flaws --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/queue/CeTask.java b/server/sonar-server/src/main/java/org/sonar/server/computation/queue/CeTask.java index 7867c83aea9..0d847f20e7e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/queue/CeTask.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/queue/CeTask.java @@ -98,7 +98,13 @@ public class CeTask { @Override public int hashCode() { - return uuid.hashCode(); + int result = type.hashCode(); + result = 31 * result + uuid.hashCode(); + result = 31 * result + componentUuid.hashCode(); + result = 31 * result + (componentKey != null ? componentKey.hashCode() : 0); + result = 31 * result + (componentName != null ? componentName.hashCode() : 0); + result = 31 * result + (submitterLogin != null ? submitterLogin.hashCode() : 0); + return result; } public static final class Builder { diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java index 6d94cdeaa26..f7cb3a23894 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java +++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java @@ -46,19 +46,19 @@ import org.sonar.updatecenter.common.UpdateCenterDeserializer.Mode; key = UpdateCenterClient.ACTIVATION_PROPERTY, defaultValue = "true", name = "Enable Update Center", + category = "Update Center", project = false, // hidden from UI global = false, - category = "Update Center", type = PropertyType.BOOLEAN), @Property( key = UpdateCenterClient.URL_PROPERTY, defaultValue = "http://update.sonarsource.org/update-center.properties", name = "Update Center URL", + category = "Update Center", project = false, // hidden from UI - global = false, - category = "Update Center") + global = false) }) public class UpdateCenterClient { diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java index ca0cf295bd6..4a92ec849cb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java @@ -76,7 +76,7 @@ public class ComponentNavigationAction implements NavigationWsAction { private final ComponentFinder componentFinder; public ComponentNavigationAction(DbClient dbClient, Views views, I18n i18n, ResourceTypes resourceTypes, UserSession userSession, - ComponentFinder componentFinder) { + ComponentFinder componentFinder) { this.dbClient = dbClient; this.activeDashboardDao = dbClient.activeDashboardDao(); this.views = views; @@ -144,13 +144,14 @@ public class ComponentNavigationAction implements NavigationWsAction { if (dashboards.isEmpty()) { dashboards = activeDashboardDao.selectProjectDashboardsForUserLogin(session, ANONYMOUS); } - writeDashboards(json, component, dashboards, userSession.locale()); + writeDashboards(json, dashboards); if (snapshot != null) { json.prop("version", snapshot.getVersion()) .prop("snapshotDate", DateUtils.formatDateTime(new Date(snapshot.getCreatedAt()))); - String[] availableMeasures = dbClient.measureDao().selectMetricKeysForSnapshot(session, snapshot.getId()).toArray(new String[0]); - List> pages = views.getPages(NavigationSection.RESOURCE, component.scope(), component.qualifier(), component.language(), availableMeasures); + List availableMeasures = dbClient.measureDao().selectMetricKeysForSnapshot(session, snapshot.getId()); + List> pages = views.getPages(NavigationSection.RESOURCE, component.scope(), component.qualifier(), component.language(), + availableMeasures.toArray(new String[availableMeasures.size()])); writeExtensions(json, component, pages, userSession.locale()); } } @@ -176,7 +177,7 @@ public class ComponentNavigationAction implements NavigationWsAction { } private String getPageUrl(ViewProxy page, ComponentDto component) { - String result = null; + String result; String componentKey = encodeComponentKey(component); if (page.isController()) { result = String.format("%s?id=%s", page.getId(), componentKey); @@ -196,7 +197,7 @@ public class ComponentNavigationAction implements NavigationWsAction { return componentKey; } - private void writeDashboards(JsonWriter json, ComponentDto component, List dashboards, Locale locale) { + private void writeDashboards(JsonWriter json, List dashboards) { json.name("dashboards").beginArray(); for (DashboardDto dashboard : dashboards) { json.beginObject() @@ -212,7 +213,7 @@ public class ComponentNavigationAction implements NavigationWsAction { Locale locale = userSession.locale(); json.name("configuration").beginObject(); - writeConfigPageAccess(json, isAdmin, component, userSession); + writeConfigPageAccess(json, isAdmin, component); if (isAdmin) { json.name("extensions").beginArray(); @@ -225,7 +226,7 @@ public class ComponentNavigationAction implements NavigationWsAction { json.endObject(); } - private void writeConfigPageAccess(JsonWriter json, boolean isAdmin, ComponentDto component, UserSession userSession) { + private void writeConfigPageAccess(JsonWriter json, boolean isAdmin, ComponentDto component) { boolean isProject = Qualifiers.PROJECT.equals(component.qualifier()); json.prop("showSettings", isAdmin && componentTypeHasProperty(component, PROPERTY_CONFIGURABLE)); @@ -242,10 +243,7 @@ public class ComponentNavigationAction implements NavigationWsAction { private boolean componentTypeHasProperty(ComponentDto component, String resourceTypeProperty) { ResourceType resourceType = resourceTypes.get(component.qualifier()); - if (resourceType != null) { - return resourceType.getBooleanProperty(resourceTypeProperty); - } - return false; + return resourceType != null && resourceType.getBooleanProperty(resourceTypeProperty); } private void writePage(JsonWriter json, String url, String name) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexDefinition.java index 64e13256ef3..6d13e2a0684 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexDefinition.java @@ -88,7 +88,7 @@ public class UserIndexDefinition implements IndexDefinition { mapping.stringFieldBuilder(FIELD_SCM_ACCOUNTS).build(); } - private SortedMap buildGramSearchField() { + private static SortedMap buildGramSearchField() { return ImmutableSortedMap.of( "type", "string", "index", "analyzed",