3 * Copyright (C) 2009-2019 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.qualitygate;
22 import com.google.common.collect.ImmutableList;
23 import com.google.common.collect.ImmutableSet;
24 import java.util.List;
25 import org.sonar.api.measures.CoreMetrics;
27 import static org.sonar.db.qualitygate.QualityGateConditionDto.OPERATOR_GREATER_THAN;
30 * Offers constants describing the Hardcoded Quality Gate for short living branches and pull requests.
32 public final class ShortLivingBranchQualityGate {
33 public static final long ID = -1_963_456_987L;
34 public static final String NAME = "Hardcoded short living branch quality gate";
35 public static final List<Condition> CONDITIONS = ImmutableList.of(
36 new Condition(CoreMetrics.OPEN_ISSUES_KEY, OPERATOR_GREATER_THAN, "0"),
37 new Condition(CoreMetrics.REOPENED_ISSUES_KEY, OPERATOR_GREATER_THAN, "0"));
39 public static final QualityGate GATE = new QualityGate(String.valueOf(ID), NAME, ImmutableSet.of(
40 new org.sonar.server.qualitygate.Condition(CoreMetrics.OPEN_ISSUES_KEY, org.sonar.server.qualitygate.Condition.Operator.GREATER_THAN, "0"),
41 new org.sonar.server.qualitygate.Condition(CoreMetrics.REOPENED_ISSUES_KEY, org.sonar.server.qualitygate.Condition.Operator.GREATER_THAN, "0")));
43 private ShortLivingBranchQualityGate() {
44 // prevents instantiation
47 public static final class Condition {
48 private final String metricKey;
49 private final String operator;
50 private final String errorThreshold;
52 public Condition(String metricKey, String operator, String errorThreshold) {
53 this.metricKey = metricKey;
54 this.operator = operator;
55 this.errorThreshold = errorThreshold;
58 public String getMetricKey() {
62 public String getOperator() {
66 public String getErrorThreshold() {
67 return errorThreshold;