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

Issue #12296: Resolve Pitest suppression for block profile #12297

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 0 additions & 54 deletions .ci/pitest-suppressions/pitest-blocks-suppressions.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<suppressedMutations>
<mutation unstable="false">
<sourceFile>EmptyBlockCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck</mutatedClass>
<mutatedMethod>setOption</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/lang/String::toUpperCase with receiver</description>
<lineContent>option = BlockOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>EmptyBlockCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck</mutatedClass>
<mutatedMethod>setOption</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/lang/String::trim with receiver</description>
<lineContent>option = BlockOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>EmptyBlockCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck</mutatedClass>
Expand All @@ -27,24 +9,6 @@
<lineContent>ast.getText());</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>LeftCurlyCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck</mutatedClass>
<mutatedMethod>setOption</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/lang/String::toUpperCase with receiver</description>
<lineContent>option = LeftCurlyOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>LeftCurlyCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck</mutatedClass>
<mutatedMethod>setOption</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/lang/String::trim with receiver</description>
<lineContent>option = LeftCurlyOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>LeftCurlyCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck</mutatedClass>
Expand Down Expand Up @@ -81,24 +45,6 @@
<lineContent>nextToken = Details.getNextToken(nextToken);</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>RightCurlyCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck</mutatedClass>
<mutatedMethod>setOption</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/lang/String::toUpperCase with receiver</description>
<lineContent>option = RightCurlyOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>RightCurlyCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck</mutatedClass>
<mutatedMethod>setOption</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/lang/String::trim with receiver</description>
<lineContent>option = RightCurlyOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>RightCurlyCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck$Details</mutatedClass>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,13 @@ public void testEmptyBlockSwitchExpressions() throws Exception {
getNonCompilablePath("InputEmptyBlockSwitchExpressions.java"), expected);
}

@Test
public void testUppercaseProperty() throws Exception {
final String[] expected = {
"16:30: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "default"),
"22:13: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "default"),
};
verifyWithInlineConfigParser(
getPath("InputEmptyBlockTestUppercaseOptionProperty.java"), expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -512,4 +512,13 @@ public void testInvalidOption() throws Exception {
}
}

@Test
public void testTrimOptionProperty() throws Exception {
final String[] expected = {
"13:12: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 12),
"20:16: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 16),
};
verifyWithInlineConfigParser(
getPath("InputLeftCurlyWithTrimOptionProperty.java"), expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,14 @@ public void testRightCurlyWithEmojiAloneOrSingleLine() throws Exception {
verifyWithInlineConfigParser(
getPath("InputRightCurlyWithEmojiAloneOrSingleLine.java"), expected);
}

@Test
public void testUppercaseOptionProperty() throws Exception {
final String[] expected = {
"16:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
"21:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
};
verifyWithInlineConfigParser(
getPath("InputRightCurlyWithUppercaseOptionProperty.java"), expected);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
EmptyBlock
option = TEXT
option = \tTEXT
tokens = (default)LITERAL_WHILE, LITERAL_TRY, LITERAL_FINALLY, LITERAL_DO, \
LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, INSTANCE_INIT, STATIC_INIT, \
LITERAL_SWITCH, LITERAL_SYNCHRONIZED
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
EmptyBlock
option = text
tokens = LITERAL_DEFAULT


*/

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

public class InputEmptyBlockTestUppercaseOptionProperty {

void method1(int a) {
switch (a) {}
switch (a) {default: ; } // ok
switch (a) {default: {}} // violation 'Empty default block'
switch (a) {
default:
}
switch (a) {
default:
{} // violation 'Empty default block'
}
switch (a) {
default:
{ // ok
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
LeftCurly
option = NL
option = nl
ignoreEnums = (default)true
tokens = (default)ANNOTATION_DEF, CLASS_DEF, CTOR_DEF, ENUM_CONSTANT_DEF, \
ENUM_DEF, INTERFACE_DEF, LAMBDA, LITERAL_CASE, LITERAL_CATCH, \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
LeftCurly
option = \tNL
tokens = STATIC_INIT


*/

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

public class InputLeftCurlyWithTrimOptionProperty {

static { // violation ''{' at column 12 should be on a new line'
}
static
{}

static class Inner
{ // ok
static { // violation ''{' at column 16 should be on a new line'
int i = 1;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
RightCurly
option = ALONE
option = \tALONE
tokens = LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, \
CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, \
STATIC_INIT, INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
RightCurly
option = alone
tokens = LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, \
CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, \
STATIC_INIT, INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF


*/

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

public class InputRightCurlyWithUppercaseOptionProperty {

@SuppressWarnings("unused")
private void foo2() { int a = 9; return; }
// violation above ''}' at column 46 should be alone on a line'

@SuppressWarnings("unused")
private void foo3()
{ int var1 = 5; int var2 = 6; } // violation ''}' at column 35 should be alone on a line'

}