Interface Redundant Modifiers

ID

java.interface_redundant_modifiers

Severity

high

Remediation Complexity

medium

Remediation Risk

low

Remediation Effort

medium

Resource

Code Smell

Language

Java

Tags

code-style

Description

Reports interface methods that explicitly declare public or abstract modifiers.

Rationale

All non-default, non-static methods declared in a Java interface are implicitly public abstract. Restating those modifiers is redundant noise that suggests the author is unaware of the language defaults. This can mislead maintainers about visibility or concreteness guarantees and adds unnecessary clutter to the codebase.

// Bad - redundant modifiers
interface Service {
    public void start();
    abstract void stop();
    public abstract void restart();
}

// Good - no redundant modifiers
interface Service {
    void start();
    void stop();
    void restart();
}

Default and static methods are excluded from this check, as they are not implicitly abstract.

Remediation

Remove the public and abstract keywords from interface method declarations. The compiler infers them automatically.