diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2019-12-09 09:34:43 -0600 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-12-10 20:46:09 +0100 |
commit | d1fd889554bccbb50122550899dbb66b90b04f78 (patch) | |
tree | 9cad838366292ee79b77ac3513403f7489b06355 /server/sonar-webserver-es | |
parent | f86a1094588e4e47b3abf612891af0431653cd0e (diff) | |
download | sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.tar.gz sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.zip |
Fix code quality issues and reduce dependency on Guava
Diffstat (limited to 'server/sonar-webserver-es')
5 files changed, 9 insertions, 10 deletions
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexCreator.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexCreator.java index 0a45e823dbe..afa9977ca48 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexCreator.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexCreator.java @@ -114,7 +114,7 @@ public class IndexCreator implements Startable { String indexName = mainType.getIndex().getName(); String readOnly = client.nativeClient().admin().indices().getSettings(new GetSettingsRequest().indices(indexName)).actionGet() .getSetting(indexName, "index.blocks.read_only_allow_delete"); - return readOnly != null && "true".equalsIgnoreCase(readOnly); + return "true".equalsIgnoreCase(readOnly); } private void removeReadOnly(IndexType.IndexMainType mainType) { diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexDefinitions.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexDefinitions.java index 22b8b59b0c3..bbd8b1dbd39 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexDefinitions.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexDefinitions.java @@ -19,7 +19,7 @@ */ package org.sonar.server.es; -import com.google.common.collect.Maps; +import java.util.HashMap; import java.util.Map; import org.picocontainer.Startable; import org.sonar.api.config.Configuration; @@ -33,7 +33,7 @@ import org.sonar.server.es.newindex.NewIndex; @ServerSide public class IndexDefinitions implements Startable { - private final Map<String, BuiltIndex> byKey = Maps.newHashMap(); + private final Map<String, BuiltIndex> byKey = new HashMap<>(); private final IndexDefinition[] defs; private final Configuration config; diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java index 295c8576cb2..6406a47025b 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java @@ -510,7 +510,7 @@ public class IssueIndex { String facetName = ASSIGNEES.getName(); // Same as in super.stickyFacetBuilder - Map<String, QueryBuilder> assigneeFilters = Maps.newHashMap(filters); + Map<String, QueryBuilder> assigneeFilters = new HashMap<>(filters); assigneeFilters.remove(IS_ASSIGNED_FILTER); assigneeFilters.remove(fieldName); StickyFacetBuilder stickyFacetBuilder = newStickyFacetBuilder(query, assigneeFilters, queryBuilder); @@ -895,8 +895,8 @@ public class IssueIndex { private static AggregationBuilder createAggregation(String categoryField, String category, boolean includeCwe, Optional<Map<String, Set<String>>> categoryToCwesMap) { return addSecurityReportSubAggregations(AggregationBuilders - .filter(category, boolQuery() - .filter(termQuery(categoryField, category))), + .filter(category, boolQuery() + .filter(termQuery(categoryField, category))), includeCwe, categoryToCwesMap.map(m -> m.get(category))); } diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java index 8f9bf8b324f..d680ccbd0a4 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java @@ -450,7 +450,7 @@ public class RecoveryIndexerTest { } } - private class HardFailingFakeIndexer implements ResilientIndexer { + private static class HardFailingFakeIndexer implements ResilientIndexer { private final Set<IndexType> types; private final List<Collection<EsQueueDto>> called = new ArrayList<>(); @@ -476,7 +476,7 @@ public class RecoveryIndexerTest { } } - private class SoftFailingFakeIndexer implements ResilientIndexer { + private static class SoftFailingFakeIndexer implements ResilientIndexer { private final Set<IndexType> types; private final List<Collection<EsQueueDto>> called = new ArrayList<>(); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java index 1dda0b4e89a..d7070fad5bb 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java @@ -391,8 +391,7 @@ public class PermissionIndexerTest { } private ComponentDto createUnindexedPublicProject() { - ComponentDto project = db.components().insertPublicProject(); - return project; + return db.components().insertPublicProject(); } private ComponentDto createAndIndexPrivateProject() { |