@@ -52,6 +52,7 @@ date=Date | |||
days=Days | |||
default=Default | |||
delete=Delete | |||
deprecated=Deprecated | |||
descending=Descending | |||
description=Description | |||
directories=Directories |
@@ -54,6 +54,8 @@ define [ | |||
groupedMetrics: -> | |||
metrics = @options.app.metrics | |||
metrics = _.filter metrics, (metric) -> | |||
!metric.hidden | |||
metrics = _.groupBy metrics, 'domain' | |||
metrics = _.map metrics, (metrics, domain) -> | |||
domain: domain, metrics: _.sortBy metrics, 'short_name' |
@@ -1,5 +1,8 @@ | |||
<td nowrap> | |||
{{metric.name}} | |||
{{#if metric.hidden}} | |||
<span class="deprecated">{{t 'deprecated'}}</span> | |||
{{/if}} | |||
</td> | |||
<td width="10%" nowrap> | |||
{{#if canEdit}} |
@@ -229,7 +229,7 @@ public class QualityGates { | |||
return Collections2.filter(metricFinder.findAll(), new Predicate<Metric>() { | |||
@Override | |||
public boolean apply(Metric metric) { | |||
return isAlertable(metric); | |||
return isAvailableForInit(metric); | |||
} | |||
}); | |||
} | |||
@@ -284,8 +284,12 @@ public class QualityGates { | |||
} | |||
} | |||
private boolean isAvailableForInit(Metric metric) { | |||
return !metric.isDataType() && !CoreMetrics.ALERT_STATUS.equals(metric) && ValueType.RATING != metric.getType(); | |||
} | |||
private boolean isAlertable(Metric metric) { | |||
return !metric.isDataType() && BooleanUtils.isFalse(metric.isHidden()) && !CoreMetrics.ALERT_STATUS.equals(metric) && ValueType.RATING != metric.getType(); | |||
return isAvailableForInit(metric) && BooleanUtils.isFalse(metric.isHidden()); | |||
} | |||
private boolean isDefault(QualityGateDto qGate) { |
@@ -19,6 +19,7 @@ | |||
*/ | |||
package org.sonar.server.qualitygate.ws; | |||
import org.apache.commons.lang.BooleanUtils; | |||
import org.sonar.api.i18n.I18n; | |||
import org.sonar.api.measures.Metric; | |||
import org.sonar.api.server.ws.Request; | |||
@@ -46,6 +47,7 @@ public class QgateAppHandler implements RequestHandler { | |||
"create", | |||
"default", | |||
"delete", | |||
"deprecated", | |||
"more", | |||
"name", | |||
"quality_gates.add_condition", | |||
@@ -136,6 +138,7 @@ public class QgateAppHandler implements RequestHandler { | |||
.prop("name", metric.getName()) | |||
.prop("type", metric.getType().toString()) | |||
.prop("domain", metric.getDomain()) | |||
.prop("hidden", BooleanUtils.isNotFalse(metric.isHidden())) | |||
.endObject(); | |||
} | |||
writer.endArray(); |
@@ -104,3 +104,11 @@ | |||
border: 1px solid #ddd; | |||
background-color: #efefef; | |||
} | |||
.quality-gate-conditions { | |||
& .deprecated { | |||
color: #777; | |||
text-transform: lowercase; | |||
font-variant: small-caps; | |||
} | |||
} |
@@ -569,6 +569,6 @@ public class QualityGatesTest { | |||
when(classicMetric.getType()).thenReturn(ValueType.BOOL); | |||
when(metricFinder.findAll()).thenReturn(ImmutableList.of( | |||
dataMetric, hiddenMetric, nullHiddenMetric, alertMetric, ratingMetric, classicMetric)); | |||
assertThat(qGates.gateMetrics()).hasSize(1).containsOnly(classicMetric); | |||
assertThat(qGates.gateMetrics()).hasSize(3).containsOnly(classicMetric, hiddenMetric, nullHiddenMetric); | |||
} | |||
} |
@@ -79,6 +79,7 @@ public class QgateAppHandlerTest { | |||
when(metric.getName()).thenReturn("Metric"); | |||
when(metric.getType()).thenReturn(ValueType.BOOL); | |||
when(metric.getDomain()).thenReturn("General"); | |||
when(metric.isHidden()).thenReturn(false); | |||
when(qGates.gateMetrics()).thenReturn(ImmutableList.of(metric)); | |||
String json = tester.newRequest("app").execute().outputAsString(); | |||
@@ -88,12 +89,18 @@ public class QgateAppHandlerTest { | |||
Collection<Map> periods = (Collection<Map>) responseJson.get("periods"); | |||
assertThat(periods).hasSize(3); | |||
Map messages = (Map) responseJson.get("messages"); | |||
assertThat(messages).isNotNull().isNotEmpty().hasSize(50); | |||
assertThat(messages).isNotNull().isNotEmpty().hasSize(51); | |||
for (Entry message: (Set<Entry>) messages.entrySet()) { | |||
assertThat(message.getKey()).isEqualTo(message.getValue()); | |||
} | |||
Collection<Map> metrics = (Collection<Map>) responseJson.get("metrics"); | |||
assertThat(metrics).hasSize(1); | |||
assertThat(metrics.iterator().next().get("key")).isEqualTo("metric"); | |||
Map metricMap = metrics.iterator().next(); | |||
assertThat(metricMap.get("id").toString()).isEqualTo("42"); | |||
assertThat(metricMap.get("key")).isEqualTo("metric"); | |||
assertThat(metricMap.get("name")).isEqualTo("Metric"); | |||
assertThat(metricMap.get("type")).isEqualTo("BOOL"); | |||
assertThat(metricMap.get("domain")).isEqualTo("General"); | |||
assertThat(metricMap.get("hidden")).isEqualTo(false); | |||
} | |||
} |