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
Currently RightCurlyCheck accepts a less tokens than LeftCurlyCheck (19 tokens)
This issue aims to add support for LITERAL_DEFAULT token in RightCurlyCheck
this issue is a child issue for #3547
For LeftCurlyCheck:
PS D:\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="LeftCurly">
<property name="tokens" value="LITERAL_DEFAULT"/>
<property name="option" value="eol"/>
</module>
</module>
</module>
PS D:\test> cat src/Test.java
class Test{
void test(){
int x = 1;
switch(x){
case 1:
{
System.out.println("x is 1");
break;
}
case 2:
{
System.out.println("x is 2");
break;
}
default:
{ // violation
System.out.println("x is neither 1 nor 2");
}
}
}
}
PS D:\test> java -jar checkstyle-10.13.0-all.jar -c config.xml src/Test.java
Starting audit...
[ERROR] D:\test\src\Test.java:12:13: '{' at column 17 should be on the previous line. [LeftCurly]
Audit done.
for RightCurlyCheck:
PS D:\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="RightCurly">
<property name="tokens" value="LITERAL_DEFAULT"/>
<property name="option" value="alone"/>
</module>
</module>
</module>
PS D:\test> cat src/Test.java
class Test{
void test(){
int x = 1;
switch(x){
case 1:
{
System.out.println("x is 1");
break;
} case 2:
{
System.out.println("x is 2");
break;
} default: {System.out.println("x is neither 1 nor 2");} // expecting violation here
}
}
}
Expected:- Violation for the right curly brace for LITERAL_DEFAULT NOTE:- implementation for LITERAL_CASE is done at #14623 I am just waiting for this to get merged and will enable support for default and testing in another PR (the implementation for case and default is almost the same)
The text was updated successfully, but these errors were encountered:
Currently RightCurlyCheck accepts a less tokens than LeftCurlyCheck (19 tokens)
This issue aims to add support for
LITERAL_DEFAULT
token in RightCurlyCheckthis issue is a child issue for #3547
For LeftCurlyCheck:
for RightCurlyCheck:
Expected:- Violation for the right curly brace for
LITERAL_DEFAULT
NOTE:- implementation for
LITERAL_CASE
is done at #14623 I am just waiting for this to get merged and will enable support for default and testing in another PR (the implementation for case and default is almost the same)The text was updated successfully, but these errors were encountered: