Skip to content

Commit

Permalink
Issue checkstyle#12441: Resolve Pitest suppression for RightCurlyCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
arinmodi committed Nov 23, 2022
1 parent e5b77a6 commit b60d0e6
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public void testAlone() throws Exception {
"184:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"189:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"190:53: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 53),
"221:12: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 12),
};
verifyWithInlineConfigParser(
getPath("InputRightCurlyLeftTestAlone.java"), expected);
Expand Down Expand Up @@ -650,4 +649,23 @@ public void testUppercaseOptionProperty() throws Exception {
verifyWithInlineConfigParser(
getPath("InputRightCurlyWithUppercaseOptionProperty.java"), expected);
}

@Test
public void testRightCurlyWithIfElseAlone() throws Exception {
final String[] expected = {
"19:12: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 12),
"27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
};
verifyWithInlineConfigParser(
getPath("InputRightCurlyTestIfElseAlone.java"), expected);
}

@Test
public void testRightCurlyDefault() throws Exception {
final String[] expected = {
"21:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9),
};
verifyWithInlineConfigParser(
getPath("InputRightCurlyTestDefault.java"), expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,4 @@ interface Interface3 {
interface Interface4 {
void myMethod();
}} // ok

public void test() {
int id = 0;
switch (id) {
case 0: break;
case 1: if (1 == 0) {
break;
}; // violation ''}' at column 12 should be alone on a line.'
case 2: break;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
RightCurly
option = (default)SAME
tokens = (default)LITERAL_TRY , LITERAL_CATCH , LITERAL_FINALLY , LITERAL_IF , LITERAL_ELSE
*/

package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;

public class InputRightCurlyTestDefault {

public void foo() {
if (456 == 123) { } // OK
if(true) { } else { } // OK
}

public void foo1() {
if (4 > 0) {
//
} // violation ''}' at column 9 should be on the same line as .*/else'
else {
//
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
RightCurly
option = ALONE
tokens = LITERAL_IF, LITERAL_ELSE
*/

package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;

public class InputRightCurlyTestIfElseAlone {

public void test() {
int id = 0;
switch (id) {
case 0: break;
case 1: if (1 == 0) {
break;
}; // violation ''}' at column 12 should be alone on a line.'
case 2: break;
}
}

public void test2() {
if(true) {

} if(false) { // violation ''}' at column 9 should be alone on a line.'

}
}

}

0 comments on commit b60d0e6

Please sign in to comment.