001/*
002 * SonarQube
003 * Copyright (C) 2009-2016 SonarSource SA
004 * mailto:contact 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 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   * @deprecated since 5.5 use {@link #gap(Double)}
044   */
045  @Deprecated
046  NewIssue effortToFix(@Nullable Double effortToFix);
047
048  /**
049   * Gap used for the computation of the effort. 
050   * @since 5.5
051   */
052  NewIssue gap(@Nullable Double gap);
053
054  /**
055   * Override severity of the issue.
056   * Setting a null value or not calling this method means to use severity configured in quality profile.
057   */
058  NewIssue overrideSeverity(@Nullable Severity severity);
059
060  /**
061   * Primary location for this issue.
062   * @since 5.2
063   */
064  NewIssue at(NewIssueLocation primaryLocation);
065
066  /**
067   * Add a secondary location for this issue. Several secondary locations can be registered.
068   * @since 5.2
069   */
070  NewIssue addLocation(NewIssueLocation secondaryLocation);
071
072  /**
073   * Register a flow for this issue. A flow is an ordered list of issue locations that help to understand the issue.
074   * It could be a path leading to the primary location. Several flows can be registered.
075   * @since 5.2
076   */
077  NewIssue addFlow(Iterable<NewIssueLocation> flowLocations);
078
079  /**
080   * Create a new location for this issue. First registered location is considered as primary location.
081   * @since 5.2
082   */
083  NewIssueLocation newLocation();
084
085  /**
086   * 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
087   * is thrown.
088   */
089  void save();
090
091}