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 021package org.sonar.api.server.debt; 022 023import javax.annotation.CheckForNull; 024 025/** 026 * Function used to calculate the remediation cost of an issue. There are three types : 027 * <ul> 028 * <li> 029 * <b>Linear</b> - Each issue of the rule costs the same amount of time (coefficient) to fix. 030 * </li> 031 * <li> 032 * <b>Linear with offset</b> - It takes a certain amount of time to analyze the issues of such kind on the file (offset). 033 * Then, each issue of the rule costs the same amount of time (coefficient) to fix. Total remediation cost 034 * by file = offset + (number of issues x coefficient) 035 * </li> 036 * <li><b>Constant/issue</b> - The cost to fix all the issues of the rule is the same whatever the number of issues 037 * of this rule in the file. Total remediation cost by file = constant 038 * </li> 039 * </ul> 040 * 041 * @since 4.3 042 */ 043public interface DebtRemediationFunction { 044 045 enum Type { 046 LINEAR(true, false), LINEAR_OFFSET(true, true), CONSTANT_ISSUE(false, true); 047 048 private final boolean usesCoefficient; 049 private final boolean usesOffset; 050 051 Type(boolean usesCoefficient, boolean usesOffset) { 052 this.usesCoefficient = usesCoefficient; 053 this.usesOffset = usesOffset; 054 } 055 056 public boolean usesCoefficient() { 057 return usesCoefficient; 058 } 059 060 public boolean usesOffset() { 061 return usesOffset; 062 } 063 } 064 065 Type type(); 066 067 /** 068 * Factor is set on types {@link Type#LINEAR} and {@link Type#LINEAR_OFFSET}, else it's null. 069 */ 070 @CheckForNull 071 String coefficient(); 072 073 /** 074 * Offset is set on types {@link Type#LINEAR_OFFSET} and {@link Type#CONSTANT_ISSUE}, else it's null. 075 */ 076 @CheckForNull 077 String offset(); 078 079}