forked from phoedos/pmd
Applied patch 3155140: Exclude boolean getters (is*) from
TooManyMethods rule. Thanks to Riku Nykanen. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.3.x@7353 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
parent
9487afa38f
commit
d0f2ec451a
@ -4,6 +4,7 @@ Add options --ignore-literals and --ignore-identifiers to the CPD command line t
|
||||
Fixed character reference in xml report - thanks to Seko
|
||||
Add C# support for CPD - thanks to Florian Bauer
|
||||
Fix small bug in Rule Designer UI
|
||||
Improve TooManyMethods rule - thanks to a patch from Riku Nykanen
|
||||
|
||||
New Rule:
|
||||
basic: DontCallThreadRun - thanks to Andy Throgmorton
|
||||
|
@ -58,26 +58,32 @@ Less than 10 methods, with getter/setter...
|
||||
<expected-problems>0</expected-problems>
|
||||
<code>
|
||||
<![CDATA[
|
||||
public class Foo
|
||||
{
|
||||
public void setMethod1(){}
|
||||
public void setMethod2(){}
|
||||
public void setMethod3(){}
|
||||
public void setMethod4(){}
|
||||
public void setMethod5(){}
|
||||
|
||||
public void getMethod6(){}
|
||||
public void getMethod7(){}
|
||||
public void getMethod8(){}
|
||||
public void getMethod9(){}
|
||||
public void getMethod10(){}
|
||||
|
||||
public void method11(){}
|
||||
public void method12(){}
|
||||
public void method13(){}
|
||||
public void method14(){}
|
||||
public void method15(){}
|
||||
public void method16(){}
|
||||
public class Foo {
|
||||
public void setMethod1(){}
|
||||
public void setMethod2(){}
|
||||
public void setMethod3(){}
|
||||
public void setMethod4(){}
|
||||
public void setMethod5(){}
|
||||
|
||||
public void getMethod6(){}
|
||||
public void getMethod7(){}
|
||||
public void getMethod8(){}
|
||||
public void getMethod9(){}
|
||||
public void getMethod10(){}
|
||||
|
||||
public boolean isMethod11(){}
|
||||
public boolean isMethod12(){}
|
||||
public boolean isMethod13(){}
|
||||
public boolean isMethod14(){}
|
||||
public boolean isMethod15(){}
|
||||
public boolean isMethod16(){}
|
||||
|
||||
public void method17(){}
|
||||
public void method18(){}
|
||||
public void method19(){}
|
||||
public void method20(){}
|
||||
public void method21(){}
|
||||
public void method22(){}
|
||||
}
|
||||
]]>
|
||||
</code>
|
||||
|
@ -338,8 +338,8 @@ public class Foo extends Bar {
|
||||
externalInfoUrl="http://pmd.sourceforge.net/rules/codesize.html#TooManyMethods">
|
||||
<description>
|
||||
<![CDATA[
|
||||
A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to
|
||||
have more fine grained objects.
|
||||
A class with too many methods is probably a good target for refactoring, in
|
||||
order to reduce its complexity and find a way to have more fine grained objects.
|
||||
]]>
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
@ -350,28 +350,34 @@ have more fine grained objects.
|
||||
<!-- FIXME: Refine XPath to discard 'get' and 'set' methods with Block no more than 3 lines,
|
||||
something like this:
|
||||
not (
|
||||
(
|
||||
starts-with(@Image,'get')
|
||||
or
|
||||
starts-with(@Image,'set')
|
||||
)
|
||||
and ( (
|
||||
(../Block/attribute::endLine)
|
||||
-
|
||||
(../Block/attribute::beginLine) ) <= 3 )
|
||||
)
|
||||
(
|
||||
starts-with(@Image,'get')
|
||||
or
|
||||
starts-with(@Image,'set')
|
||||
or
|
||||
starts-with(@Image,'is')
|
||||
)
|
||||
and (
|
||||
(
|
||||
(../Block/attribute::endLine)
|
||||
-
|
||||
(../Block/attribute::beginLine)
|
||||
) <= 3
|
||||
)
|
||||
)
|
||||
This will avoid discarding 'real' method...
|
||||
-->
|
||||
<![CDATA[
|
||||
//ClassOrInterfaceDeclaration/ClassOrInterfaceBody
|
||||
[
|
||||
count(descendant::MethodDeclarator[
|
||||
not
|
||||
(
|
||||
not (
|
||||
starts-with(@Image,'get')
|
||||
or
|
||||
or
|
||||
starts-with(@Image,'set')
|
||||
)
|
||||
or
|
||||
starts-with(@Image,'is')
|
||||
)
|
||||
]) > $maxmethods
|
||||
]
|
||||
]]>
|
||||
@ -379,9 +385,4 @@ have more fine grained objects.
|
||||
</property>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
|
||||
</ruleset>
|
||||
|
||||
|
||||
|
||||
|
@ -320,6 +320,7 @@
|
||||
<li>Jared Bunting - Patch to add ASTAnnotationMethodDeclaration to Java AST</li>
|
||||
<li>Lucian Ciufudean - RedundantFieldInitializerRule</li>
|
||||
<li>Andreas Dangel - GodClass and LawOfDemeter rules, several bugfixes and cleanup</li>
|
||||
<li>Riku Nykanen - patch improving TooManyMethods rule</li>
|
||||
</ul>
|
||||
</subsection>
|
||||
<subsection name="Organizations">
|
||||
|
Loading…
x
Reference in New Issue
Block a user