RedundantModifierCompactSource
Since Checkstyle 14.4.0
Description
RedundantModifier.
The check reports public, protected, private, static, final, and strictfp on direct methods. It reports public, protected, private, and static on direct fields.
A final, static, or private modifier is retained when removing it would make a variable-arity method annotated with @SafeVarargs invalid. An invalid fixed-arity use of @SafeVarargs does not prevent final from being reported.
Only fields and methods whose immediate parent is a compact compilation unit are checked. Use RedundantModifier for declarations in ordinary and nested types.
Examples
To configure the check:
<module name="Checker">
<module name="TreeWalker">
<module name="RedundantModifierCompactSource"/>
</module>
</module>
Example:
public static void process() {}
// 2 violations above:
// 'Redundant 'public' modifier on a direct member.'
// 'Redundant 'static' modifier on a direct member.'
protected final strictfp void calculate() {}
// 3 violations above:
// 'Redundant 'protected' modifier on a direct member.'
// 'Redundant 'final' modifier on a direct member.'
// 'Redundant 'strictfp' modifier on a direct member.'
// violation below 'Redundant 'private' modifier on a direct member.'
private void helper() {}
public static int first;
// 2 violations above:
// 'Redundant 'public' modifier on a direct member.'
// 'Redundant 'static' modifier on a direct member.'
// violation below 'Redundant 'protected' modifier on a direct member.'
protected int second;
// violation below 'Redundant 'private' modifier on a direct member.'
private int third;
void main() {}
Example of Usage
Violation Messages
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
Fully Qualified Name
com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCompactSourceCheck






