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;
024
025import javax.annotation.CheckForNull;
026
027import java.io.Serializable;
028import java.util.Date;
029import java.util.List;
030import java.util.Map;
031
032/**
033 * @since 3.6
034 */
035public 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   * Unique generated key. It looks like "d2de809c-1512-4ae2-9f34-f5345c9f1a13".
067   */
068  String key();
069
070  /**
071   * Components are modules ("my_project"), directories ("my_project:my/dir") or files ("my_project:my/file.c").
072   * Keys of Java packages and classes are currently in a special format: "my_project:com.company" and "my_project:com.company.Foo".
073   */
074  String componentKey();
075
076  RuleKey ruleKey();
077
078  /**
079   * See constants in {@link org.sonar.api.rule.Severity}.
080   */
081  String severity();
082
083  @CheckForNull
084  String message();
085
086  /**
087   * Optional line number. If set, then it's greater than or equal 1.
088   */
089  @CheckForNull
090  Integer line();
091
092  /**
093   * Arbitrary distance to threshold for resolving the issue.
094   * <p/>
095   * For examples:
096   * <ul>
097   *   <li>for the rule "Avoid too complex methods" : current complexity - max allowed complexity</li>
098   *   <li>for the rule "Avoid Duplications" : number of duplicated blocks</li>
099   *   <li>for the rule "Insufficient Line Coverage" : number of lines to cover to reach the accepted threshold</li>
100   * </ul>
101   */
102  @CheckForNull
103  Double effortToFix();
104
105  /**
106   * See constant values in {@link Issue}.
107   */
108  String status();
109
110  /**
111   * The type of resolution, or null if the issue is not resolved. See constant values in {@link Issue}.
112   */
113  @CheckForNull
114  String resolution();
115
116  /**
117   * Login of the user who reported this issue. Null if the issue is reported by a rule engine.
118   */
119  @CheckForNull
120  String reporter();
121
122  /**
123   * Login of the user who is assigned to this issue. Null if the issue is not assigned.
124   */
125  @CheckForNull
126  String assignee();
127
128  Date creationDate();
129
130  Date updateDate();
131
132  /**
133   * Date when status was set to {@link Issue#STATUS_CLOSED}, else null.
134   */
135  @CheckForNull
136  Date closeDate();
137
138  @CheckForNull
139  String attribute(String key);
140
141  Map<String, String> attributes();
142
143  /**
144   * Login of the SCM account that introduced this issue. Requires the
145   * <a href="http://www.sonarsource.com/products/plugins/developer-tools/developer-cockpit/">Developer Cockpit Plugin</a> to be installed.
146   */
147  @CheckForNull
148  String authorLogin();
149
150  @CheckForNull
151  String actionPlanKey();
152
153  /**
154   * Non-null list of comments, ordered by chronological order.
155   * <p/>
156   * IMPORTANT: existing comments are not loaded when this method is called when analyzing project
157   * (from {@link org.sonar.api.BatchExtension}).
158   */
159  List<IssueComment> comments();
160
161  /**
162   * During a scan return if the current issue is a new one.
163   * @return always false on server side
164   * @since 4.0
165   */
166  boolean isNew();
167}