aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-03-13 14:15:05 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-03-13 14:15:05 +0100
commitd82ef451facf728359a9634fdec781b2d8dc25ce (patch)
treebcd8bdf9c330578811e078b1602ddd25c5d28d6c /sonar-plugin-api/src
parent9aa415c8a2ef82dcd3e7b9b193d51deed6dca674 (diff)
downloadsonarqube-d82ef451facf728359a9634fdec781b2d8dc25ce.tar.gz
sonarqube-d82ef451facf728359a9634fdec781b2d8dc25ce.zip
SONAR-5056 Fix performance issue when converting new rule to old rule
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rules.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRules.java16
2 files changed, 18 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rules.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rules.java
index 14fb6cb7ac3..2a2ff644f32 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rules.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rules.java
@@ -39,4 +39,6 @@ public interface Rules {
Collection<Rule> findByRepository(String repository);
+ Collection<Rule> findWithDebt();
+
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRules.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRules.java
index 3c14387a31c..20de45fd89f 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRules.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRules.java
@@ -31,12 +31,16 @@ import javax.annotation.concurrent.Immutable;
import java.util.Collection;
import java.util.List;
+import static com.google.common.collect.Lists.newArrayList;
+
@Immutable
class DefaultRules implements Rules {
// TODO use disk-backed cache (persistit) instead of full in-memory cache ?
private final ListMultimap<String, Rule> rulesByRepository;
+ private final Collection<Rule> rulesWithDebt;
+
DefaultRules(Collection<NewRule> newRules) {
ImmutableListMultimap.Builder<String, Rule> builder = ImmutableListMultimap.builder();
for (NewRule newRule : newRules) {
@@ -44,6 +48,13 @@ class DefaultRules implements Rules {
builder.put(r.key().repository(), r);
}
rulesByRepository = builder.build();
+
+ rulesWithDebt = newArrayList();
+ for (Rule rule : rulesByRepository.values()) {
+ if (rule.characteristic() != null) {
+ rulesWithDebt.add(rule);
+ }
+ }
}
@Override
@@ -66,4 +77,9 @@ class DefaultRules implements Rules {
public Collection<Rule> findByRepository(String repository) {
return rulesByRepository.get(repository);
}
+
+ @Override
+ public Collection<Rule> findWithDebt() {
+ return rulesWithDebt;
+ }
}