001    /*
002     * SonarQube, open source software quality management tool.
003     * Copyright (C) 2008-2014 SonarSource
004     * mailto:contact AT sonarsource DOT com
005     *
006     * SonarQube is free software; you can redistribute it and/or
007     * modify it under the terms of the GNU Lesser General Public
008     * License as published by the Free Software Foundation; either
009     * version 3 of the License, or (at your option) any later version.
010     *
011     * SonarQube is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014     * Lesser General Public License for more details.
015     *
016     * You should have received a copy of the GNU Lesser General Public License
017     * along with this program; if not, write to the Free Software Foundation,
018     * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019     */
020    package org.sonar.api.issue;
021    
022    import com.google.common.collect.ImmutableList;
023    import org.sonar.api.rule.RuleKey;
024    
025    import javax.annotation.CheckForNull;
026    
027    import java.io.Serializable;
028    import java.util.Date;
029    import java.util.List;
030    import java.util.Map;
031    
032    /**
033     * @since 3.6
034     */
035    public interface Issue extends Serializable {
036    
037      /**
038       * Maximum number of characters in the message.
039       */
040      int MESSAGE_MAX_SIZE = 4000;
041    
042      /**
043       * Default status when creating an issue.
044       */
045      String STATUS_OPEN = "OPEN";
046      String STATUS_CONFIRMED = "CONFIRMED";
047      String STATUS_REOPENED = "REOPENED";
048      String STATUS_RESOLVED = "RESOLVED";
049      String STATUS_CLOSED = "CLOSED";
050    
051      String RESOLUTION_FIXED = "FIXED";
052    
053      /**
054       * Resolution when issue is flagged as false positive.
055       */
056      String RESOLUTION_FALSE_POSITIVE = "FALSE-POSITIVE";
057    
058      /**
059       * Resolution when rule has been uninstalled or disabled in the Quality profile.
060        */
061      String RESOLUTION_REMOVED = "REMOVED";
062    
063      List<String> RESOLUTIONS = ImmutableList.of(RESOLUTION_FALSE_POSITIVE, RESOLUTION_FIXED, RESOLUTION_REMOVED);
064    
065      /**
066       * Return all available statuses
067       *
068       * @since 4.4
069       */
070      List<String> STATUSES = ImmutableList.of(STATUS_OPEN, STATUS_CONFIRMED, STATUS_REOPENED, STATUS_RESOLVED, STATUS_CLOSED);
071    
072      /**
073       * Unique generated key. It looks like "d2de809c-1512-4ae2-9f34-f5345c9f1a13".
074       */
075      String key();
076    
077      /**
078       * Components are modules ("my_project"), directories ("my_project:my/dir") or files ("my_project:my/file.c").
079       * Keys of Java packages and classes are currently in a special format: "my_project:com.company" and "my_project:com.company.Foo".
080       */
081      String componentKey();
082    
083      RuleKey ruleKey();
084    
085      /**
086       * See constants in {@link org.sonar.api.rule.Severity}.
087       */
088      String severity();
089    
090      @CheckForNull
091      String message();
092    
093      /**
094       * Optional line number. If set, then it's greater than or equal 1.
095       */
096      @CheckForNull
097      Integer line();
098    
099      /**
100       * Arbitrary distance to threshold for resolving the issue.
101       * <p/>
102       * For examples:
103       * <ul>
104       *   <li>for the rule "Avoid too complex methods" : current complexity - max allowed complexity</li>
105       *   <li>for the rule "Avoid Duplications" : number of duplicated blocks</li>
106       *   <li>for the rule "Insufficient Line Coverage" : number of lines to cover to reach the accepted threshold</li>
107       * </ul>
108       */
109      @CheckForNull
110      Double effortToFix();
111    
112      /**
113       * See constant values in {@link Issue}.
114       */
115      String status();
116    
117      /**
118       * The type of resolution, or null if the issue is not resolved. See constant values in {@link Issue}.
119       */
120      @CheckForNull
121      String resolution();
122    
123      /**
124       * Login of the user who reported this issue. Null if the issue is reported by a rule engine.
125       */
126      @CheckForNull
127      String reporter();
128    
129      /**
130       * Login of the user who is assigned to this issue. Null if the issue is not assigned.
131       */
132      @CheckForNull
133      String assignee();
134    
135      Date creationDate();
136    
137      Date updateDate();
138    
139      /**
140       * Date when status was set to {@link Issue#STATUS_CLOSED}, else null.
141       */
142      @CheckForNull
143      Date closeDate();
144    
145      @CheckForNull
146      String attribute(String key);
147    
148      Map<String, String> attributes();
149    
150      /**
151       * Login of the SCM account that introduced this issue. Requires the
152       * <a href="http://www.sonarsource.com/products/plugins/developer-tools/developer-cockpit/">Developer Cockpit Plugin</a> to be installed.
153       */
154      @CheckForNull
155      String authorLogin();
156    
157      @CheckForNull
158      String actionPlanKey();
159    
160      /**
161       * Non-null list of comments, ordered by chronological order.
162       * <p/>
163       * IMPORTANT: existing comments are not loaded when this method is called when analyzing project
164       * (from {@link org.sonar.api.BatchExtension}).
165       */
166      List<IssueComment> comments();
167    
168      /**
169       * During a scan return if the current issue is a new one.
170       * @return always false on server side
171       * @since 4.0
172       */
173      boolean isNew();
174    }