Browse Source

SONAR-16039 added new metric analysis_from_sonarqube_9_4

tags/9.4.0.54424
Lukasz Jarocki 2 years ago
parent
commit
b7df67a2d8

+ 21
- 0
sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java View File

@@ -26,6 +26,8 @@ import java.util.List;
import java.util.NoSuchElementException;
import org.sonar.api.utils.SonarException;

import static org.sonar.api.measures.Metric.ValueType.BOOL;

/**
* @since 1.10
*/
@@ -1809,6 +1811,25 @@ public final class CoreMetrics {
.setHidden(true)
.create();

/**
* @since 9.4
*/
public static final String ANALYSIS_FROM_SONARQUBE_9_4_KEY = "analysis_from_sonarqube_9_4";

/**
* @since 9.4
*
* This hidden metric that is only needed to fully fix the issue with identifying new issues when using reference branch
* that was haunting us in 9.3 and before. More details in the ticket SONAR-16039
*/
public static final Metric<Integer> ANALYSIS_FROM_SONARQUBE_9_4 = new Metric.Builder(ANALYSIS_FROM_SONARQUBE_9_4_KEY,
"Analysis From SonarQube 9.4", BOOL)
.setDescription("Indicates whether the analysis has been run after the upgrade to SonarQube 9.4. It affects how the issues " +
"will be detected for branches that use reference branch as the strategy for detecting new code.")
.setDomain(CoreMetrics.DOMAIN_ISSUES)
.setHidden(true)
.create();

private static final List<Metric> METRICS;

static {

+ 1
- 1
sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java View File

@@ -681,7 +681,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a
}

/**
* Sets whether the metric should be hidden in Web UI (e.g. in Time Machine). Default is false.
* Sets whether the metric should be hidden in Web UI. Default is false.
*
* @param b true if the metric should be hidden.
* @return the builder

+ 6
- 0
sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java View File

@@ -51,4 +51,10 @@ public class CoreMetricsTest {
assertThatThrownBy(() -> getMetric("unknown"))
.isInstanceOf(NoSuchElementException.class);
}

@Test
public void someMetricsAreMeantToBeHidden() {
Metric metric = getMetric("analysis_from_sonarqube_9_4");
assertThat(metric.isHidden()).isTrue();
}
}

Loading…
Cancel
Save