记录当时使用PMD, FindBugs等静态代码扫描工具中有用的Tips。有些看上去很细,不是很能注意到,也不影响使用。但是对于提高代码质量,对于提高对语言的理解,从发明语言者的角度去思考。。。
UnusedModifier
Since: PMD 1.02
Fields in interfaces are automatically public static final, and methods are public abstract. Classes or interfaces nested in an interface are automatically public and static (all nested interfaces are automatically static). For historical reasons, modifiers which are implied by the context are accepted by the compiler, but are superfluous.
This rule is defined by the following Java class: net.sourceforge.pmd.rules.UnusedModifier
Example:
public interface Foo { public abstract void bar(); // both abstract and public are ignored by the compiler public static final int X = 0; // public, static, and final all ignored public static class Bar {} // public, static ignored public static interface Baz {} // ditto } public class Bar { public static interface Baz {} // static ignored }