forked from phoedos/pmd
Fix build (Apex Metrics)
This commit is contained in:
@ -5,10 +5,9 @@
|
||||
package net.sourceforge.pmd.lang.apex.metrics.impl;
|
||||
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTUserClassOrInterface;
|
||||
import net.sourceforge.pmd.lang.apex.metrics.ApexMetrics;
|
||||
import net.sourceforge.pmd.lang.apex.metrics.api.ApexOperationMetricKey;
|
||||
import net.sourceforge.pmd.lang.metrics.MetricOptions;
|
||||
import net.sourceforge.pmd.lang.metrics.ResultOption;
|
||||
import net.sourceforge.pmd.lang.metrics.MetricsUtil;
|
||||
|
||||
/**
|
||||
* The sum of the cognitive complexities of all the methods within a class.
|
||||
@ -18,6 +17,6 @@ import net.sourceforge.pmd.lang.metrics.ResultOption;
|
||||
public class ClassCognitiveComplexityMetric extends AbstractApexClassMetric {
|
||||
@Override
|
||||
public double computeFor(ASTUserClassOrInterface<?> node, MetricOptions options) {
|
||||
return ApexMetrics.get(ApexOperationMetricKey.COGNITIVE, node, ResultOption.SUM);
|
||||
return MetricsUtil.computeStatistics(ApexOperationMetricKey.COGNITIVE, node.getMethods()).getSum();
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,10 @@ import java.util.Stack;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTUserClass;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTUserTrigger;
|
||||
import net.sourceforge.pmd.lang.apex.metrics.ApexMetrics;
|
||||
import net.sourceforge.pmd.lang.apex.metrics.api.ApexClassMetricKey;
|
||||
import net.sourceforge.pmd.lang.apex.metrics.api.ApexOperationMetricKey;
|
||||
import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule;
|
||||
import net.sourceforge.pmd.lang.metrics.MetricsUtil;
|
||||
import net.sourceforge.pmd.lang.metrics.ResultOption;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
import net.sourceforge.pmd.properties.PropertyFactory;
|
||||
|
||||
@ -66,7 +64,7 @@ public class CognitiveComplexityRule extends AbstractApexRule {
|
||||
int classCognitive = (int) MetricsUtil.computeMetric(ApexClassMetricKey.COGNITIVE, node);
|
||||
|
||||
if (classCognitive >= getProperty(CLASS_LEVEL_DESCRIPTOR)) {
|
||||
int classHighest = (int) ApexMetrics.get(ApexOperationMetricKey.COGNITIVE, node, ResultOption.HIGHEST);
|
||||
int classHighest = (int) MetricsUtil.computeStatistics(ApexOperationMetricKey.COGNITIVE, node.getMethods()).getMax();
|
||||
|
||||
String[] messageParams = {
|
||||
"class",
|
||||
|
Reference in New Issue
Block a user