Skip to content

Commit

Permalink
Issue checkstyle#12876: Resolve pitest suppression for AbstractViolat…
Browse files Browse the repository at this point in the history
…ionReporter
  • Loading branch information
ThatSneakyCoder committed Apr 5, 2023
1 parent 50acb33 commit b1392ab
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
9 changes: 0 additions & 9 deletions config/pitest-suppressions/pitest-api-suppressions.xml
@@ -1,14 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<suppressedMutations>
<mutation unstable="false">
<sourceFile>AbstractViolationReporter.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter</mutatedClass>
<mutatedMethod>setSeverity</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.MemberVariableMutator</mutator>
<description>Removed assignment to member variable severityLevel</description>
<lineContent>severityLevel = SeverityLevel.getInstance(severity);</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>FileContents.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.api.FileContents</mutatedClass>
Expand Down
Expand Up @@ -23,6 +23,7 @@

import java.util.SortedSet;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
Expand All @@ -33,7 +34,12 @@
* Tests to ensure that default message bundle is determined correctly.
*
*/
public class AbstractViolationReporterTest {
public class AbstractViolationReporterTest extends AbstractModuleTestSupport {

@Override
protected String getPackageLocation() {
return "com/puppycrawl/tools/checkstyle/api/abstractviolationreporter";
}

private final AbstractCheck emptyCheck = new EmptyCheck();

Expand Down Expand Up @@ -79,6 +85,14 @@ public void testSeverity() throws Exception {
.isEqualTo("error");
}

@Test
public void testSetSeverity() throws Exception {
final Configuration checkConfig =
createModuleConfig(SetSeverity.class);
final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputAbstractViolationReporterSetSeverity.java"), expected);
}

@Test
public void testCustomMessage() throws Exception {
final DefaultConfiguration config = createModuleConfig(emptyCheck.getClass());
Expand Down Expand Up @@ -152,4 +166,17 @@ public int[] getRequiredTokens() {

}

public static class SetSeverity extends AbstractViolationReporter {

@Override
public void log(int line, String key, Object... args) {

}

@Override
public void log(int line, int col, String key, Object... args) {

}
}

}
@@ -0,0 +1,5 @@
package com.puppycrawl.tools.checkstyle.api.abstractviolationreporter;

public class InputAbstractViolationReporterSetSeverity {
// code
}

0 comments on commit b1392ab

Please sign in to comment.