All Downloads are FREE. Search and download functionalities are using the official Maven repository.

resources.report.rules.pmd.EmptyMethodInAbstractClassShouldBeAbstract.html Maven / Gradle / Ivy



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