Merge branch 'pr-799'

This commit is contained in:
Juan Martín Sotuyo Dodero
2017-12-21 00:35:48 -03:00
3 changed files with 16 additions and 1 deletions

View File

@@ -23,6 +23,8 @@ This is a bug fixing release.
* apex-errorprone
* [#792](https://github.com/pmd/pmd/issues/792): \[apex] AvoidDirectAccessTriggerMap incorrectly detects array access in classes
* apex-security
* [#788](https://github.com/pmd/pmd/issues/788): \[apex] Method chaining breaks ApexCRUDViolation
* java-design
* [#785](https://github.com/pmd/pmd/issues/785): \[java] NPE in DataClass rule
@@ -31,3 +33,4 @@ This is a bug fixing release.
### External Contributions
* [#796](https://github.com/pmd/pmd/pull/796): \[apex] AvoidDirectAccessTriggerMap incorrectly detects array access in classes - [Robert Sösemann](https://github.com/up2go-rsoesemann)
* [#799](https://github.com/pmd/pmd/pull/799): \[apex] Method chaining breaks ApexCRUDViolation - [Robert Sösemann](https://github.com/up2go-rsoesemann)

View File

@@ -322,7 +322,7 @@ public class ApexCRUDViolationRule extends AbstractApexRule {
private boolean isLastMethodName(final ASTMethodCallExpression methodNode, final String className,
final String methodName) {
final ASTReferenceExpression reference = methodNode.getFirstChildOfType(ASTReferenceExpression.class);
if (reference.getNode().getNames().size() > 0) {
if (reference != null && reference.getNode().getNames().size() > 0) {
if (reference.getNode().getNames().get(reference.getNode().getNames().size() - 1).getValue()
.equalsIgnoreCase(className) && Helper.isMethodName(methodNode, methodName)) {
return true;

View File

@@ -812,6 +812,18 @@ public class Foo {
public list<A.B[]> bar;
public map<Id,A.B[]> baz;
}
]]></code>
</test-code>
<test-code>
<description>Regression issue #799 detection</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
void chainedMethods() {
firstMethod().lastMethod();
}
}
]]></code>
</test-code>
</test-data>