[java] Cyclomatic complexity is misreported (lack of clearing metrics cache)
Fixes #1984
This commit is contained in:
@ -23,6 +23,7 @@ import net.sourceforge.pmd.lang.java.ast.JavaNode;
|
||||
import net.sourceforge.pmd.lang.java.ast.MethodLikeNode;
|
||||
import net.sourceforge.pmd.lang.java.dfa.DataFlowFacade;
|
||||
import net.sourceforge.pmd.lang.java.dfa.JavaDFAGraphRule;
|
||||
import net.sourceforge.pmd.lang.java.metrics.JavaMetrics;
|
||||
import net.sourceforge.pmd.lang.java.metrics.JavaMetricsComputer;
|
||||
import net.sourceforge.pmd.lang.java.metrics.api.JavaClassMetricKey;
|
||||
import net.sourceforge.pmd.lang.java.metrics.api.JavaOperationMetricKey;
|
||||
@ -178,6 +179,10 @@ public abstract class AbstractJavaHandler extends AbstractLanguageVersionHandler
|
||||
super(ASTAnyTypeDeclaration.class, MethodLikeNode.class, JavaMetricsComputer.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
JavaMetrics.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends MetricKey<ASTAnyTypeDeclaration>> getAvailableTypeMetrics() {
|
||||
|
@ -38,8 +38,11 @@ public final class JavaMetrics {
|
||||
}
|
||||
|
||||
|
||||
/** Resets the entire data structure. Used for tests. */
|
||||
static void reset() {
|
||||
/**
|
||||
* Resets the entire data structure.
|
||||
* This needs to be done in case PMD is executed multiple times within one JVM run.
|
||||
*/
|
||||
public static void reset() {
|
||||
FACADE.reset();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user