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: Indentation #15108

Closed
mahfouz72 opened this issue Jun 23, 2024 · 4 comments · Fixed by #15477
Closed

Add Check Support for Java 17 Sealed Classes: Indentation #15108

mahfouz72 opened this issue Jun 23, 2024 · 4 comments · Fixed by #15477

Comments

@mahfouz72
Copy link
Member

mahfouz72 commented Jun 23, 2024

child of #14969 :

documentation: Add Check Support for Java 17 Sealed Classe


PS D:\CS\test> javac src/Test.java                                              
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="Indentation">

        </module>
    </module>
</module>
PS D:\CS\test> cat src/Test.java                                                
     sealed   // violation
class Test  // violation
    permits A, B { // violation
}

    final class A extends Test { // violation
}

   sealed  // violation
   class B extends Test // violation
permits // violation
       D {
}

    non-sealed // violation
class D // violation
    extends B { // violation
}

Starting audit...
[ERROR] D:\CS\test\src\Test.java:1:3: 'class def modifier' has incorrect indentation level 2, expected level should be 0. [Indentation]
[ERROR] D:\CS\test\src\Test.java:2:1: 'class' has incorrect indentation level 0, expected level should be 6. [Indentation]
[ERROR] D:\CS\test\src\Test.java:3:5: 'permits' has incorrect indentation level 4, expected level should be 6. [Indentation]
[ERROR] D:\CS\test\src\Test.java:6:5: 'class def modifier' has incorrect indentation level 4, expected level should be 0. [Indentation]
[ERROR] D:\CS\test\src\Test.java:9:4: 'class def modifier' has incorrect indentation level 3, expected level should be 0. [Indentation]
[ERROR] D:\CS\test\src\Test.java:10:4: 'class' has incorrect indentation level 3, expected level should be 7. [Indentation]
[ERROR] D:\CS\test\src\Test.java:11:1: 'permits' has incorrect indentation level 0, expected level should be 7. [Indentation]
[ERROR] D:\CS\test\src\Test.java:15:5: 'class def modifier' has incorrect indentation level 4, expected level should be 0. [Indentation]
[ERROR] D:\CS\test\src\Test.java:16:1: 'class' has incorrect indentation level 0, expected level should be 8. [Indentation]
[ERROR] D:\CS\test\src\Test.java:17:5: 'extends' has incorrect indentation level 4, expected level should be 8. [Indentation]
Audit done.
Checkstyle ends with 10 errors.

PS D:\CS\test> 

Describe what you want in detail.

we are good here. The check works correctly on all new tokens

@mahfouz72
Copy link
Member Author

I am curious how the check works correct on permits for sealed I understand we may have some handler for all modifiers.

@rnveach
Copy link
Member

rnveach commented Jun 26, 2024

We do have support for line wrapping between 2 ASTs. Most likely it is picked as part of extends for all tokens between that and {.

@mahfouz72
Copy link
Member Author

I updated the first post to have example of violation on permits without extends

@nrmancuso
Copy link
Member

Let's add an input and move on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants