Merge branch 'pr-188'

Closes #188 (rebased onto pmd/5.5.x)
This commit is contained in:
Andreas Dangel
2017-01-15 19:49:43 +01:00
4 changed files with 33 additions and 7 deletions

View File

@ -16,7 +16,6 @@ import net.sourceforge.pmd.lang.apex.ast.ASTReturnStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTThrowStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTTryCatchFinallyBlockStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTVariableDeclaration;
import net.sourceforge.pmd.lang.apex.ast.ASTWhileLoopStatement;
import net.sourceforge.pmd.lang.apex.ast.ApexNode;
import net.sourceforge.pmd.lang.apex.rule.AbstractStatisticalApexRule;
@ -158,13 +157,8 @@ public abstract class AbstractNcssCountRule extends AbstractStatisticalApexRule
return NumericConstants.ONE;
}
@Override
public Object visit(ASTVariableDeclaration node, Object data) {
return countNodeChildren(node, data);
}
@Override
public Object visit(ASTMethodCallExpression node, Object data) {
return countNodeChildren(node, data);
return NumericConstants.ONE;
}
}

View File

@ -144,6 +144,13 @@ public class ApexOpenRedirectRule extends AbstractApexRule {
}
}
private void addVariable(AbstractApexNode<?> node) {
ASTVariableExpression variable = node.getFirstChildOfType(ASTVariableExpression.class);
if (variable != null) {
listOfStringLiteralVariables.add(Helper.getFQVariableName(variable));
}
}
/**
* Traverses all new declarations to find PageReferences
*

View File

@ -103,5 +103,28 @@ public class Foo {
}
]]></code>
</test-code>
<test-code>
<description>Github issue #183 - lines are counted properly</description>
<rule-property name="minimum">10</rule-property>
<expected-problems>0</expected-problems>
<code>
@isTest
private class AcceptanceTests_Test {
@isTest
private static void test() {
// Setup
Opportunity o1 = new Opportunity()
.add(new Contact().foo(1) .bar(1).year(2012) .bar(1).price(5) .vol(100))
.add(new Contact().foo(1) .bar(2).year(2013) .bar(1).price(5) .vol(110))
.add(new Contact().foo(1) .bar(3).year(2014) .bar(1).price(5) .vol(120))
.add(new Contact().foo(1) .bar(4).year(2015) .bar(1).price(5) .vol(130))
.persist();
// Verify
System.assert(attribute());
}
}
</code>
</test-code>
</test-data>

View File

@ -218,6 +218,8 @@ to avoid XSS attacks.
* [#1542](https://sourceforge.net/p/pmd/bugs/1542/): \[java] CPD throws an NPE when parsing enums with -ignore-identifiers
* apex-apexunit
* [#1543](https://sourceforge.net/p/pmd/bugs/1543/): \[apex] ApexUnitTestClassShouldHaveAsserts assumes APEX is case sensitive
* apex-complexity
* [#183](https://github.com/pmd/pmd/issues/183): \[apex] NCSS Method length is incorrect when using method chaining
* Java
* [#1545](https://sourceforge.net/p/pmd/bugs/1545/): \[java] Symbol Table fails to resolve inner classes
* java-design