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