aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/DefaultActiveRulesLoader.java30
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/LoadedActiveRule.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/ChecksMediumTest.java14
3 files changed, 25 insertions, 25 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultActiveRulesLoader.java b/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultActiveRulesLoader.java
index 956793fe1a2..6c63e451f45 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultActiveRulesLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultActiveRulesLoader.java
@@ -19,26 +19,23 @@
*/
package org.sonar.batch.rule;
-import org.sonarqube.ws.Rules.Active.Param;
-import org.sonarqube.ws.Rules.Active;
-import org.sonar.api.rule.RuleKey;
-import org.sonarqube.ws.Rules.ActiveList;
-import org.sonarqube.ws.Rules.SearchResponse;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.mutable.MutableBoolean;
-import org.sonar.batch.cache.WSLoader;
-import org.sonar.batch.cache.WSLoaderResult;
-
-import javax.annotation.Nullable;
-
-import org.sonarqube.ws.Rules.Rule;
-
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.mutable.MutableBoolean;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.batch.cache.WSLoader;
+import org.sonar.batch.cache.WSLoaderResult;
+import org.sonarqube.ws.Rules.Active;
+import org.sonarqube.ws.Rules.Active.Param;
+import org.sonarqube.ws.Rules.ActiveList;
+import org.sonarqube.ws.Rules.Rule;
+import org.sonarqube.ws.Rules.SearchResponse;
public class DefaultActiveRulesLoader implements ActiveRulesLoader {
private static final String RULES_SEARCH_URL = "/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true";
@@ -108,7 +105,10 @@ public class DefaultActiveRulesLoader implements ActiveRulesLoader {
loadedRule.setSeverity(active.getSeverity());
loadedRule.setLanguage(r.getLang());
loadedRule.setInternalKey(r.getInternalKey());
- loadedRule.setTemplateRuleKey(r.getTemplateKey());
+ if (r.hasTemplateKey()) {
+ RuleKey templateRuleKey = RuleKey.parse(r.getTemplateKey());
+ loadedRule.setTemplateRuleKey(templateRuleKey.rule());
+ }
Map<String, String> params = new HashMap<>();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/LoadedActiveRule.java b/sonar-batch/src/main/java/org/sonar/batch/rule/LoadedActiveRule.java
index edd5b2c421e..c0a338ef796 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/rule/LoadedActiveRule.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/rule/LoadedActiveRule.java
@@ -20,7 +20,8 @@
package org.sonar.batch.rule;
import java.util.Map;
-
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import org.sonar.api.rule.RuleKey;
public class LoadedActiveRule {
@@ -72,11 +73,12 @@ public class LoadedActiveRule {
this.params = params;
}
+ @CheckForNull
public String getTemplateRuleKey() {
return templateRuleKey;
}
- public void setTemplateRuleKey(String templateRuleKey) {
+ public void setTemplateRuleKey(@Nullable String templateRuleKey) {
this.templateRuleKey = templateRuleKey;
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/ChecksMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/ChecksMediumTest.java
index 4c58eb3eb68..861e5eabf59 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/ChecksMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/ChecksMediumTest.java
@@ -20,6 +20,12 @@
package org.sonar.batch.mediumtest.issues;
import com.google.common.collect.ImmutableMap;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
@@ -33,14 +39,6 @@ import org.sonar.batch.rule.LoadedActiveRule;
import org.sonar.xoo.XooPlugin;
import org.sonar.xoo.rule.XooRulesDefinition;
-import javax.annotation.Nullable;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import static org.assertj.core.api.Assertions.assertThat;
public class ChecksMediumTest {