forked from phoedos/pmd
Implemented CompareObjectsWithEquals and put it in the design ruleset; it misses some cases, but it's a start
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@3589 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -87,7 +87,7 @@ public class LocalScopeTest extends STBBaseTst {
|
||||
ASTLocalVariableDeclaration node = (ASTLocalVariableDeclaration)acu.findChildrenOfType(ASTLocalVariableDeclaration.class).get(0);
|
||||
LocalScope scope = (LocalScope)node.getScope();
|
||||
MethodScope ms = scope.getEnclosingMethodScope();
|
||||
|
||||
assertEquals(2, ms.getVariableDeclarations().size());
|
||||
}
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ public class LocalScopeTest extends STBBaseTst {
|
||||
|
||||
public static final String TEST4 =
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" void foo(String x) { int y; }" + PMD.EOL +
|
||||
" void foo(String x, String z) { int y; }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -32,25 +32,6 @@ public class Foo {
|
||||
</rule>
|
||||
|
||||
-->
|
||||
|
||||
<rule name="CompareObjectsWithEquals"
|
||||
message="Use equals() to compare object references."
|
||||
class="net.sourceforge.pmd.rules.design.CompareObjectsWithEquals">
|
||||
<description>
|
||||
Use equals() to compare object references; don't compare them with ==.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
class Foo {
|
||||
boolean bar(String a, String b) {
|
||||
return a == b;
|
||||
}
|
||||
}
|
||||
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user