From 235e5f4160016fca2075950b161cdf7af20b19eb Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 19 Mar 2020 12:37:53 +0100 Subject: [PATCH] Fix build (Apex Metrics) --- .../apex/metrics/impl/ClassCognitiveComplexityMetric.java | 5 ++--- .../pmd/lang/apex/rule/design/CognitiveComplexityRule.java | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/ClassCognitiveComplexityMetric.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/ClassCognitiveComplexityMetric.java index 90e0527c14..3193727c30 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/ClassCognitiveComplexityMetric.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/ClassCognitiveComplexityMetric.java @@ -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(); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityRule.java index 319afdd529..5c4018404c 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityRule.java @@ -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",