Menu

#550 AbstractClassWithoutAbstractMethod to match description

open
nobody
None
5
2012-10-07
2010-06-15
No

The description of this rule seems to say that this would be OK condition if the class only had protected or private constructors, We actually wanted to allow for that case, but the rule as provided did not allow. I updated a custom version with this xpath to allow abstract class with no abstract methods if there are no public constructors. You should make this something that could be turned on/off if there is a desire to maintain backward compatibility. Here is my xpath

    <property name="xpath">
        <value><![CDATA[

//ClassOrInterfaceDeclaration
[@Abstract='true'
and count( .//MethodDeclaration[@Abstract='true']
)=0 ]
[count(ImplementsList)=0]
[count(.//ExtendsList)=0]
[count(ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Public='true']) > 0 ]
[count(ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Protected='true' or Private='true' or @PackagePrivate='true']) = 0]
]]>

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.