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 documentation: Checks if unnecessary semicolon is used after type member declaration.
➜ full-record-grammar /usr/lib/jvm/java-14-openjdk/bin/javac --enable-preview --source 14 MyRecord.java
Note: MyRecord.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="UnnecessarySemicolonAfterTypeMemberDeclaration"/>
</module>
</module>
➜ full-record-grammar cat MyRecord.java
public record MyRecord() {
; // violation, standalone semicolon
static {}; // violation, extra semicolon after init block
static {}; // violation, extra semicolon after static init block
public MyRecord{}; // violation, extra semicolon after compact constructor definition
public MyRecord(Object o){this();}; // violation, extra semicolon after constructor definition
void method() {}; // violation, extra semicolon after method definition
static int field = 10;; // violation, extra semicolon after field declaration
static {
; // no violation, it is empty statement inside init block
}
static {
; // no violation, it is empty statement inside static init block
}
void anotherMethod() {
; // no violation, it is empty statement
if(true); // no violation, it is empty statement
}
}; // ok, this check does not apply to outer types
➜ full-record-grammar java $RUN_LOCALE -jar ~/IdeaProjects/checkstyle/target/checkstyle-8.35-SNAPSHOT-all.jar -c config.xml MyRecord.java
Starting audit...
[ERROR] /home/nick/Desktop/full-record-grammar/MyRecord.java:3:15: Unnecessary semicolon. [UnnecessarySemicolonAfterTypeMemberDeclaration]
[ERROR] /home/nick/Desktop/full-record-grammar/MyRecord.java:4:15: Unnecessary semicolon. [UnnecessarySemicolonAfterTypeMemberDeclaration]
[ERROR] /home/nick/Desktop/full-record-grammar/MyRecord.java:6:40: Unnecessary semicolon. [UnnecessarySemicolonAfterTypeMemberDeclaration]
[ERROR] /home/nick/Desktop/full-record-grammar/MyRecord.java:7:22: Unnecessary semicolon. [UnnecessarySemicolonAfterTypeMemberDeclaration]
[ERROR] /home/nick/Desktop/full-record-grammar/MyRecord.java:8:28: Unnecessary semicolon. [UnnecessarySemicolonAfterTypeMemberDeclaration]
Audit done.
Checkstyle ends with 5 errors.
So, this check works in the body of record definitions, but does not work on compact constructors(line #5). We need to add support for compact constructors to this check.
The text was updated successfully, but these errors were encountered:
Child of #8452
Check documentation: https://checkstyle.sourceforge.io/config_coding.html#UnnecessarySemicolonAfterTypeMemberDeclaration
From documentation:
Checks if unnecessary semicolon is used after type member declaration.
So, this check works in the body of record definitions, but does not work on compact constructors(line #5). We need to add support for compact constructors to this check.
The text was updated successfully, but these errors were encountered: