avgMeasure(module, targetMetricKey, avgTargetMetricKey, avgMetricKey);
}
private void avgMeasure(Module module, MeasureKey targetMetricKey, MeasureKey avgTargetMetricKey, MeasureKey avgMetricKey) {
if (module.getMeasure(targetMetricKey)==null) {
MetricMeasure avgTargetMeasure = module.getMeasure( avgTargetMetricKey );
MetricMeasure avgMetricMeasure = module.getMeasure( avgMetricKey );
if ( avgTargetMeasure != null && avgMetricMeasure != null && isNotZero(avgMetricMeasure.getValue())) {
Double avgValue = avgTargetMeasure.getValue() / avgMetricMeasure.getValue();
module.createMeasure(targetMetricKey, avgValue);
} else if (avgMetricMeasure != null && !isNotZero(avgMetricMeasure.getValue())) {
MeasureKey missingMeasureKey = avgTargetMeasure == null ? avgTargetMetricKey : avgMetricKey;
String message = "Unable to create avg metric " + targetMetricKey.getMetric() + " for project " +
module.getMavenProject().getArtifactId() + " missing metric " + missingMeasureKey.getMetric();
if ( missingMeasureKey.getFile() != null ) {
message += " for file " + missingMeasureKey.getFile();