001/* 002 * SonarQube 003 * Copyright (C) 2009-2017 SonarSource SA 004 * mailto:info AT sonarsource DOT com 005 * 006 * This program 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 * This program 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.batch.sensor.issue; 021 022import javax.annotation.Nullable; 023import org.sonar.api.batch.rule.Severity; 024import org.sonar.api.batch.sensor.Sensor; 025import org.sonar.api.rule.RuleKey; 026 027/** 028 * Represents an issue detected by a {@link Sensor}. 029 * 030 * @since 5.1 031 */ 032public interface NewIssue { 033 034 /** 035 * The {@link RuleKey} of the issue. 036 */ 037 NewIssue forRule(RuleKey ruleKey); 038 039 /** 040 * Effort to fix the issue. 041 * @deprecated since 5.5 use {@link #gap(Double)} 042 */ 043 @Deprecated 044 NewIssue effortToFix(@Nullable Double effortToFix); 045 046 /** 047 * Gap used for the computation of the effort. 048 * @since 5.5 049 */ 050 NewIssue gap(@Nullable Double gap); 051 052 /** 053 * Override severity of the issue. 054 * Setting a null value or not calling this method means to use severity configured in quality profile. 055 */ 056 NewIssue overrideSeverity(@Nullable Severity severity); 057 058 /** 059 * Primary location for this issue. 060 * @since 5.2 061 */ 062 NewIssue at(NewIssueLocation primaryLocation); 063 064 /** 065 * Add a secondary location for this issue. Several secondary locations can be registered. 066 * @since 5.2 067 */ 068 NewIssue addLocation(NewIssueLocation secondaryLocation); 069 070 /** 071 * Register a flow for this issue. A flow is an ordered list of issue locations that help to understand the issue. 072 * It should be a <b>path that backtracks the issue from its primary location to the start of the flow</b>. 073 * Several flows can be registered. 074 * @since 5.2 075 */ 076 NewIssue addFlow(Iterable<NewIssueLocation> flowLocations); 077 078 /** 079 * Create a new location for this issue. First registered location is considered as primary location. 080 * @since 5.2 081 */ 082 NewIssueLocation newLocation(); 083 084 /** 085 * Save the issue. If rule key is unknown or rule not enabled in the current quality profile then a warning is logged but no exception 086 * is thrown. 087 */ 088 void save(); 089 090}