From ebc75e34c2efdbccf8efbfc34755d2fd71cb8fb8 Mon Sep 17 00:00:00 2001 From: Sébastien Lesaint Date: Fri, 25 Mar 2016 16:36:11 +0100 Subject: SONAR-7480 remove useless map copy --- .../java/org/sonar/server/qualityprofile/QProfileLoader.java | 9 +-------- .../org/sonar/server/qualityprofile/ws/SearchDataLoader.java | 10 ++-------- 2 files changed, 3 insertions(+), 16 deletions(-) (limited to 'server/sonar-server') diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java index 64230d8b40b..ff63491c891 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java @@ -21,11 +21,9 @@ package org.sonar.server.qualityprofile; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import javax.annotation.CheckForNull; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; @@ -101,12 +99,7 @@ public class QProfileLoader { } public Map countAllActiveRules() { - Set> entries = activeRuleIndex.countAllByQualityProfileKey().entrySet(); - Map counts = new HashMap<>(entries.size()); - for (Map.Entry entry : entries) { - counts.put(entry.getKey(), entry.getValue()); - } - return counts; + return activeRuleIndex.countAllByQualityProfileKey(); } public Map> getAllProfileStats() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java index 71348447368..cb5c848cdca 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java @@ -181,13 +181,13 @@ public class SearchDataLoader { return Sets.newHashSet(Sets.difference(languageKeys, set2)); } - private void addAllFromDto(Map qualityProfiles, Collection list) { + private static void addAllFromDto(Map qualityProfiles, Collection list) { for (QualityProfileDto qualityProfileDto : list) { qualityProfiles.put(qualityProfileDto.getLanguage(), QualityProfileDtoToQProfile.INSTANCE.apply(qualityProfileDto)); } } - private void addAll(Map qualityProfiles, Collection list) { + private static void addAll(Map qualityProfiles, Collection list) { for (QProfile qProfile : list) { qualityProfiles.put(qProfile.language(), qProfile); } @@ -197,12 +197,6 @@ public class SearchDataLoader { return from(Arrays.asList(languages.all())).transform(LanguageToKey.INSTANCE).toSet(); } - private List findDefaultProfiles(Set languageKeys) { - try (DbSession dbSession = dbClient.openSession(false)) { - return findDefaultProfiles(dbSession, languageKeys); - } - } - private List findDefaultProfiles(final DbSession dbSession, Set languageKeys) { return from(profileFactory.getDefaults(dbSession, languageKeys)) .transform(QualityProfileDtoToQProfile.INSTANCE) -- cgit v1.2.3