diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/FieldSignature.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/FieldSignature.java index 2083fca749..1477c68ff9 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/FieldSignature.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/FieldSignature.java @@ -49,15 +49,11 @@ public final class FieldSignature extends Signature { @Override public boolean equals(Object o) { - if (o instanceof FieldSignature) { - FieldSignature f = (FieldSignature) o; - return super.equals(o) && f.isFinal == isFinal && f.isStatic == isStatic; - } - return false; + return this == o; } @Override public int hashCode() { - return super.hashCode() * 16 + (isStatic ? 1 : 0) * 32 + (isFinal ? 1 : 0); + return (isFinal ? 1 : 0) + super.hashCode() << 3 + (isStatic ? 1 : 0) << 1; } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/OperationSignature.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/OperationSignature.java index e456cf830e..5004bbaecb 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/OperationSignature.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/OperationSignature.java @@ -69,13 +69,12 @@ public final class OperationSignature extends Signature { @Override public boolean equals(Object o) { - return o instanceof OperationSignature && super.equals(o) && role == ((OperationSignature) o).role - && isAbstract == ((OperationSignature) o).isAbstract; + return this == o; } @Override public int hashCode() { - return super.hashCode() * 2 + role.hashCode() * 4 + (isAbstract ? 1 : 0); + return (isAbstract ? 1 : 0) + super.hashCode() << 1 + role.hashCode() << 2; } /** @@ -102,6 +101,7 @@ public final class OperationSignature extends Signature { } } + // TODO:cf clean that up private static boolean isGetterOrSetter(ASTMethodDeclaration node) { String name = node.getName(); if (NAME_PATTERN.matcher(name).matches()) { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/Signature.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/Signature.java index 2cf2873d70..d363dcc849 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/Signature.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/oom/signature/Signature.java @@ -26,7 +26,7 @@ public abstract class Signature { @Override public int hashCode() { - return visibility.hashCode() * 2; + return visibility.hashCode(); } /** diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/oom/metrics/xml/NcssTest.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/oom/metrics/xml/NcssTest.xml index 0dd9d3d71d..8ba0a6b399 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/oom/metrics/xml/NcssTest.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/oom/metrics/xml/NcssTest.xml @@ -1,5 +1,7 @@ + +