days=Days
default=Default
delete=Delete
+deprecated=Deprecated
descending=Descending
description=Description
directories=Directories
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'
<td nowrap>
{{metric.name}}
+ {{#if metric.hidden}}
+ <span class="deprecated">{{t 'deprecated'}}</span>
+ {{/if}}
</td>
<td width="10%" nowrap>
{{#if canEdit}}
return Collections2.filter(metricFinder.findAll(), new Predicate<Metric>() {
@Override
public boolean apply(Metric metric) {
- return isAlertable(metric);
+ return isAvailableForInit(metric);
}
});
}
}
}
+ 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) {
*/
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;
"create",
"default",
"delete",
+ "deprecated",
"more",
"name",
"quality_gates.add_condition",
.prop("name", metric.getName())
.prop("type", metric.getType().toString())
.prop("domain", metric.getDomain())
+ .prop("hidden", BooleanUtils.isNotFalse(metric.isHidden()))
.endObject();
}
writer.endArray();
border: 1px solid #ddd;
background-color: #efefef;
}
+
+.quality-gate-conditions {
+ & .deprecated {
+ color: #777;
+ text-transform: lowercase;
+ font-variant: small-caps;
+ }
+}
\ No newline at end of file
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);
}
}
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();
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);
}
}