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

Add Check Support for Java 17 Sealed Classes: MissingOverride #15075

Closed
mahfouz72 opened this issue Jun 21, 2024 · 4 comments
Closed

Add Check Support for Java 17 Sealed Classes: MissingOverride #15075

mahfouz72 opened this issue Jun 21, 2024 · 4 comments

Comments

@mahfouz72
Copy link
Member

mahfouz72 commented Jun 21, 2024

child of #14969

check documentation : https://checkstyle.org/checks/annotation/missingoverride.html


PS D:\CS\test> cat 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">
    <property name="charset" value="UTF-8"/>
    <module name="TreeWalker">
            <module name="MissingOverride"/>
    </module>
</module>
PS D:\CS\test> cat src/Test.java                                                
class A {
    void a() {
        synchronized (this) {}
    }
}
public sealed class Test extends A permits Testt  {
    void test(Object obj) {
        synchronized (this) {}
    }

    /**
     * {@inheritDoc}
     */
    void a() {}  // violation
}

final class Testt extends Test {

    /**
     * {@inheritDoc}
     */
    void test(Object obj) {   // violation
    }
}
PS D:\CS\test> java  -jar checkstyle-10.17.0-all.jar -c config.xml src/Test.java
Starting audit...
[ERROR] D:\CS\test\src\Test.java:14:5: Must include @java.lang.Override annotation when '@inheritDoc' Javadoc tag exists. [MissingOverride]
[ERROR] D:\CS\test\src\Test.java:22:5: Must include @java.lang.Override annotation when '@inheritDoc' Javadoc tag exists. [MissingOverride]
Audit done.
Checkstyle ends with 2 errors.
PS D:\CS\test> 


We are ok here. no update is required.

@rnveach
Copy link
Member

rnveach commented Jun 22, 2024

synchronized (this) {} // violation

I think this is wrong.

I don't see an issue with the check, but the example should also have a violation inside a sealed class also to cover our bases.

@mahfouz72 please update examples.

@rnveach rnveach self-assigned this Jun 22, 2024
@mahfouz72
Copy link
Member Author

First post is updated

@rnveach
Copy link
Member

rnveach commented Jun 23, 2024

I am good.

@rnveach rnveach assigned nrmancuso and unassigned rnveach Jun 23, 2024
@nrmancuso
Copy link
Member

We don't need to take any further action here.

@nrmancuso nrmancuso removed their assignment Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants