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.batch.sensor.issue; 021 022import com.google.common.annotations.Beta; 023import javax.annotation.Nullable; 024import org.sonar.api.batch.rule.Severity; 025import org.sonar.api.batch.sensor.Sensor; 026import org.sonar.api.rule.RuleKey; 027 028/** 029 * Represents an issue detected by a {@link Sensor}. 030 * 031 * @since 5.1 032 */ 033@Beta 034public interface NewIssue { 035 036 /** 037 * The {@link RuleKey} of the issue. 038 */ 039 NewIssue forRule(RuleKey ruleKey); 040 041 /** 042 * Effort to fix the issue. 043 */ 044 NewIssue effortToFix(@Nullable Double effortToFix); 045 046 /** 047 * Override severity of the issue. 048 * Setting a null value or not calling this method means to use severity configured in quality profile. 049 */ 050 NewIssue overrideSeverity(@Nullable Severity severity); 051 052 /** 053 * Primary location for this issue. 054 * @since 5.2 055 */ 056 NewIssue at(NewIssueLocation primaryLocation); 057 058 /** 059 * Add a secondary location for this issue. Several secondary locations can be registered. 060 * @since 5.2 061 */ 062 NewIssue addLocation(NewIssueLocation secondaryLocation); 063 064 /** 065 * Register a flow for this issue. A flow is an ordered list of issue locations that help to understand the issue. 066 * It could be a path leading to the primary location. Several flows can be registered. 067 * @since 5.2 068 */ 069 NewIssue addFlow(Iterable<NewIssueLocation> flowLocations); 070 071 /** 072 * Create a new location for this issue. First registered location is considered as primary location. 073 * @since 5.2 074 */ 075 NewIssueLocation newLocation(); 076 077 /** 078 * 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 079 * is thrown. 080 */ 081 void save(); 082 083}