]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5389 Do not expose rule name in active rule as we may drop it soon
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 24 Jul 2014 07:28:10 +0000 (09:28 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 24 Jul 2014 07:29:02 +0000 (09:29 +0200)
sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/ActiveRule.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRule.java
sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/ActiveRulesBuilderTest.java

index f54dab6af55425a344fbd78e7f96c44036cf0918..6f4b2bdec7078a762f9b78faddd7e98eb764c82c 100644 (file)
@@ -24,8 +24,8 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.measure.Metric;
-import org.sonar.api.batch.rule.ActiveRule;
 import org.sonar.api.batch.rule.ActiveRules;
+import org.sonar.api.batch.rule.internal.DefaultActiveRule;
 import org.sonar.api.batch.sensor.SensorContext;
 import org.sonar.api.batch.sensor.issue.Issue;
 import org.sonar.api.batch.sensor.issue.IssueBuilder;
@@ -128,7 +128,7 @@ public class DefaultSensorContext implements SensorContext {
       resourceKey = def.getKey();
     }
     RuleKey ruleKey = issue.ruleKey();
-    ActiveRule activeRule = activeRules.find(ruleKey);
+    DefaultActiveRule activeRule = (DefaultActiveRule) activeRules.find(ruleKey);
     if (activeRule == null) {
       // rule does not exist or is not enabled -> ignore the issue
       return false;
@@ -147,7 +147,7 @@ public class DefaultSensorContext implements SensorContext {
     return false;
   }
 
-  private void updateIssue(DefaultIssue issue, ActiveRule activeRule) {
+  private void updateIssue(DefaultIssue issue, DefaultActiveRule activeRule) {
     if (Strings.isNullOrEmpty(issue.message())) {
       issue.setMessage(activeRule.name());
     }
index d24fa2eed841c4b83553b517d9f27ec53e6b5f48..35447556df9113288b23d316b352d65188bb6225 100644 (file)
@@ -33,12 +33,6 @@ public interface ActiveRule {
 
   RuleKey ruleKey();
 
-  /**
-   * Name of the rule.
-   * @since 4.5
-   */
-  String name();
-
   /**
    * Non-null severity.
    * @see org.sonar.api.rule.Severity
index b37fc6a88907ac6597c6f675d10da1958b30fdfd..08d34525d69f56db5a5a4c374c2fe611d2ade2cd 100644 (file)
@@ -28,7 +28,7 @@ import javax.annotation.concurrent.Immutable;
 import java.util.Map;
 
 @Immutable
-class DefaultActiveRule implements ActiveRule {
+public class DefaultActiveRule implements ActiveRule {
   private final RuleKey ruleKey;
   private final String name;
   private final String severity, internalKey, language;
@@ -48,7 +48,6 @@ class DefaultActiveRule implements ActiveRule {
     return ruleKey;
   }
 
-  @Override
   public String name() {
     return name;
   }
index 3d2ac27b8a1339d2fa3594bce71fd481507ef593..448880b9e4bf90eddfadb99f9e32fce9190e2b02 100644 (file)
@@ -59,7 +59,7 @@ public class ActiveRulesBuilderTest {
     ActiveRule squid1 = activeRules.find(RuleKey.of("squid", "S0001"));
     assertThat(squid1.ruleKey().repository()).isEqualTo("squid");
     assertThat(squid1.ruleKey().rule()).isEqualTo("S0001");
-    assertThat(squid1.name()).isEqualTo("My Rule");
+    assertThat(((DefaultActiveRule) squid1).name()).isEqualTo("My Rule");
     assertThat(squid1.severity()).isEqualTo(Severity.CRITICAL);
     assertThat(squid1.internalKey()).isEqualTo("__S0001__");
     assertThat(squid1.params()).hasSize(1);