001/*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2013 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 */
020package org.sonar.api.issue;
021
022import com.google.common.collect.ImmutableList;
023import org.sonar.api.rule.RuleKey;
024import org.sonar.api.technicaldebt.TechnicalDebt;
025
026import javax.annotation.CheckForNull;
027
028import java.io.Serializable;
029import java.util.Date;
030import java.util.List;
031import java.util.Map;
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  List<String> RESOLUTIONS = ImmutableList.of(RESOLUTION_FALSE_POSITIVE, RESOLUTION_FIXED, RESOLUTION_REMOVED);
065
066  /**
067   * Unique generated key. It looks like "d2de809c-1512-4ae2-9f34-f5345c9f1a13".
068   */
069  String key();
070
071  /**
072   * Components are modules ("my_project"), directories ("my_project:my/dir") or files ("my_project:my/file.c").
073   * Keys of Java packages and classes are currently in a special format: "my_project:com.company" and "my_project:com.company.Foo".
074   */
075  String componentKey();
076
077  RuleKey ruleKey();
078
079  /**
080   * See constants in {@link org.sonar.api.rule.Severity}.
081   */
082  String severity();
083
084  @CheckForNull
085  String message();
086
087  /**
088   * Optional line number. If set, then it's greater than or equal 1.
089   */
090  @CheckForNull
091  Integer line();
092
093  /**
094   * Arbitrary distance to threshold for resolving the issue.
095   * <p/>
096   * For examples:
097   * <ul>
098   *   <li>for the rule "Avoid too complex methods" : current complexity - max allowed complexity</li>
099   *   <li>for the rule "Avoid Duplications" : number of duplicated blocks</li>
100   *   <li>for the rule "Insufficient Line Coverage" : number of lines to cover to reach the accepted threshold</li>
101   * </ul>
102   */
103  @CheckForNull
104  Double effortToFix();
105
106  /**
107   * Elapsed time in minutes to fix the issue
108   */
109  @CheckForNull
110  TechnicalDebt technicalDebt();
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}