resources.report.rules.pmd.EmptyMethodInAbstractClassShouldBeAbstract.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sanity4j Show documentation
Show all versions of sanity4j Show documentation
Sanity4J was created to simplify running multiple static code
analysis tools on the Java projects. It provides a single entry
point to run all the selected tools and produce a consolidated
report, which presents all findings in an easily accessible
manner.
EmptyMethodInAbstractClassShouldBeAbstract
EmptyMethodInAbstractClassShouldBeAbstract
Empty or auto-generated methods in an abstract class should be tagged as abstract. This helps to remove their inapproprate usage by developers who should be implementing their own versions in the concrete subclasses.
//ClassOrInterfaceDeclaration[@Abstract = 'true']
/ClassOrInterfaceBody
/ClassOrInterfaceBodyDeclaration
/MethodDeclaration[@Abstract = 'false' and @Native = 'false']
[
( boolean(./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral) = 'true' )
or
( boolean(./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal[@Image = '0']) = 'true' )
or
( boolean(./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal[string-length(@Image) = 2]) = 'true' )
or
(./Block[count(./BlockStatement) = 1]/BlockStatement/Statement/EmptyStatement)
or
( count (./Block/*) = 0 )
]
Example(s):
public abstract class ShouldBeAbstract {
public Object couldBeAbstract() {
// Should be abstract method ?
return null;
}
public void couldBeAbstract() {
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy