Skip to content

Commit

Permalink
Issue checkstyle#10745: Removed hardcoded configs in test methods
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatj07 committed Aug 30, 2021
1 parent 525bc1e commit 875ec76
Show file tree
Hide file tree
Showing 197 changed files with 8 additions and 4,648 deletions.
Expand Up @@ -214,8 +214,7 @@ protected final String getUriString(String filename) {
.toString();
}

protected final void verifyFilterWithInlineConfigParser(Configuration aConfig,
String filePath,
protected final void verifyFilterWithInlineConfigParser(String filePath,
String[] expectedUnfiltered,
String... expectedFiltered)
throws Exception {
Expand Down
Expand Up @@ -86,6 +86,6 @@ public String toRegex() {

@Override
public int compareTo(TestInputViolation testInputViolation) {
return lineNo - testInputViolation.lineNo;
return Integer.compare(lineNo, testInputViolation.lineNo);
}
}
Expand Up @@ -26,7 +26,6 @@
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;

public class ArrayTypeStyleCheckTest
Expand All @@ -48,8 +47,6 @@ public void testGetRequiredTokens() {
@Test
public void testJavaStyleOn()
throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(ArrayTypeStyleCheck.class);
final String[] expected = {
"13:23: " + getCheckMessage(MSG_KEY),
"14:18: " + getCheckMessage(MSG_KEY),
Expand All @@ -67,9 +64,6 @@ public void testJavaStyleOn()
@Test
public void testJavaStyleOff()
throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(ArrayTypeStyleCheck.class);
checkConfig.addProperty("javaStyle", "false");
final String[] expected = {
"12:16: " + getCheckMessage(MSG_KEY),
"16:39: " + getCheckMessage(MSG_KEY),
Expand All @@ -88,8 +82,6 @@ public void testJavaStyleOff()
@Test
public void testNestedGenerics()
throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(ArrayTypeStyleCheck.class);
final String[] expected = {
"22:45: " + getCheckMessage(MSG_KEY),
"23:61: " + getCheckMessage(MSG_KEY),
Expand Down
Expand Up @@ -35,7 +35,6 @@
import org.powermock.reflect.Whitebox;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;

Expand Down Expand Up @@ -169,8 +168,6 @@ public void testGetRequiredTokens() {

@Test
public void testDefault() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(AvoidEscapedUnicodeCharactersCheck.class);
final String[] expected = {
"17:38: " + getCheckMessage(MSG_KEY),
"19:38: " + getCheckMessage(MSG_KEY),
Expand Down Expand Up @@ -228,9 +225,6 @@ public void testDefault() throws Exception {

@Test
public void testAllowEscapesForControlCharacterSet() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(AvoidEscapedUnicodeCharactersCheck.class);
checkConfig.addProperty("allowEscapesForControlCharacters", "true");
final String[] expected = {
"17:38: " + getCheckMessage(MSG_KEY),
"19:38: " + getCheckMessage(MSG_KEY),
Expand Down Expand Up @@ -283,9 +277,6 @@ public void testAllowEscapesForControlCharacterSet() throws Exception {

@Test
public void testAllowByTailComment() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(AvoidEscapedUnicodeCharactersCheck.class);
checkConfig.addProperty("allowByTailComment", "true");
final String[] expected = {
"17:38: " + getCheckMessage(MSG_KEY),
"25:38: " + getCheckMessage(MSG_KEY),
Expand Down Expand Up @@ -322,9 +313,6 @@ public void testAllowByTailComment() throws Exception {

@Test
public void testAllowAllCharactersEscaped() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(AvoidEscapedUnicodeCharactersCheck.class);
checkConfig.addProperty("allowIfAllCharactersEscaped", "true");
final String[] expected = {
"17:38: " + getCheckMessage(MSG_KEY),
"19:38: " + getCheckMessage(MSG_KEY),
Expand Down Expand Up @@ -359,9 +347,6 @@ public void testAllowAllCharactersEscaped() throws Exception {

@Test
public void allowNonPrintableEscapes() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(AvoidEscapedUnicodeCharactersCheck.class);
checkConfig.addProperty("allowNonPrintableEscapes", "true");
final String[] expected = {
"17:38: " + getCheckMessage(MSG_KEY),
"19:38: " + getCheckMessage(MSG_KEY),
Expand Down Expand Up @@ -402,9 +387,6 @@ public void allowNonPrintableEscapes() throws Exception {

@Test
public void testAvoidEscapedUnicodeCharactersTextBlocksAllowByComment() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(AvoidEscapedUnicodeCharactersCheck.class);
checkConfig.addProperty("allowByTailComment", "true");
final String[] expected = {
"18:30: " + getCheckMessage(MSG_KEY),
"20:30: " + getCheckMessage(MSG_KEY),
Expand All @@ -423,8 +405,6 @@ public void testAvoidEscapedUnicodeCharactersTextBlocksAllowByComment() throws E

@Test
public void testAvoidEscapedUnicodeCharactersTextBlocks() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(AvoidEscapedUnicodeCharactersCheck.class);
final String[] expected = {
"17:30: " + getCheckMessage(MSG_KEY),
"18:30: " + getCheckMessage(MSG_KEY),
Expand All @@ -442,9 +422,6 @@ public void testAvoidEscapedUnicodeCharactersTextBlocks() throws Exception {

@Test
public void testAvoidEscapedUnicodeCharactersEscapedS() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(AvoidEscapedUnicodeCharactersCheck.class);
checkConfig.addProperty("allowIfAllCharactersEscaped", "true");
final String[] expected = {
"17:21: " + getCheckMessage(MSG_KEY),
"18:22: " + getCheckMessage(MSG_KEY),
Expand Down Expand Up @@ -472,9 +449,6 @@ public void testGetAcceptableTokens() {

@Test
public void testAllowEscapesForControlCharacterSetForAllCharacters() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(AvoidEscapedUnicodeCharactersCheck.class);
checkConfig.addProperty("allowEscapesForControlCharacters", "true");

final int indexOfStartLineInInputFile = 16;
final String message = getCheckMessage(MSG_KEY);
Expand Down

0 comments on commit 875ec76

Please sign in to comment.