001/*
002 * SonarQube
003 * Copyright (C) 2009-2017 SonarSource SA
004 * mailto:info AT sonarsource DOT com
005 *
006 * This program 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 * This program 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 */
020package org.sonar.api.issue;
021
022import java.io.Serializable;
023import java.util.Collection;
024import java.util.Date;
025import java.util.List;
026import java.util.Map;
027import javax.annotation.CheckForNull;
028import org.sonar.api.batch.ScannerSide;
029import org.sonar.api.rule.RuleKey;
030import org.sonar.api.utils.Duration;
031
032import static java.util.Arrays.asList;
033
034/**
035 * @since 3.6
036 */
037public interface Issue extends Serializable {
038
039  /**
040   * Maximum number of characters in the message.
041   */
042  int MESSAGE_MAX_SIZE = 4000;
043
044  /**
045   * Default status when creating an issue.
046   */
047  String STATUS_OPEN = "OPEN";
048  String STATUS_CONFIRMED = "CONFIRMED";
049  String STATUS_REOPENED = "REOPENED";
050  String STATUS_RESOLVED = "RESOLVED";
051  String STATUS_CLOSED = "CLOSED";
052
053  String RESOLUTION_FIXED = "FIXED";
054
055  /**
056   * Resolution when issue is flagged as false positive.
057   */
058  String RESOLUTION_FALSE_POSITIVE = "FALSE-POSITIVE";
059
060  /**
061   * Resolution when rule has been uninstalled or disabled in the Quality profile.
062    */
063  String RESOLUTION_REMOVED = "REMOVED";
064
065  /**
066   * Issue is irrelevant in the context and was muted by user.
067   * @since 5.1
068   */
069  String RESOLUTION_WONT_FIX = "WONTFIX";
070
071  List<String> RESOLUTIONS = asList(RESOLUTION_FALSE_POSITIVE, RESOLUTION_WONT_FIX, RESOLUTION_FIXED, RESOLUTION_REMOVED);
072
073  /**
074   * Return all available statuses
075   *
076   * @since 4.4
077   */
078  List<String> STATUSES = asList(STATUS_OPEN, STATUS_CONFIRMED, STATUS_REOPENED, STATUS_RESOLVED, STATUS_CLOSED);
079
080  /**
081   * Unique generated key. It looks like "d2de809c-1512-4ae2-9f34-f5345c9f1a13".
082   */
083  String key();
084
085  /**
086   * Components are modules ("my_project"), directories ("my_project:my/dir") or files ("my_project:my/file.c").
087   * Keys of Java packages and classes are currently in a special format: "my_project:com.company" and "my_project:com.company.Foo".
088   */
089  String componentKey();
090
091  RuleKey ruleKey();
092
093  String language();
094
095  /**
096   * See constants in {@link org.sonar.api.rule.Severity}.
097   */
098  String severity();
099
100  @CheckForNull
101  String message();
102
103  /**
104   * Optional line number. If set, then it's greater than or equal 1.
105   */
106  @CheckForNull
107  Integer line();
108
109  /**
110   * @deprecated since 5.5, replaced by {@link #gap()}
111   */
112  @Deprecated
113  @CheckForNull
114  Double effortToFix();
115
116  /**
117   * Arbitrary distance to threshold for resolving the issue.
118   * <br>
119   * For examples:
120   * <ul>
121   *   <li>for the rule "Avoid too complex methods" : current complexity - max allowed complexity</li>
122   *   <li>for the rule "Avoid Duplications" : number of duplicated blocks</li>
123   *   <li>for the rule "Insufficient Line Coverage" : number of lines to cover to reach the accepted threshold</li>
124   * </ul>
125   *
126   * @since 5.5
127   */
128  @CheckForNull
129  Double gap();
130
131  /**
132   * See constant values in {@link Issue}.
133   */
134  String status();
135
136  /**
137   * The type of resolution, or null if the issue is not resolved. See constant values in {@link Issue}.
138   */
139  @CheckForNull
140  String resolution();
141
142  /**
143   * @deprecated since 5.5, manual issue feature has been dropped.
144   */
145  @Deprecated
146  @CheckForNull
147  String reporter();
148
149  /**
150   * Login of the user who is assigned to this issue. Null if the issue is not assigned.
151   */
152  @CheckForNull
153  String assignee();
154
155  Date creationDate();
156
157  Date updateDate();
158
159  /**
160   * Date when status was set to {@link Issue#STATUS_CLOSED}, else null.
161   */
162  @CheckForNull
163  Date closeDate();
164
165  @CheckForNull
166  String attribute(String key);
167
168  /**
169   * Empty on batch side since version 5.2. Attributes are moved to server's Compute Engine. No use-case for keeping them
170   * on batch side for now
171   */
172  Map<String, String> attributes();
173
174  /**
175   * Login of the SCM account that introduced this issue. Requires the
176   * <a href="http://www.sonarsource.com/products/plugins/developer-tools/developer-cockpit/">Developer Cockpit Plugin</a> to be installed.
177   */
178  @CheckForNull
179  String authorLogin();
180
181  /**
182   * @deprecated since 5.5 Action plans are dropped in 5.5. This field has no effect
183   */
184  @Deprecated
185  @CheckForNull
186  String actionPlanKey();
187
188  /**
189   * Non-null list of comments, ordered by chronological order.
190   * <br>
191   * IMPORTANT: existing comments are not loaded when this method is called when analyzing project
192   * (from {@link ScannerSide}).
193   */
194  List<IssueComment> comments();
195
196  /**
197   * During a scan return if the current issue is a new one.
198   * @return always false on server side
199   * @since 4.0
200   */
201  boolean isNew();
202
203  /**
204   * @deprecated since 5.5, replaced by {@link #effort()}
205   */
206  @Deprecated
207  Duration debt();
208
209  /**
210   * @since 5.5
211   */
212  @CheckForNull
213  Duration effort();
214
215  /**
216   * @since 5.0
217   */
218  String projectKey();
219
220  /**
221   * @since 5.0
222   */
223  String projectUuid();
224
225  /**
226   * @since 5.0
227   */
228  String componentUuid();
229
230  /**
231   * @since 5.1
232   */
233  Collection<String> tags();
234}