]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
SONARUNNER-143 New API to retrieve issues produced by the analysis
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 4 Aug 2015 07:25:07 +0000 (09:25 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 4 Aug 2015 07:25:14 +0000 (09:25 +0200)
sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java
sonar-runner-api/src/main/java/org/sonar/runner/api/Issue.java
sonar-runner-api/src/test/java/org/sonar/runner/api/EmbeddedRunnerTest.java
sonar-runner-batch-interface/src/main/java/org/sonar/runner/batch/IssueListener.java
sonar-runner-batch/src/main/java/org/sonar/runner/batch/Compatibility.java

index 6d9f0fea73515a88f236599922a826c537123ab6..7b852abc898042bcbdf7a01048d2041766fedf9c 100644 (file)
@@ -228,14 +228,17 @@ public class EmbeddedRunner {
     private static org.sonar.runner.api.Issue transformIssue(org.sonar.runner.batch.IssueListener.Issue batchIssue) {
       org.sonar.runner.api.Issue.Builder issueBuilder = org.sonar.runner.api.Issue.builder();
 
-      issueBuilder.setAssignee(batchIssue.getAssignee());
+      issueBuilder.setAssigneeLogin(batchIssue.getAssigneeLogin());
+      issueBuilder.setAssigneeName(batchIssue.getAssigneeName());
       issueBuilder.setComponentKey(batchIssue.getComponentKey());
       issueBuilder.setKey(batchIssue.getKey());
       issueBuilder.setLine(batchIssue.getLine());
       issueBuilder.setMessage(batchIssue.getMessage());
       issueBuilder.setNew(batchIssue.isNew());
       issueBuilder.setResolution(batchIssue.getResolution());
-      issueBuilder.setRule(batchIssue.getRule());
+      issueBuilder.setRuleKey(batchIssue.getRuleKey());
+      issueBuilder.setRuleName(batchIssue.getRuleName());
+      issueBuilder.setSeverity(batchIssue.getSeverity());
       issueBuilder.setStatus(batchIssue.getStatus());
 
       return issueBuilder.build();
index eb765ddafafe12e6ae6d8afa24d70897a2651337..23b81e467f7eb69bc70398bfc2eb974e55d03f31 100644 (file)
@@ -27,23 +27,30 @@ public final class Issue {
   private final String componentKey;
   private final Integer line;
   private final String message;
-  private final String rule;
+  private final String ruleKey;
+  private final String ruleName;
   private final String status;
   private final String resolution;
   private final boolean isNew;
-  private final String assignee;
+  private final String assigneeLogin;
+  private final String assigneeName;
+  private final String severity;
 
-  private Issue(String key, String componentKey, Integer line, String message, String rule, String status, String resolution, boolean isNew, String assignee) {
+  private Issue(String key, String componentKey, Integer line, String message, String ruleKey, String ruleName, String status, String resolution, boolean isNew,
+    String assigneeLogin, String assigneeName, String severity) {
     super();
     this.key = key;
     this.componentKey = componentKey;
     this.line = line;
     this.message = message;
-    this.rule = rule;
+    this.ruleKey = ruleKey;
+    this.ruleName = ruleName;
     this.status = status;
     this.resolution = resolution;
     this.isNew = isNew;
-    this.assignee = assignee;
+    this.assigneeLogin = assigneeLogin;
+    this.assigneeName = assigneeName;
+    this.severity = severity;
   }
 
   public static class Builder {
@@ -51,11 +58,14 @@ public final class Issue {
     private String componentKey;
     private Integer line;
     private String message;
-    private String rule;
+    private String ruleKey;
+    private String ruleName;
     private String status;
     private String resolution;
     private boolean isNew;
-    private String assignee;
+    private String assigneeLogin;
+    private String assigneeName;
+    private String severity;
 
     public String getKey() {
       return key;
@@ -93,12 +103,21 @@ public final class Issue {
       return this;
     }
 
-    public String getRule() {
-      return rule;
+    public String getRuleKey() {
+      return ruleKey;
     }
 
-    public Builder setRule(String rule) {
-      this.rule = rule;
+    public Builder setRuleKey(String ruleKey) {
+      this.ruleKey = ruleKey;
+      return this;
+    }
+
+    public String getRuleName() {
+      return ruleKey;
+    }
+
+    public Builder setRuleName(String ruleName) {
+      this.ruleName = ruleName;
       return this;
     }
 
@@ -129,17 +148,35 @@ public final class Issue {
       return this;
     }
 
-    public String getAssignee() {
-      return assignee;
+    public String getAssigneeLogin() {
+      return assigneeLogin;
     }
 
-    public Builder setAssignee(String assignee) {
-      this.assignee = assignee;
+    public Builder setAssigneeLogin(String assigneeLogin) {
+      this.assigneeLogin = assigneeLogin;
+      return this;
+    }
+
+    public String getAssigneeName() {
+      return assigneeName;
+    }
+
+    public Builder setAssigneeName(String assigneeName) {
+      this.assigneeName = assigneeName;
+      return this;
+    }
+
+    public String getSeverity() {
+      return severity;
+    }
+
+    public Builder setSeverity(String severity) {
+      this.severity = severity;
       return this;
     }
 
     public Issue build() {
-      return new Issue(key, componentKey, line, message, rule, status, resolution, isNew, assignee);
+      return new Issue(key, componentKey, line, message, ruleKey, ruleName, status, resolution, isNew, assigneeLogin, assigneeName, severity);
     }
   }
 
@@ -163,8 +200,12 @@ public final class Issue {
     return message;
   }
 
-  public String getRule() {
-    return rule;
+  public String getRuleKey() {
+    return ruleKey;
+  }
+
+  public String getRuleName() {
+    return ruleName;
   }
 
   public String getStatus() {
@@ -179,8 +220,16 @@ public final class Issue {
     return isNew;
   }
 
-  public String getAssignee() {
-    return assignee;
+  public String getAssigneeLogin() {
+    return assigneeLogin;
+  }
+
+  public String getAssigneeName() {
+    return assigneeName;
+  }
+
+  public String getSeverity() {
+    return severity;
   }
 
 }
index 05df62c92d5484c22d195d74141184ea9128aa9c..ea1e6589d345172b31273964c795c4b3fd0416ca 100644 (file)
@@ -172,11 +172,11 @@ public class EmbeddedRunnerTest {
     IssueListenerAdapter adapter = new IssueListenerAdapter(apiIssueListener);
 
     org.sonar.runner.batch.IssueListener.Issue batchIssue = new org.sonar.runner.batch.IssueListener.Issue();
-    batchIssue.setAssignee("assignee");
+    batchIssue.setAssigneeName("assignee");
     adapter.handle(batchIssue);
 
     assertThat(issuesRecorded).hasSize(1);
-    assertThat(issuesRecorded.get(0).getAssignee()).isEqualTo("assignee");
+    assertThat(issuesRecorded.get(0).getAssigneeName()).isEqualTo("assignee");
   }
 
   @Test(expected = IllegalArgumentException.class)
index da59d804e192ba4e9d40cc59ad381340b8d3d406..f6b596fd172ef854e75420fc9992269c8b08d843 100644 (file)
@@ -27,82 +27,109 @@ public interface IssueListener {
     private String componentKey;
     private Integer line;
     private String message;
-    private String rule;
+    private String ruleKey;
+    private String ruleName;
     private String status;
     private String resolution;
     private boolean isNew;
-    private String assignee;
+    private String assigneeLogin;
+    private String assigneeName;
+    private String severity;
+
+    public String getSeverity() {
+      return severity;
+    }
+
+    public void setSeverity(String severity) {
+      this.severity = severity;
+    }
+
+    public String getKey() {
+      return key;
+    }
 
     public void setKey(String key) {
       this.key = key;
     }
 
+    public String getComponentKey() {
+      return componentKey;
+    }
+
     public void setComponentKey(String componentKey) {
       this.componentKey = componentKey;
     }
 
+    public Integer getLine() {
+      return line;
+    }
+
     public void setLine(Integer line) {
       this.line = line;
     }
 
+    public String getMessage() {
+      return message;
+    }
+
     public void setMessage(String message) {
       this.message = message;
     }
 
-    public void setRule(String rule) {
-      this.rule = rule;
+    public String getRuleKey() {
+      return ruleKey;
     }
 
-    public void setStatus(String status) {
-      this.status = status;
+    public void setRuleKey(String ruleKey) {
+      this.ruleKey = ruleKey;
     }
 
-    public void setResolution(String resolution) {
-      this.resolution = resolution;
+    public String getRuleName() {
+      return ruleName;
     }
 
-    public void setNew(boolean isNew) {
-      this.isNew = isNew;
+    public void setRuleName(String ruleName) {
+      this.ruleName = ruleName;
     }
 
-    public void setAssignee(String assignee) {
-      this.assignee = assignee;
+    public String getStatus() {
+      return status;
     }
 
-    public String getKey() {
-      return key;
+    public void setStatus(String status) {
+      this.status = status;
     }
 
-    public String getComponentKey() {
-      return componentKey;
+    public String getResolution() {
+      return resolution;
     }
 
-    public Integer getLine() {
-      return line;
+    public void setResolution(String resolution) {
+      this.resolution = resolution;
     }
 
-    public String getMessage() {
-      return message;
+    public boolean isNew() {
+      return isNew;
     }
 
-    public String getRule() {
-      return rule;
+    public void setNew(boolean isNew) {
+      this.isNew = isNew;
     }
 
-    public String getStatus() {
-      return status;
+    public String getAssigneeLogin() {
+      return assigneeLogin;
     }
 
-    public String getResolution() {
-      return resolution;
+    public void setAssigneeLogin(String assigneeLogin) {
+      this.assigneeLogin = assigneeLogin;
     }
 
-    public boolean isNew() {
-      return isNew;
+    public String getAssigneeName() {
+      return assigneeName;
     }
 
-    public String getAssignee() {
-      return assignee;
+    public void setAssigneeName(String assigneeName) {
+      this.assigneeName = assigneeName;
     }
 
   }
index 99eb70c9ae709b076009c23d62fd7a353eb3b2ac..f37e1b92f44ace0a738ffce02dbf719dcebbe916 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.runner.batch;
 
-import org.sonar.api.issue.Issue;
 import org.sonar.batch.bootstrapper.Batch;
 import org.sonar.batch.bootstrapper.LogOutput;
 
@@ -57,15 +56,20 @@ public class Compatibility {
 
     private static IssueListener.Issue transformIssue(Issue batchIssue) {
       IssueListener.Issue newIssue = new IssueListener.Issue();
-      newIssue.setAssignee(batchIssue.assignee());
-      newIssue.setComponentKey(batchIssue.componentKey());
-      newIssue.setKey(batchIssue.key());
-      newIssue.setResolution(batchIssue.resolution());
-      newIssue.setRule(batchIssue.ruleKey().toString());
-      newIssue.setMessage(batchIssue.message());
+
+      newIssue.setAssigneeLogin(batchIssue.getAssigneeLogin());
+      newIssue.setAssigneeName(batchIssue.getAssigneeName());
+      newIssue.setComponentKey(batchIssue.getComponentKey());
+      newIssue.setKey(batchIssue.getKey());
+      newIssue.setResolution(batchIssue.getResolution());
+      newIssue.setRuleKey(batchIssue.getRuleKey());
+      newIssue.setRuleName(batchIssue.getRuleName());
+      newIssue.setMessage(batchIssue.getMessage());
       newIssue.setNew(batchIssue.isNew());
-      newIssue.setLine(batchIssue.line());
-      
+      newIssue.setLine(batchIssue.getLine());
+      newIssue.setSeverity(batchIssue.getSeverity());
+      newIssue.setStatus(batchIssue.getStatus());
+
       return newIssue;
     }
   }