Skip to content

Files

Latest commit

 

History

History
33 lines (22 loc) · 842 Bytes

EmptyMethod.md

File metadata and controls

33 lines (22 loc) · 842 Bytes

Pattern: Empty method

Issue: -

Description

A method was found without an implementation. If the method is overriding or implementing a parent method, then mark it with the @Override annotation. This rule should not be used with Java 5 code because you cannot put @Override on a method implementing an interface. Use with Java 6 and higher.

Example of violations:

class SomeClass {

    // violation, empty method
    public void method1() {}

    // violation, empty method
    def method2() {}

    // OK because of @Override
    @Override
    public void method3() {}
}

abstract class SomeBaseClass {
    // OK, handled by EmptyMethodInAbstractClass Rule
    public void method() {}
}

Further Reading