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