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 org.sonar.api.batch.fs.InputDir; 024import org.sonar.api.batch.fs.InputFile; 025import org.sonar.api.batch.sensor.Sensor; 026import org.sonar.api.batch.sensor.issue.Issue.Severity; 027import org.sonar.api.rule.RuleKey; 028 029import javax.annotation.Nullable; 030 031/** 032 * Represents an issue detected by a {@link Sensor}. 033 * 034 * @since 5.1 035 */ 036@Beta 037public interface NewIssue { 038 039 /** 040 * The {@link RuleKey} of the issue. 041 */ 042 NewIssue forRule(RuleKey ruleKey); 043 044 /** 045 * The {@link InputFile} the issue belongs to. For global issues call {@link #onProject()}. 046 */ 047 NewIssue onFile(InputFile file); 048 049 /** 050 * The {@link InputDir} the issue belongs to. For global issues call {@link #onProject()}. 051 */ 052 NewIssue onDir(InputDir inputDir); 053 054 /** 055 * Tell that the issue is global to the project. 056 */ 057 NewIssue onProject(); 058 059 /** 060 * Line of the issue. Only available for {@link #onFile(InputFile)} issues. 061 * If no line is specified it means that issue is global to the file. 062 */ 063 NewIssue atLine(int line); 064 065 /** 066 * Effort to fix the issue. 067 */ 068 NewIssue effortToFix(@Nullable Double effortToFix); 069 070 /** 071 * Message of the issue. 072 */ 073 NewIssue message(String message); 074 075 /** 076 * Override severity of the issue. 077 * Setting a null value or not calling this method means to use severity configured in quality profile. 078 */ 079 NewIssue overrideSeverity(@Nullable Severity severity); 080 081 /** 082 * 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 083 * is thrown. 084 */ 085 void save(); 086 087}