aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-01-31 16:37:50 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-02-08 13:41:00 +0100
commit0a5f50d66405272d1f8e3a8dc3b9de4c58a29c82 (patch)
tree24a5d39e933e143e1b7b38fb49720d0dc2559e6a /server/sonar-server
parent522be74684c7ba49c86f47c827356f090a1187c1 (diff)
downloadsonarqube-0a5f50d66405272d1f8e3a8dc3b9de4c58a29c82.tar.gz
sonarqube-0a5f50d66405272d1f8e3a8dc3b9de4c58a29c82.zip
SONAR-10313 remove rule key and repo from rules.activeRule index
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java21
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndexDefinition.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java6
4 files changed, 3 insertions, 32 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java
index 464d3f13531..0d1d03f7f15 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java
@@ -22,7 +22,6 @@ package org.sonar.server.qualityprofile.index;
import com.google.common.collect.Maps;
import java.util.Map;
import javax.annotation.Nullable;
-import org.sonar.api.rule.RuleKey;
import org.sonar.server.es.BaseDoc;
import org.sonar.server.qualityprofile.ActiveRule;
@@ -30,9 +29,7 @@ import static org.apache.commons.lang.StringUtils.containsIgnoreCase;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_ID;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_INHERITANCE;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_PROFILE_UUID;
-import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_REPOSITORY;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_RULE_ID;
-import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_RULE_KEY;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_SEVERITY;
public class ActiveRuleDoc extends BaseDoc {
@@ -61,24 +58,6 @@ public class ActiveRuleDoc extends BaseDoc {
return getRuleIdAsString();
}
- RuleKey getRuleKey() {
- return RuleKey.parse(getRuleKeyAsString());
- }
-
- private String getRuleKeyAsString() {
- return getField(FIELD_ACTIVE_RULE_RULE_KEY);
- }
-
- String getRuleRepository() {
- return getField(FIELD_ACTIVE_RULE_REPOSITORY);
- }
-
- ActiveRuleDoc setRuleKey(RuleKey ruleKey) {
- setField(FIELD_ACTIVE_RULE_RULE_KEY, ruleKey.toString());
- setField(FIELD_ACTIVE_RULE_REPOSITORY, ruleKey.repository());
- return this;
- }
-
private String getRuleIdAsString() {
return getField(FIELD_ACTIVE_RULE_RULE_ID);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java
index 09858a14e25..a24afa09b56 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java
@@ -29,7 +29,6 @@ import javax.annotation.Nullable;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.index.query.QueryBuilders;
-import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.db.DbClient;
@@ -210,8 +209,7 @@ public class ActiveRuleIndexer implements ResilientIndexer {
ActiveRuleDoc doc = new ActiveRuleDoc(dto.getId())
.setRuleId(dto.getRuleId())
.setRuleProfileUuid(dto.getRuleProfileUuid())
- .setSeverity(SeverityUtil.getSeverityFromOrdinal(dto.getSeverity()))
- .setRuleKey(RuleKey.of(dto.getRepository(), dto.getKey()));
+ .setSeverity(SeverityUtil.getSeverityFromOrdinal(dto.getSeverity()));
// all the fields must be present, even if value is null
String inheritance = dto.getInheritance();
doc.setInheritance(inheritance == null ? ActiveRule.Inheritance.NONE.name() : inheritance);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndexDefinition.java
index a2d78d521cf..a25e207e35b 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndexDefinition.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndexDefinition.java
@@ -75,11 +75,9 @@ public class RuleIndexDefinition implements IndexDefinition {
public static final IndexType INDEX_TYPE_ACTIVE_RULE = new IndexType(INDEX, "activeRule");
public static final String FIELD_ACTIVE_RULE_ID = "id";
public static final String FIELD_ACTIVE_RULE_RULE_ID = "ruleId";
- public static final String FIELD_ACTIVE_RULE_REPOSITORY = "repo";
public static final String FIELD_ACTIVE_RULE_INHERITANCE = "inheritance";
public static final String FIELD_ACTIVE_RULE_PROFILE_UUID = "ruleProfile";
public static final String FIELD_ACTIVE_RULE_SEVERITY = "severity";
- public static final String FIELD_ACTIVE_RULE_RULE_KEY = "ruleKey";
private final Configuration config;
private final boolean enableSource;
@@ -121,8 +119,6 @@ public class RuleIndexDefinition implements IndexDefinition {
activeRuleMapping.keywordFieldBuilder(FIELD_ACTIVE_RULE_ID).disableNorms().build();
activeRuleMapping.keywordFieldBuilder(FIELD_ACTIVE_RULE_RULE_ID).disableNorms().build();
- activeRuleMapping.keywordFieldBuilder(FIELD_ACTIVE_RULE_RULE_KEY).addSubFields(SORTABLE_ANALYZER).build();
- activeRuleMapping.keywordFieldBuilder(FIELD_ACTIVE_RULE_REPOSITORY).build();
activeRuleMapping.keywordFieldBuilder(FIELD_ACTIVE_RULE_PROFILE_UUID).disableNorms().build();
activeRuleMapping.keywordFieldBuilder(FIELD_ACTIVE_RULE_INHERITANCE).disableNorms().build();
activeRuleMapping.keywordFieldBuilder(FIELD_ACTIVE_RULE_SEVERITY).disableNorms().build();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java
index c5849903149..fff22e50be2 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java
@@ -92,7 +92,7 @@ public class ActiveRuleIndexerTest {
List<ActiveRuleDoc> docs = es.getDocuments(INDEX_TYPE_ACTIVE_RULE, ActiveRuleDoc.class);
assertThat(docs).hasSize(1);
- verify(docs.get(0), rule1, profile1, activeRule);
+ verify(docs.get(0), profile1, activeRule);
assertThatEsQueueTableIsEmpty();
}
@@ -202,12 +202,10 @@ public class ActiveRuleIndexerTest {
}
}
- private void verify(ActiveRuleDoc doc1, RuleDefinitionDto rule, QProfileDto profile, ActiveRuleDto activeRule) {
+ private void verify(ActiveRuleDoc doc1, QProfileDto profile, ActiveRuleDto activeRule) {
assertThat(doc1)
- .matches(doc -> doc.getRuleKey().equals(rule.getKey()))
.matches(doc -> doc.getId().equals("" + activeRule.getId()))
.matches(doc -> doc.getRuleProfileUuid().equals(profile.getRulesProfileUuid()))
- .matches(doc -> doc.getRuleRepository().equals(rule.getRepositoryKey()))
.matches(doc -> doc.getSeverity().equals(activeRule.getSeverityString()));
}