Skeleton implementation of CognativeComplexityVisitor
This commit is contained in:
2 files changed
+34
No files matched your search
+20
@@ -0,0 +1,20 @@
|
||||
package net.sourceforge.pmd.lang.apex.metrics.impl;
|
||||
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
|
||||
import net.sourceforge.pmd.lang.apex.metrics.impl.visitors.CognitiveComplexityVisitor;
|
||||
import net.sourceforge.pmd.lang.metrics.MetricOptions;
|
||||
|
||||
/**
|
||||
* Measures the cognitive complexity of a Class / Method in Apex.
|
||||
*
|
||||
* See https://www.sonarsource.com/docs/CognitiveComplexity.pdf for information about the metric
|
||||
*
|
||||
* @author Gwilym Kuiper
|
||||
*/
|
||||
public class CognitiveComplexityMetric extends AbstractApexOperationMetric {
|
||||
@Override
|
||||
public double computeFor(ASTMethod node, MetricOptions options) {
|
||||
CognitiveComplexityVisitor.State resultingState = (CognitiveComplexityVisitor.State) node.jjtAccept(new CognitiveComplexityVisitor(), new CognitiveComplexityVisitor.State());
|
||||
return resultingState.getComplexity();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package net.sourceforge.pmd.lang.apex.metrics.impl.visitors;
|
||||
|
||||
import net.sourceforge.pmd.lang.apex.ast.*;
|
||||
|
||||
/**
|
||||
* @author Gwilym Kuiper
|
||||
*/
|
||||
public class CognitiveComplexityVisitor extends ApexParserVisitorAdapter {
|
||||
public static class State {
|
||||
public double getComplexity() {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user