You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From check documentation: Checks nested (internal) classes/interfaces are declared at the bottom of the primary (top-level) class after all method and field declarations.
➜ full-record-grammar /usr/lib/jvm/java-14-openjdk/bin/javac --enable-preview --source 14 TestClass.java
Note: TestClass.java uses preview language features.
Note: Recompile with -Xlint:preview for details.
➜ full-record-grammar cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="InnerTypeLast"/>
</module>
</module>
➜ full-record-grammar cat TestClass.java
public class TestClass{
record Test (){
private static String s; // OK
record InnerTest1() {}
public void test() {} // should be violation, method should be declared before inner types.
}
public void test() {} // should be violation, method should be declared before inner types.
record Test3 (){
private static String s; // ok
class InnerTest1 {}
public void test() {} // violation, method should be declared before inner types.
}
record Test4 (){
private static String s; // ok
record MyInnerRecord(){}
static Test3 innerRecord = new Test3(); //ok
public void test() {}// should be a violation, method should be declared before inner types.
}
record Test5 (){
private static String s; // ok
static Test3 myRecordTest = new Test3(); //ok
public void test() {} // ok
}
}% ➜ full-record-grammar java $RUN_LOCALE -jar ~/IdeaProjects/checkstyle/target/checkstyle-8.35-SNAPSHOT-all.jar -c config.xml TestClass.java
Starting audit...
[ERROR] /home/nick/Desktop/full-record-grammar/TestClass.java:13:9: Fields and methods should be before inner classes. [InnerTypeLast]
Audit done.
Checkstyle ends with 1 errors.
We need to add support for record declarations and bodies to this check.
The text was updated successfully, but these errors were encountered:
Child of #8452
Check documentation: https://checkstyle.sourceforge.io/config_design.html#InnerTypeLast
From check documentation:
Checks nested (internal) classes/interfaces are declared at the bottom of the primary (top-level) class after all method and field declarations.
We need to add support for record declarations and bodies to this check.
The text was updated successfully, but these errors were encountered: