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