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

import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import org.sonar.api.utils.SonarException; import org.sonar.api.utils.SonarException;


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

/** /**
* @since 1.10 * @since 1.10
*/ */
.setHidden(true) .setHidden(true)
.create(); .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; private static final List<Metric> METRICS;


static { static {

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

} }


/** /**
* 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. * @param b true if the metric should be hidden.
* @return the builder * @return the builder

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

assertThatThrownBy(() -> getMetric("unknown")) assertThatThrownBy(() -> getMetric("unknown"))
.isInstanceOf(NoSuchElementException.class); .isInstanceOf(NoSuchElementException.class);
} }

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

Loading…
Cancel
Save