#167 Redundant Modifier should only check top-level declarations

release_3.1
closed
Lars Kühne
5
2012-10-10
2003-11-04
Chuck Daniels
No

RedundantModifier erroneously flags nested modifiers as
redundant. It should only check top-level declarations
within an interface.

Example:

public interface Operation
{
double eval(double a, double b);

Operation PLUS =
    new Operation()
    {
        public double eval(double a, double b)
        {
            return a + b;
        }

        public String toString()
        {
            return "+";
        }
    };

Operation MINUS =
    new Operation()
    {
        public double eval(double a, double b)
        {
            return a - b;
        }

        public String toString()
        {
            return "-";
        }
    };

}

For this interface, RedundantModifier incorrectly flags
the public modifiers of the eval and toString methods as
redundant.

Discussion

  • Lars Kühne
    Lars Kühne
    2003-11-06

    Logged In: YES
    user_id=401384

    duplicate of bug 784814, which is already fixed in CVS
    Version of Checkstyle.