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