New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SuppressWarnings triggers RedundantModifier check on enum constructor #4846

Closed
mmoehring opened this Issue Jul 29, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@mmoehring

mmoehring commented Jul 29, 2017

/var/tmp $ javac Foo.java

/var/tmp $ cat Foo.java

package com.checkstyletest;

/**
 * Insert javadoc.
 */
public enum Foo {
    A(1, 2, 3, 4, 5);

    private final int a;
    private final int b;
    private final int c;
    private final int d;
    private final int e;

    @SuppressWarnings("checkstyle:parameternumber")
    Foo(final int a, final int b, final int c, final int d, final int e) {
        this.a = a;
        this.b = b;
        this.c = c;
        this.d = d;
        this.e = e;
    }
}

/var/tmp $ cat config.xml

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
        "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">

<module name="Checker">
    <property name="charset" value="UTF-8"/>
    <module name="SuppressWarningsFilter"/>
    <module name="TreeWalker">
        <module name="SuppressWarningsHolder"/>
        <module name="ParameterNumber">
            <property name="max" value="4"/>
            <property name="ignoreOverriddenMethods" value="true"/>
        </module>
        <module name="RedundantModifier"/>
    </module>
</module>

Output:

/var/tmp $ java -jar checkstyle-8.1-all.jar -c config.xml Foo.java 
Starting audit...
[ERROR] /var/tmp/Foo.java:15:5: Redundant 'ANNOTATION' modifier. [RedundantModifier]
Audit done.
Checkstyle ends with 1 errors.

I wanted to suppress the checkstyle error for 'too many parameters' on the enum constructor, so I added the @SuppressWarnings("checkstyle:parameternumber") but with this annotation checkstyle now warns with RedundantModifier because of the annotation.
I would expect that a @SuppressWarnings should not trigger the RedundantModifier warning.


@romani romani added the approved label Aug 2, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Aug 5, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Aug 5, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Aug 5, 2017

romani added a commit that referenced this issue Aug 10, 2017

@romani romani added the bug label Aug 10, 2017

@romani romani added this to the 8.2 milestone Aug 10, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Aug 10, 2017

Member

fix is merged

Member

romani commented Aug 10, 2017

fix is merged

@romani romani closed this Aug 10, 2017

ArneLimburg pushed a commit to ArneLimburg/checkstyle that referenced this issue Aug 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment