org.sonar.api.issue
Interface Issuable

All Superinterfaces:
Perspective

public interface Issuable
extends Perspective

This perspective allows to add and get issues related to the selected component. It can be used from Sensors and Decorators. Web extensions must use RubyIssueService.

Example:

   import org.sonar.api.component.ResourcePerspectives;
   public class MySensor extends Sensor {
     private final ResourcePerspectives perspectives;

     public MySensor(ResourcePerspectives p) {
       this.perspectives = p;
     }

     public void analyse(Project project, SensorContext context) {
       Resource myResource; // to be set
       Issuable issuable = perspectives.as(Issuable.class, myResource);
       if (issuable != null) {
         // can be used
         Issue issue = issuable.newIssueBuilder()
           .setRuleKey(RuleKey.of("pmd", "AvoidArrayLoops")
           .setLine(10)
           .build();
         issuable.addIssue(issue);
       }
     }
   }
 

Since:
3.6

Nested Class Summary
static interface Issuable.IssueBuilder
           
 
Method Summary
 boolean addIssue(Issue issue)
          Register an issue created with newIssueBuilder().
 List<Issue> issues()
          Unresolved issues, including the issues reported by end-users.
 Issuable.IssueBuilder newIssueBuilder()
          Builder is used to create the issue to be passed to addIssue(Issue)
 List<Issue> resolvedIssues()
          Issues marked as resolved during this scan.
 
Methods inherited from interface org.sonar.api.component.Perspective
component
 

Method Detail

newIssueBuilder

Issuable.IssueBuilder newIssueBuilder()
Builder is used to create the issue to be passed to addIssue(Issue)


addIssue

boolean addIssue(Issue issue)
Register an issue created with newIssueBuilder().

This method is usually called from Sensors. Decorators calling this method must be annotated with @DependedUpon(DecoratorBarriers.ISSUES_ADDED).

Returns:
true if the new issue is registered, false if the related rule does not exist or is disabled in the Quality profile.

issues

List<Issue> issues()
Unresolved issues, including the issues reported by end-users.

Decorators calling this method must be annotated with @DependsUpon(DecoratorBarriers.ISSUES_TRACKED).


resolvedIssues

List<Issue> resolvedIssues()
Issues marked as resolved during this scan.

Decorators calling this method must be annotated with @DependsUpon(DecoratorBarriers.ISSUES_TRACKED).



Copyright © 2009-2013 SonarSource. All Rights Reserved.