/*
* SonarQube, open source software quality management tool.
* Copyright (C) 2008-2014 SonarSource
* mailto:contact AT sonarsource DOT com
*
* SonarQube is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* SonarQube is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.plugins.core.issue;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Metric;
import org.sonar.api.rules.RulePriority;
final class SeverityUtils {
private SeverityUtils() {
// only static methods
}
static Metric severityToIssueMetric(RulePriority severity) {
Metric metric;
if (severity.equals(RulePriority.BLOCKER)) {
metric = CoreMetrics.BLOCKER_VIOLATIONS;
} else if (severity.equals(RulePriority.CRITICAL)) {
metric = CoreMetrics.CRITICAL_VIOLATIONS;
} else if (severity.equals(RulePriority.MAJOR)) {
metric = CoreMetrics.MAJOR_VIOLATIONS;
} else if (severity.equals(RulePriority.MINOR)) {
metric = CoreMetrics.MINOR_VIOLATIONS;
} else if (severity.equals(RulePriority.INFO)) {
metric = CoreMetrics.INFO_VIOLATIONS;
} else {
throw new IllegalArgumentException("Unsupported severity: " + severity);
}
return metric;
}
static Metric severityToNewMetricIssue(RulePriority severity) {
Metric metric;
if (severity.equals(RulePriority.BLOCKER)) {
metric = CoreMetrics.NEW_BLOCKER_VIOLATIONS;
} else if (severity.equals(RulePriority.CRITICAL)) {
metric = CoreMetrics.NEW_CRITICAL_VIOLATIONS;
} else if (severity.equals(RulePriority.MAJOR)) {
metric = CoreMetrics.NEW_MAJOR_VIOLATIONS;
} else if (severity.equals(RulePriority.MINOR)) {
metric = CoreMetrics.NEW_MINOR_VIOLATIONS;
} else if (severity.equals(RulePriority.INFO)) {
metric = CoreMetrics.NEW_INFO_VIOLATIONS;
} else {
throw new IllegalArgumentException("Unsupported severity: " + severity);
}
return metric;
}
}