Skip to content

Files

Latest commit

 

History

History
23 lines (15 loc) · 948 Bytes

MissingOverrideAnnotation.md

File metadata and controls

23 lines (15 loc) · 948 Bytes

Pattern: Missing @Override annotation

Issue: -

Description

Checks for methods that override a method in a superclass or implement a method in an interface but are not annotated with @Override.

Consistent use of @Override annotation helps in spotting situations when the intent was to override a method but because of a mistake in method signature that is not the case. Additionally, applying @Override annotation to all overridden methods helps in spotting unnecessary methods which no longer override any methods after removing them from superclasses or implemented interfaces because such annotated methods will cause compilation errors.

Example of violation:

class ClassOverridingToString {
    String toString() {
      "ClassOverridingToString"
    }
}

Further Reading