Skip to content
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

FinalClass: If you follow the checkstyle hint, the code breaks. #4037

Closed
hneemann opened this issue Mar 18, 2017 · 3 comments
Closed

FinalClass: If you follow the checkstyle hint, the code breaks. #4037

hneemann opened this issue Mar 18, 2017 · 3 comments

Comments

@hneemann
Copy link

hneemann commented Mar 18, 2017

/var/tmp $ javac Foo.java
/var/tmp $ cat Foo.java

/**
 * Foo is a simple test.
 */
public final class Foo {

    /**
     * Test.
     */
    private class Test {

        /**
         * Create a new instance.
         */
        private Test() {
        }
    }

    /**
     * Test 2.
     */
    private class Test2 extends Test {
    }

}

/var/tmp $ cat digital_checks.xml

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
        "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
        "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
    <module name="TreeWalker">
        <module name="FinalClass"/>
    </module>
</module>

/var/tmp $ java -Duser.language=en -jar checkstyle-7.6-all.jar -c digital_checks.xml Foo.java

Starting audit...
[ERROR] /home/hneemann/temp/checkstyle/Foo.java:9: Class Test should be declared as final. [FinalClass]
Audit done.
Checkstyle ends with 1 errors.

The class Test can not be final because Test2 inherits from Test. There should be no error at all.
If you decare Test as final, the code does not compile anymore.


unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 28, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 28, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 28, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 28, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 28, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 28, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 29, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 29, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 29, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 29, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 29, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 29, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 29, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 29, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 29, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 29, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 30, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Mar 30, 2017
unrealwork added a commit to unrealwork/checkstyle that referenced this issue Apr 5, 2017
@romani
Copy link
Member

romani commented Jul 3, 2017

connection with @unrealwork is lost, PR is closed as incomplete.
If smb want to continue from scratch or from where unrealwork is finished, please be welcome .

@checkstyle checkstyle deleted a comment from unrealwork Jul 3, 2017
@linusjf
Copy link

linusjf commented May 25, 2020

https://groups.google.com/forum/m/#!msg/checkstyle/Szdb6677DWM/cCAH59EYAAAJ

Another example Java source that exhibits the above scenario.

@pbludov
Copy link
Member

pbludov commented Dec 22, 2021

Will be fixed in #10859

@pbludov pbludov closed this as completed Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants