diff options
author | DDMili <130993898+dejan-milisavljevic-sonarsource@users.noreply.github.com> | 2024-05-30 16:53:11 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-06-03 20:02:58 +0000 |
commit | 836c5a30998402fdf4a59f21fcc5ab1daf91eb0d (patch) | |
tree | 5f4643b4ba0864752bec0330268ef66e3bfd0bca /server/sonar-server-common | |
parent | ce591fc631120e68eb0a0a266ba1c2036c4ca373 (diff) | |
download | sonarqube-836c5a30998402fdf4a59f21fcc5ab1daf91eb0d.tar.gz sonarqube-836c5a30998402fdf4a59f21fcc5ab1daf91eb0d.zip |
SONAR-22224 live update metric
Diffstat (limited to 'server/sonar-server-common')
2 files changed, 79 insertions, 0 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/metric/IssueCountMetrics.java b/server/sonar-server-common/src/main/java/org/sonar/server/metric/IssueCountMetrics.java new file mode 100644 index 00000000000..1776c05019d --- /dev/null +++ b/server/sonar-server-common/src/main/java/org/sonar/server/metric/IssueCountMetrics.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.server.metric; + +import java.util.List; +import org.sonar.api.measures.Metric; +import org.sonar.api.measures.Metrics; + +import static org.sonar.api.measures.CoreMetrics.DOMAIN_ISSUES; + +public class IssueCountMetrics implements Metrics { + + public static final String PRIORITIZED_RULE_ISSUES_KEY = "prioritized_rule_issues"; + public static final Metric<Integer> PRIORITIZED_RULE_ISSUES = new Metric.Builder( + PRIORITIZED_RULE_ISSUES_KEY, "Issues from prioritized rules", Metric.ValueType.INT) + .setDescription("Count of issues that have a flag Prioritized Rule.") + .setDirection(Metric.DIRECTION_WORST) + .setQualitative(true) + .setDomain(DOMAIN_ISSUES) + .setBestValue(0.0) + .setOptimizedBestValue(true) + .create(); + + @Override + public List<Metric> getMetrics() { + return List.of(PRIORITIZED_RULE_ISSUES); + } +} diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/metric/IssueCountMetricsTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/metric/IssueCountMetricsTest.java new file mode 100644 index 00000000000..8d1147e909a --- /dev/null +++ b/server/sonar-server-common/src/test/java/org/sonar/server/metric/IssueCountMetricsTest.java @@ -0,0 +1,34 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.server.metric; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.sonar.server.metric.IssueCountMetrics.PRIORITIZED_RULE_ISSUES; + +class IssueCountMetricsTest { + @Test + void getMetrics() { + assertThat(new IssueCountMetrics().getMetrics()) + .containsExactlyInAnyOrder(PRIORITIZED_RULE_ISSUES); + } + +} |