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 */ 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.BatchSide; 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 * Arbitrary distance to threshold for resolving the issue. 110 * <p/> 111 * For examples: 112 * <ul> 113 * <li>for the rule "Avoid too complex methods" : current complexity - max allowed complexity</li> 114 * <li>for the rule "Avoid Duplications" : number of duplicated blocks</li> 115 * <li>for the rule "Insufficient Line Coverage" : number of lines to cover to reach the accepted threshold</li> 116 * </ul> 117 */ 118 @CheckForNull 119 Double effortToFix(); 120 121 /** 122 * See constant values in {@link Issue}. 123 */ 124 String status(); 125 126 /** 127 * The type of resolution, or null if the issue is not resolved. See constant values in {@link Issue}. 128 */ 129 @CheckForNull 130 String resolution(); 131 132 /** 133 * Login of the user who reported this issue. Null if the issue is reported by a rule engine. 134 */ 135 @CheckForNull 136 String reporter(); 137 138 /** 139 * Login of the user who is assigned to this issue. Null if the issue is not assigned. 140 */ 141 @CheckForNull 142 String assignee(); 143 144 Date creationDate(); 145 146 Date updateDate(); 147 148 /** 149 * Date when status was set to {@link Issue#STATUS_CLOSED}, else null. 150 */ 151 @CheckForNull 152 Date closeDate(); 153 154 @CheckForNull 155 String attribute(String key); 156 157 /** 158 * Empty on batch side since version 5.2. Attributes are moved to server's Compute Engine. No use-case for keeping them 159 * on batch side for now 160 */ 161 Map<String, String> attributes(); 162 163 /** 164 * Login of the SCM account that introduced this issue. Requires the 165 * <a href="http://www.sonarsource.com/products/plugins/developer-tools/developer-cockpit/">Developer Cockpit Plugin</a> to be installed. 166 */ 167 @CheckForNull 168 String authorLogin(); 169 170 @CheckForNull 171 String actionPlanKey(); 172 173 /** 174 * Non-null list of comments, ordered by chronological order. 175 * <p/> 176 * IMPORTANT: existing comments are not loaded when this method is called when analyzing project 177 * (from {@link BatchSide}). 178 */ 179 List<IssueComment> comments(); 180 181 /** 182 * During a scan return if the current issue is a new one. 183 * @return always false on server side 184 * @since 4.0 185 */ 186 boolean isNew(); 187 188 /** 189 * @since 5.0 190 */ 191 @CheckForNull 192 Duration debt(); 193 194 /** 195 * @since 5.0 196 */ 197 String projectKey(); 198 199 /** 200 * @since 5.0 201 */ 202 String projectUuid(); 203 204 /** 205 * @since 5.0 206 */ 207 String componentUuid(); 208 209 /** 210 * @since 5.1 211 */ 212 Collection<String> tags(); 213}