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 */ 020 package org.sonar.api.batch.sensor.issue; 021 022 import com.google.common.annotations.Beta; 023 import org.sonar.api.batch.fs.InputDir; 024 import org.sonar.api.batch.fs.InputFile; 025 import org.sonar.api.batch.fs.InputPath; 026 import org.sonar.api.batch.sensor.Sensor; 027 import org.sonar.api.rule.RuleKey; 028 029 import javax.annotation.CheckForNull; 030 import javax.annotation.Nullable; 031 032 /** 033 * Represents an issue detected by a {@link Sensor}. 034 * 035 * @since 5.0 036 */ 037 @Beta 038 public interface Issue { 039 040 public enum Severity { 041 INFO, 042 MINOR, 043 MAJOR, 044 CRITICAL, 045 BLOCKER; 046 } 047 048 /** 049 * The {@link RuleKey} of the issue. 050 */ 051 Issue ruleKey(RuleKey ruleKey); 052 053 /** 054 * The {@link RuleKey} of this issue. 055 */ 056 RuleKey ruleKey(); 057 058 /** 059 * The {@link InputFile} the issue belongs to. For global issues call {@link #onProject()}. 060 */ 061 Issue onFile(InputFile file); 062 063 /** 064 * The {@link InputDir} the issue belongs to. For global issues call {@link #onProject()}. 065 */ 066 Issue onDir(InputDir inputDir); 067 068 /** 069 * Tell that the issue is global to the project. 070 */ 071 Issue onProject(); 072 073 /** 074 * The {@link InputPath} this issue belongs to. Returns null if issue is global to the project. 075 */ 076 @CheckForNull 077 InputPath inputPath(); 078 079 /** 080 * Line of the issue. Only available for {@link #onFile(InputFile)} issues. 081 * If no line is specified it means that issue is global to the file. 082 */ 083 Issue atLine(int line); 084 085 /** 086 * Line of the issue. Null for global issues and issues on directories. Can also be null 087 * for files (issue global to the file). 088 */ 089 @CheckForNull 090 Integer line(); 091 092 /** 093 * Effort to fix the issue. 094 */ 095 Issue effortToFix(@Nullable Double effortToFix); 096 097 /** 098 * Effort to fix the issue. Used by technical debt model. 099 */ 100 @CheckForNull 101 Double effortToFix(); 102 103 /** 104 * Message of the issue. 105 */ 106 Issue message(String message); 107 108 /** 109 * Message of the issue. 110 */ 111 @CheckForNull 112 String message(); 113 114 /** 115 * Override severity of the issue. 116 * Setting a null value or not calling this method means to use severity configured in quality profile. 117 */ 118 Issue overrideSeverity(@Nullable Severity severity); 119 120 /** 121 * Overriden severity. 122 */ 123 @CheckForNull 124 Severity overridenSeverity(); 125 126 /** 127 * Save the issue. If rule key is unknow or rule not enabled in the current quality profile then a warning is logged but no exception 128 * is thrown. 129 */ 130 void save(); 131 132 }