nucandrei nucandrei - 1 month ago 14
Java Question

It is possible to get a warning if a interface method has redundant modifiers in Eclipse?

As you probably know, methods in interfaces are by default public abstract.

The JLS7 says: "It is permitted, but discouraged as a matter of style, to redundantly specify the public and/or abstract modifier for a method declared in an interface."

Is there any option in Eclipse to generate warnings if existing interface methods have redundant modifiers? I didn't find any option in Preferences -> Java -> Compiler -> Errors / Warnings

Intellij IDEA has a similar feature, turned on by default.

I found some similar questions but they deal with code generation:

Eclipse generating useless 'public abstract' modifier in interface method signatures

eclipse refactoring - pull up method to interface

Eclipse fixed bug:

[code style] don't generate redundant modifiers

Regards.

Answer

Based on ΦXocę 웃 Пepeúpa ツ comment, I found out that there is an Eclipse plug-in, called SonarLint, that can connect to a SonarQube instance and mark detected problems in Java editor.