Merge branch 'pr-103'

This commit is contained in:
Andreas Dangel
2016-07-07 22:44:15 +02:00
3 changed files with 46 additions and 1 deletions

View File

@ -166,8 +166,8 @@ public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
entryStack.push( new Entry( node ) );
super.visit( node, data );
Entry classEntry = entryStack.pop();
if ( showClassesComplexity ) {
Entry classEntry = entryStack.pop();
if ( classEntry.getComplexityAverage() >= reportLevel
|| classEntry.highestDecisionPoints >= reportLevel ) {
addViolation( data, node, new String[] {

View File

@ -0,0 +1,42 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.codesize;
import java.io.StringReader;
import java.util.Arrays;
import org.junit.Assert;
import org.junit.Test;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.lang.Parser;
import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.java.JavaLanguageModule;
public class StdCyclomaticComplexityRuleTest {
/**
* Make sure the entry stack is empty, if show classes complexity is disabled.
*
* @see <a href="https://sourceforge.net/p/pmd/bugs/1501/">bug #1501</a>
*/
@Test
public void entryStackMustBeEmpty() {
StdCyclomaticComplexityRule rule = new StdCyclomaticComplexityRule();
rule.setProperty(StdCyclomaticComplexityRule.SHOW_CLASSES_COMPLEXITY_DESCRIPTOR, Boolean.FALSE);
RuleContext ctx = new RuleContext();
LanguageVersion javaLanguageVersion = LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("1.8");
ParserOptions parserOptions = javaLanguageVersion.getLanguageVersionHandler().getDefaultParserOptions();
Parser parser = javaLanguageVersion.getLanguageVersionHandler().getParser(parserOptions);
Node node = parser.parse("test", new StringReader("public class SampleClass {}"));
rule.apply(Arrays.asList(node), ctx);
Assert.assertTrue(rule.entryStack.isEmpty());
}
}

View File

@ -12,9 +12,12 @@
* [#101](https://github.com/pmd/pmd/pull/101): \[java] Improve multithreading performance: do not lock on classloader
* [#102](https://github.com/pmd/pmd/pull/102): \[apex] Restrict AvoidLogicInTrigger rule to max. 1 violation per file
* [#103](https://github.com/pmd/pmd/pull/103): \[java] \[apex] Fix for 1501: CyclomaticComplexity rule causes OOM when class reporting is disabled
**Bugfixes:**
* Java
* [#1501](https://sourceforge.net/p/pmd/bugs/1501/): \[java] \[apex] CyclomaticComplexity rule causes OOM when class reporting is disabled
* General
* [#1499](https://sourceforge.net/p/pmd/bugs/1499/): \[core] CPD test break PMD 5.5.1 build on Windows