]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2381 Improve the violations WS decorated with reviews
authorFabrice Bellingard <bellingard@gmail.com>
Wed, 27 Apr 2011 12:25:18 +0000 (14:25 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Thu, 28 Apr 2011 13:15:49 +0000 (15:15 +0200)
sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb
sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java
sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java
sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java
sonar-ws-client/src/test/resources/violations/false-positive.json

index c39747fadaf004fafac92fa5a60785d6962471bd..01c7acb2f56f816c8f857c14ba8cd9e11ddfdac7 100644 (file)
@@ -46,7 +46,7 @@ class RuleFailure < ActiveRecord::Base
     json['message'] = message
     json['line'] = line if line && line>=1
     json['priority'] = Sonar::RulePriority.to_s(failure_level).upcase
-    json['falsePositive']=true if false_positive?
+    json['switchedOff']=true if switched_off?
     if created_at
       json['createdAt'] = format_datetime(created_at)
     end
@@ -61,7 +61,7 @@ class RuleFailure < ActiveRecord::Base
       :qualifier => snapshot.project.qualifier,
       :language => snapshot.project.language
     }
-    json['review']=review.id if review
+    json['review']=review.id.to_i if review
     json
   end
 
@@ -70,7 +70,7 @@ class RuleFailure < ActiveRecord::Base
       xml.message(message)
       xml.line(line) if line && line>=1
       xml.priority(Sonar::RulePriority.to_s(failure_level))
-      xml.falsePositive(true) if false_positive?
+      xml.switchedOff(true) if switched_off?
       if created_at
         xml.createdAt(format_datetime(created_at))
       end
@@ -85,7 +85,7 @@ class RuleFailure < ActiveRecord::Base
         xml.qualifier(snapshot.project.qualifier)
         xml.language(snapshot.project.language)
       end
-      xml.review(review.id) if review
+      xml.review(review.id.to_i) if review
     end
   end
 
index 4e170124c6b3c98d58ac872f3275aeffd0675096..d077ac974953098c01fbab3e67a17937947031f8 100644 (file)
@@ -33,7 +33,7 @@ public class Violation extends Model {
   private String resourceScope = null;
   private String resourceQualifier = null;
   private Date createdAt = null;
-  private boolean falsePositive;
+  private boolean switchedOff;
   private Long reviewId = null;
 
   public String getMessage() {
@@ -180,16 +180,16 @@ public class Violation extends Model {
   /**
    * @since 2.8
    */
-  public Violation setFalsePositive(Boolean b) {
-    this.falsePositive = (b != null && b);
+  public Violation setSwitchedOff(Boolean b) {
+    this.switchedOff = (b != null && b);
     return this;
   }
 
   /**
    * @since 2.8
    */
-  public boolean isFalsePositive() {
-    return falsePositive;
+  public boolean isSwitchedOff() {
+    return switchedOff;
   }
 
   public Long getReviewId() {
index 45f692b582c6f5bec613aed36e40e96f9f8e8c94..a73d4b3c4fa9eee6156d0de1c228e95d1bede2b3 100644 (file)
@@ -33,7 +33,7 @@ public class ViolationUnmarshaller extends AbstractUnmarshaller<Violation> {
     violation.setLine(utils.getInteger(json, "line"));
     violation.setSeverity(utils.getString(json, "priority"));
     violation.setCreatedAt(utils.getDateTime(json, "createdAt"));
-    violation.setFalsePositive(utils.getBoolean(json, "falsePositive"));
+    violation.setSwitchedOff(utils.getBoolean(json, "switchedOff"));
     violation.setReviewId(utils.getLong(json, "review"));
 
     Object rule = utils.getField(json, "rule");
index 4652c2cd9d96c326e708ac598909d31a9a0fab06..16e07efff3832f60c54ca4e79d7b69ef44f41504 100644 (file)
@@ -53,7 +53,7 @@ public class ViolationUnmarshallerTest extends UnmarshallerTestCase {
     assertThat(violation.getResourceName(), is("TraceableResourceLimitingPool"));
     assertThat(violation.getResourceQualifier(), is("CLA"));
     assertThat(violation.getResourceScope(), is("FIL"));
-    assertThat(violation.isFalsePositive(), is(false));
+    assertThat(violation.isSwitchedOff(), is(false));
     assertThat(violation.getReviewId(), nullValue());
   }
 
@@ -67,9 +67,9 @@ public class ViolationUnmarshallerTest extends UnmarshallerTestCase {
   }
 
   @Test
-  public void testFalsePositive() {
+  public void testSwitchedOff() {
     Violation violation = new ViolationUnmarshaller().toModel(loadFile("/violations/false-positive.json"));
-    assertThat(violation.isFalsePositive(), is(true));
+    assertThat(violation.isSwitchedOff(), is(true));
     assertThat(violation.getReviewId(), is(123L));
   }
 
index d84cb1528d5886e4756bc033c4a398d2e2e90350..2165e9455c189db925ef3ad0601d04005ebfabe4 100644 (file)
@@ -1,3 +1,3 @@
 [
-  {"message":"throw java.lang.Exception","falsePositive": true, "review": 123, "priority":"MAJOR","rule":{"key":"pmd:SignatureDeclareThrowsException","name":"Signature Declare Throws Exception","category":"Maintainability"},"resource":{"key":"org.apache.excalibur.components:excalibur-pool-instrumented:org.apache.avalon.excalibur.pool.TraceableResourceLimitingPool","name":"TraceableResourceLimitingPool","scope":"FIL","qualifier":"CLA","language":"java"}}
+  {"message":"throw java.lang.Exception","switchedOff": true, "review": 123, "priority":"MAJOR","rule":{"key":"pmd:SignatureDeclareThrowsException","name":"Signature Declare Throws Exception","category":"Maintainability"},"resource":{"key":"org.apache.excalibur.components:excalibur-pool-instrumented:org.apache.avalon.excalibur.pool.TraceableResourceLimitingPool","name":"TraceableResourceLimitingPool","scope":"FIL","qualifier":"CLA","language":"java"}}
 ]
\ No newline at end of file