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

False RedundantModifier violation for final method of enum inside final class #5268

Closed
frost13it opened this Issue Nov 16, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@frost13it

frost13it commented Nov 16, 2017

Here is code:

TestClass.java:

public final class TestClass {

    public enum TestEnum {
        VALUE {
           @Override public void someMethodToOverride() {
                // do it differently
            }
         };

        public void someMethodToOverride() { }
        public static final void someStaticMethod() { }
        public final void someMethod() { }         // unexpected violation here
    }

}

config.xml:

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

<module name="Checker">
    <module name="TreeWalker">
        <module name="RedundantModifier"/>
    </module>
</module>

Result:

java -jar checkstyle-8.4-all.jar -c config.xml TestClass.java 
Starting audit...
[ERROR] /var/tmp/Test.java:11:23: Redundant 'final' modifier. [RedundantModifier]
[ERROR] /var/tmp/Test.java:12:16: Redundant 'final' modifier. [RedundantModifier]
Audit done.
Checkstyle ends with 2 errors.

Expected:
only one violation
[ERROR] /var/tmp/Test.java:11:23: Redundant 'final' modifier. [RedundantModifier]

https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.9
sub-classing of enum is forbidden but all constants could override methods.
Documentation should have such example as it is not very obvious.

@romani romani closed this Nov 18, 2017

@romani romani reopened this Nov 18, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Nov 18, 2017

Member

@frost13it , thanks for bringing this back, next time please report issue as it was defined in issue template to avoid misunderstanding on our side.

I updated description to follow rules and explain there is an issue.
All removed all previous comments to keep history of issue clean to be less scary to possible contributor from aside of main team

Member

romani commented Nov 18, 2017

@frost13it , thanks for bringing this back, next time please report issue as it was defined in issue template to avoid misunderstanding on our side.

I updated description to follow rules and explain there is an issue.
All removed all previous comments to keep history of issue clean to be less scary to possible contributor from aside of main team

@checkstyle checkstyle deleted a comment from frost13it Nov 18, 2017

djydewang added a commit to djydewang/checkstyle that referenced this issue Nov 27, 2017

@djydewang

This comment has been minimized.

Show comment
Hide comment
@djydewang

djydewang Nov 27, 2017

Contributor

I am on it.

Contributor

djydewang commented Nov 27, 2017

I am on it.

djydewang added a commit to djydewang/checkstyle that referenced this issue Nov 27, 2017

djydewang added a commit to djydewang/checkstyle that referenced this issue Nov 28, 2017

djydewang added a commit to djydewang/checkstyle that referenced this issue Nov 29, 2017

djydewang added a commit to djydewang/checkstyle that referenced this issue Dec 2, 2017

djydewang added a commit to djydewang/checkstyle that referenced this issue Dec 4, 2017

djydewang added a commit to djydewang/checkstyle that referenced this issue Dec 6, 2017

rnveach added a commit that referenced this issue Dec 6, 2017

@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach Dec 6, 2017

Member

Fix was merged

Member

rnveach commented Dec 6, 2017

Fix was merged

@rnveach rnveach closed this Dec 6, 2017

@rnveach rnveach added this to the 8.6 milestone Dec 6, 2017

timurt added a commit to timurt/checkstyle that referenced this issue Dec 19, 2017

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