List<ProjectMeasure> measures = new ArrayList<ProjectMeasure>();
try {
Integer classesCount = ( (Number)ckjmXpath.evaluate("count(/ckjm/class)", ckjmDocument, XPathConstants.NUMBER ) ).intValue();
Integer wmcCount = ( (Number)ckjmXpath.evaluate("sum(/ckjm/class/wmc/text())", ckjmDocument, XPathConstants.NUMBER ) ).intValue();
measures.add( new ProjectMeasure( loadMetric( Metrics.CK_WMC ), scaleValue( wmcCount.doubleValue() / classesCount ) ) );
Integer ditCount = ( (Number)ckjmXpath.evaluate("sum(/ckjm/class/dit/text())", ckjmDocument, XPathConstants.NUMBER ) ).intValue();
measures.add( new ProjectMeasure( loadMetric( Metrics.CK_DIT), scaleValue( ditCount.doubleValue() / classesCount ) ) );
Integer nocCount = ( (Number)ckjmXpath.evaluate("sum(/ckjm/class/noc/text())", ckjmDocument, XPathConstants.NUMBER ) ).intValue();
measures.add( new ProjectMeasure( loadMetric( Metrics.CK_NOC), scaleValue( nocCount.doubleValue() / classesCount ) ) );
Integer cboCount = ( (Number)ckjmXpath.evaluate("sum(/ckjm/class/cbo/text())", ckjmDocument, XPathConstants.NUMBER ) ).intValue();
measures.add( new ProjectMeasure( loadMetric( Metrics.CK_CBO), scaleValue( cboCount.doubleValue() / classesCount ) ) );
Integer rfcCount = ( (Number)ckjmXpath.evaluate("sum(/ckjm/class/rfc/text())", ckjmDocument, XPathConstants.NUMBER ) ).intValue();
measures.add( new ProjectMeasure( loadMetric( Metrics.CK_RFC), scaleValue( rfcCount.doubleValue() / classesCount ) ) );
Integer lcomCount = ( (Number)ckjmXpath.evaluate("sum(/ckjm/class/lcom/text())", ckjmDocument, XPathConstants.NUMBER ) ).intValue();
measures.add( new ProjectMeasure( loadMetric( Metrics.CK_LCOM), scaleValue( lcomCount.doubleValue() / classesCount ) ) );
Integer caCount = ( (Number)ckjmXpath.evaluate("sum(/ckjm/class/ca/text())", ckjmDocument, XPathConstants.NUMBER ) ).intValue();
measures.add( new ProjectMeasure( loadMetric( Metrics.CK_CA), scaleValue( caCount.doubleValue() / classesCount ) ) );
Integer npmCount = ( (Number)ckjmXpath.evaluate("sum(/ckjm/class/npm/text())", ckjmDocument, XPathConstants.NUMBER ) ).intValue();
measures.add( new ProjectMeasure(loadMetric( Metrics.CK_NPM), scaleValue( npmCount.doubleValue() / classesCount ) ) );
} catch (Exception ex) {
throw new MojoExecutionException("Error during CK report parsing", ex);
}
return measures;