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/trunk@7349 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -57,30 +57,37 @@ Less than 10 methods, with getter/setter...
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code>
|
||||
<![CDATA[
|
||||
<![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 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>
|
||||
]]>
|
||||
</code>
|
||||
</test-code>
|
||||
|
||||
</test-data>
|
||||
|
@ -363,28 +363,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
|
||||
(
|
||||
starts-with(@Image,'get')
|
||||
or
|
||||
starts-with(@Image,'set')
|
||||
)
|
||||
not (
|
||||
starts-with(@Image,'get')
|
||||
or
|
||||
starts-with(@Image,'set')
|
||||
or
|
||||
starts-with(@Image,'is')
|
||||
)
|
||||
]) > $maxmethods
|
||||
]
|
||||
]]>
|
||||
|
@ -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">
|
||||
|
Reference in New Issue
Block a user