]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2706 add Review#getRuleName()
authorSimon Brandhof <simon.brandhof@gmail.com>
Fri, 25 May 2012 14:10:46 +0000 (16:10 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Fri, 25 May 2012 14:10:46 +0000 (16:10 +0200)
sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java
sonar-core/src/main/java/org/sonar/core/review/workflow/review/ImmutableReview.java
sonar-core/src/main/java/org/sonar/core/review/workflow/review/Review.java
sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb
sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb

index 51a52790000a7ffd2d4cc6b3650df3ea4fd6024e..2c6519e38bcfed6b6c874452ed67bcdf62d5ed5b 100644 (file)
@@ -39,6 +39,7 @@ public final class DefaultReview implements MutableReview {
   private Long reviewId;
   private String ruleRepositoryKey;
   private String ruleKey;
+  private String ruleName;
   private Long line;
   private boolean switchedOff = false;
   private boolean manual = false;
@@ -85,6 +86,15 @@ public final class DefaultReview implements MutableReview {
     return this;
   }
 
+  public String getRuleName() {
+    return ruleName;
+  }
+
+  public DefaultReview setRuleName(String s) {
+    this.ruleName = s;
+    return this;
+  }
+
   public Long getLine() {
     return line;
   }
@@ -210,6 +220,7 @@ public final class DefaultReview implements MutableReview {
     clone.setReviewId(reviewId);
     clone.setRuleKey(ruleKey);
     clone.setRuleRepositoryKey(ruleRepositoryKey);
+    clone.setRuleName(ruleName);
     clone.setSeverity(severity);
     clone.setStatus(status);
     clone.setSwitchedOff(switchedOff);
index 1f3b7e9e0224f3446720079acf9fb81349fba3d3..35c8f01a4708872599eb0e7d60f1c34955db21de 100644 (file)
@@ -24,9 +24,9 @@ import java.util.Map;
 public class ImmutableReview implements Review {
   private Long violationId;
   private Long reviewId;
-  private Long ruleId;
   private String ruleRepositoryKey;
   private String ruleKey;
+  private String ruleName;
   private Long line;
   private boolean switchedOff = false;
   private boolean manual = false;
@@ -52,12 +52,12 @@ public class ImmutableReview implements Review {
     this.reviewId = reviewId;
   }
 
-  public Long getRuleId() {
-    return ruleId;
+  public String getRuleName() {
+    return ruleName;
   }
 
-  void setRuleId(Long ruleId) {
-    this.ruleId = ruleId;
+  void setRuleName(String s) {
+    this.ruleName = s;
   }
 
   public String getRuleRepositoryKey() {
index 95c8e28080a48c2597b561e47c7c40152b002358..777b6c5da968061ebbc303654d79d551d5d17f24 100644 (file)
@@ -27,6 +27,8 @@ public interface Review {
 
   String getRuleKey();
 
+  String getRuleName();
+
   boolean isSwitchedOff();
 
   String getMessage();
index 71fbd6a411fdf6818b92ade74f02a96329505c91..4cde503c03ddd2b5fb94eb90f96624b988446906 100644 (file)
@@ -69,13 +69,17 @@ class Rule < ActiveRecord::Base
     name.downcase<=>other.name.downcase
   end
 
-  def name
-    @l10n_name ||=
+  def name(l10n=true)
+    if l10n
+      @l10n_name ||=
         begin
           result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getRuleName(I18n.locale, repository_key, plugin_rule_key)
           result = read_attribute(:name) unless result
           result
         end
+    else
+      read_attribute(:name)
+    end
   end
 
   def name=(value)
index 5121cd144c12171e8fb77d6eb05bd01ed62b3b10..6ae29910d0bac84360ad7914d288cb5df129574e 100644 (file)
@@ -280,6 +280,7 @@ class RuleFailure < ActiveRecord::Base
     java_review.setSeverity(violation.severity.to_s)
     java_review.setRuleKey(violation.rule.plugin_rule_key)
     java_review.setRuleRepositoryKey(violation.rule.repository_key)
+    java_review.setRuleName(violation.rule.name(false)) # rule name is not localized
     java_review.setSwitchedOff(violation.switched_off||false)
     java_review.setMessage(violation.message)
     java_review.setLine(violation.line)