diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckTest.java index a539c014e5d..d6bcb7d50d7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckTest.java @@ -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 @@ -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), @@ -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), @@ -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), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/AvoidEscapedUnicodeCharactersCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/AvoidEscapedUnicodeCharactersCheckTest.java index 1f0649e1038..3b6a06ce5bd 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/AvoidEscapedUnicodeCharactersCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/AvoidEscapedUnicodeCharactersCheckTest.java @@ -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; @@ -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), @@ -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), @@ -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), @@ -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), @@ -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), @@ -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), @@ -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), @@ -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), @@ -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); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java index c264fa8a09d..dfc679d1b80 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class DescendantTokenCheckTest extends AbstractModuleTestSupport { @@ -40,8 +39,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputDescendantTokenIllegalTokens.java"), expected); @@ -50,11 +47,6 @@ public void testDefault() @Test public void testMaximumNumber() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "LITERAL_NATIVE"); - checkConfig.addProperty("limitedTokens", "LITERAL_NATIVE"); - checkConfig.addProperty("maximumNumber", "0"); final String[] expected = { "32:12: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "LITERAL_NATIVE", "LITERAL_NATIVE"), }; @@ -65,12 +57,6 @@ public void testMaximumNumber() @Test public void testMessage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "LITERAL_NATIVE"); - checkConfig.addProperty("limitedTokens", "LITERAL_NATIVE"); - checkConfig.addProperty("maximumNumber", "0"); - checkConfig.addProperty("maximumMessage", "Using ''native'' is not allowed."); final String[] expected = { "32:12: Using 'native' is not allowed.", }; @@ -81,11 +67,6 @@ public void testMessage() @Test public void testMinimumNumber() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "LITERAL_SWITCH"); - checkConfig.addProperty("limitedTokens", "LITERAL_DEFAULT"); - checkConfig.addProperty("minimumNumber", "2"); final String[] expected = { "23:9: " + getCheckMessage(MSG_KEY_MIN, 1, 2, "LITERAL_SWITCH", "LITERAL_DEFAULT"), }; @@ -96,12 +77,6 @@ public void testMinimumNumber() @Test public void testMinimumDepth() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "LITERAL_SWITCH"); - checkConfig.addProperty("limitedTokens", "LITERAL_DEFAULT"); - checkConfig.addProperty("maximumNumber", "0"); - checkConfig.addProperty("minimumDepth", "3"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputDescendantTokenIllegalTokens5.java"), expected); @@ -110,12 +85,6 @@ public void testMinimumDepth() @Test public void testMaximumDepth() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "LITERAL_SWITCH"); - checkConfig.addProperty("limitedTokens", "LITERAL_DEFAULT"); - checkConfig.addProperty("maximumNumber", "0"); - checkConfig.addProperty("maximumDepth", "1"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputDescendantTokenIllegalTokens6.java"), expected); @@ -124,13 +93,6 @@ public void testMaximumDepth() @Test public void testEmptyStatements() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "EMPTY_STAT"); - checkConfig.addProperty("limitedTokens", "EMPTY_STAT"); - checkConfig.addProperty("maximumNumber", "0"); - checkConfig.addProperty("maximumDepth", "0"); - checkConfig.addProperty("maximumMessage", "Empty statement."); final String[] expected = { "22:7: Empty statement.", @@ -157,13 +119,6 @@ public void testEmptyStatements() @Test public void testMissingSwitchDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "LITERAL_SWITCH"); - checkConfig.addProperty("limitedTokens", "LITERAL_DEFAULT"); - checkConfig.addProperty("minimumNumber", "1"); - checkConfig.addProperty("maximumDepth", "2"); - checkConfig.addProperty("minimumMessage", "switch without \"default\" clause."); final String[] expected = { "32:9: switch without \"default\" clause.", @@ -175,15 +130,6 @@ public void testMissingSwitchDefault() throws Exception { @Test public void testStringLiteralEquality() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "EQUAL, NOT_EQUAL"); - checkConfig.addProperty("limitedTokens", "STRING_LITERAL"); - checkConfig.addProperty("maximumNumber", "0"); - checkConfig.addProperty("maximumDepth", "1"); - checkConfig.addProperty("maximumMessage", - "Literal Strings should be compared using equals(), not ''==''."); - final String[] expected = { "22:18: Literal Strings should be compared using equals(), not '=='.", "27:20: Literal Strings should be compared using equals(), not '=='.", @@ -195,13 +141,6 @@ public void testStringLiteralEquality() throws Exception { @Test public void testIllegalTokenDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "LITERAL_SWITCH, POST_INC, POST_DEC"); - checkConfig.addProperty("limitedTokens", "LITERAL_SWITCH, POST_INC, POST_DEC"); - checkConfig.addProperty("maximumNumber", "0"); - checkConfig.addProperty("maximumDepth", "0"); - checkConfig.addProperty("maximumMessage", "Using ''{2}'' is not allowed."); final String[] expected = { "23:9: Using 'LITERAL_SWITCH' is not allowed.", @@ -214,13 +153,6 @@ public void testIllegalTokenDefault() throws Exception { @Test public void testIllegalTokenNative() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "LITERAL_NATIVE"); - checkConfig.addProperty("limitedTokens", "LITERAL_NATIVE"); - checkConfig.addProperty("maximumNumber", "0"); - checkConfig.addProperty("maximumDepth", "0"); - checkConfig.addProperty("maximumMessage", "Using ''{2}'' is not allowed."); final String[] expected = { "32:12: Using 'LITERAL_NATIVE' is not allowed.", @@ -231,12 +163,6 @@ public void testIllegalTokenNative() throws Exception { @Test public void testReturnFromCatch() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DescendantTokenCheck.class); - - checkConfig.addProperty("tokens", "LITERAL_CATCH"); - checkConfig.addProperty("limitedTokens", "LITERAL_RETURN"); - checkConfig.addProperty("maximumNumber", "0"); - checkConfig.addProperty("maximumMessage", "Return from catch is not allowed."); final String[] expected = { "22:11: Return from catch is not allowed.", @@ -249,12 +175,6 @@ public void testReturnFromCatch() throws Exception { @Test public void testReturnFromFinally() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DescendantTokenCheck.class); - - checkConfig.addProperty("tokens", "LITERAL_FINALLY"); - checkConfig.addProperty("limitedTokens", "LITERAL_RETURN"); - checkConfig.addProperty("maximumNumber", "0"); - checkConfig.addProperty("maximumMessage", "Return from finally is not allowed."); final String[] expected = { "22:11: Return from finally is not allowed.", @@ -267,12 +187,6 @@ public void testReturnFromFinally() throws Exception { @Test public void testNoSum() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DescendantTokenCheck.class); - - checkConfig.addProperty("tokens", "NOT_EQUAL, EQUAL"); - checkConfig.addProperty("limitedTokens", "LITERAL_THIS, LITERAL_NULL"); - checkConfig.addProperty("maximumNumber", "1"); - checkConfig.addProperty("maximumMessage", "What are you doing?"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -282,13 +196,6 @@ public void testNoSum() throws Exception { @Test public void testWithSumCustomMsg() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "NOT_EQUAL, EQUAL"); - checkConfig.addProperty("limitedTokens", "LITERAL_THIS, LITERAL_NULL"); - checkConfig.addProperty("maximumNumber", "1"); - checkConfig.addProperty("maximumDepth", "1"); - checkConfig.addProperty("maximumMessage", "this cannot be null."); - checkConfig.addProperty("sumTokenCounts", "true"); final String[] expected = { "37:32: this cannot be null.", @@ -303,12 +210,6 @@ public void testWithSumCustomMsg() throws Exception { @Test public void testWithSumDefaultMsg() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "NOT_EQUAL, EQUAL"); - checkConfig.addProperty("limitedTokens", "LITERAL_THIS, LITERAL_NULL"); - checkConfig.addProperty("maximumNumber", "1"); - checkConfig.addProperty("maximumDepth", "1"); - checkConfig.addProperty("sumTokenCounts", "true"); final String[] expected = { "37:32: " + getCheckMessage(MSG_KEY_SUM_MAX, 2, 1, "EQUAL"), @@ -323,11 +224,6 @@ public void testWithSumDefaultMsg() throws Exception { @Test public void testWithSumLessThenMinDefMsg() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "NOT_EQUAL, EQUAL"); - checkConfig.addProperty("limitedTokens", "LITERAL_THIS, LITERAL_NULL"); - checkConfig.addProperty("minimumNumber", "3"); - checkConfig.addProperty("sumTokenCounts", "true"); final String[] expected = { "31:44: " + getCheckMessage(MSG_KEY_SUM_MIN, 0, 3, "EQUAL"), @@ -345,12 +241,6 @@ public void testWithSumLessThenMinDefMsg() throws Exception { @Test public void testWithSumLessThenMinCustomMsg() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "NOT_EQUAL, EQUAL"); - checkConfig.addProperty("limitedTokens", "LITERAL_THIS, LITERAL_NULL"); - checkConfig.addProperty("minimumNumber", "3"); - checkConfig.addProperty("sumTokenCounts", "true"); - checkConfig.addProperty("minimumMessage", "custom message"); final String[] expected = { "31:44: custom message", @@ -368,12 +258,6 @@ public void testWithSumLessThenMinCustomMsg() throws Exception { @Test public void testMaxTokenType() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "OBJBLOCK"); - checkConfig.addProperty("limitedTokens", "LCURLY, RCURLY"); - checkConfig.addProperty("maximumNumber", "0"); - checkConfig.addProperty("maximumDepth", "2"); final String[] expected = { "21:48: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "OBJBLOCK", "LCURLY"), "21:48: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "OBJBLOCK", "RCURLY"), @@ -384,12 +268,6 @@ public void testMaxTokenType() throws Exception { @Test public void testMaxTokenTypeReverseOrder() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DescendantTokenCheck.class); - checkConfig.addProperty("tokens", "OBJBLOCK"); - checkConfig.addProperty("limitedTokens", "RCURLY, LCURLY"); - checkConfig.addProperty("maximumNumber", "0"); - checkConfig.addProperty("maximumDepth", "2"); final String[] expected = { "21:49: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "OBJBLOCK", "LCURLY"), "21:49: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "OBJBLOCK", "RCURLY"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckTest.java index f4bd1f95dc1..070938b48db 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckTest.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class FinalParametersCheckTest extends AbstractModuleTestSupport { @@ -36,8 +35,6 @@ protected String getPackageLocation() { @Test public void testDefaultTokens() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalParametersCheck.class); final String[] expected = { "27:26: " + getCheckMessage(MSG_KEY, "s"), "42:26: " + getCheckMessage(MSG_KEY, "i"), @@ -57,9 +54,6 @@ public void testDefaultTokens() throws Exception { @Test public void testCtorToken() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalParametersCheck.class); - checkConfig.addProperty("tokens", "CTOR_DEF"); final String[] expected = { "28:27: " + getCheckMessage(MSG_KEY, "s"), "43:27: " + getCheckMessage(MSG_KEY, "i"), @@ -71,9 +65,6 @@ public void testCtorToken() throws Exception { @Test public void testMethodToken() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalParametersCheck.class); - checkConfig.addProperty("tokens", "METHOD_DEF"); final String[] expected = { "58:17: " + getCheckMessage(MSG_KEY, "s"), "74:17: " + getCheckMessage(MSG_KEY, "s"), @@ -90,9 +81,6 @@ public void testMethodToken() throws Exception { @Test public void testCatchToken() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalParametersCheck.class); - checkConfig.addProperty("tokens", "LITERAL_CATCH"); final String[] expected = { "130:16: " + getCheckMessage(MSG_KEY, "npe"), "136:16: " + getCheckMessage(MSG_KEY, "e"), @@ -104,9 +92,6 @@ public void testCatchToken() throws Exception { @Test public void testForEachClauseToken() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalParametersCheck.class); - checkConfig.addProperty("tokens", "FOR_EACH_CLAUSE"); final String[] expected = { "157:13: " + getCheckMessage(MSG_KEY, "s"), "165:13: " + getCheckMessage(MSG_KEY, "s"), @@ -117,9 +102,6 @@ public void testForEachClauseToken() throws Exception { @Test public void testIgnorePrimitiveTypesParameters() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalParametersCheck.class); - checkConfig.addProperty("ignorePrimitiveTypes", "true"); final String[] expected = { "14:22: " + getCheckMessage(MSG_KEY, "k"), "15:15: " + getCheckMessage(MSG_KEY, "s"), @@ -135,8 +117,6 @@ public void testIgnorePrimitiveTypesParameters() throws Exception { @Test public void testPrimitiveTypesParameters() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalParametersCheck.class); final String[] expected = { "13:14: " + getCheckMessage(MSG_KEY, "i"), "14:15: " + getCheckMessage(MSG_KEY, "i"), @@ -159,8 +139,6 @@ public void testPrimitiveTypesParameters() throws Exception { @Test public void testReceiverParameters() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalParametersCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputFinalParametersReceiver.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckTest.java index 470f019f05d..d904a2580cc 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckTest.java @@ -54,9 +54,6 @@ protected String getPackageLocation() { @Test public void testNewlineLfAtEndOfFile() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NewlineAtEndOfFileCheck.class); - checkConfig.addProperty("lineSeparator", LineSeparatorOption.LF.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNewlineAtEndOfFileLf.java"), @@ -65,9 +62,6 @@ public void testNewlineLfAtEndOfFile() throws Exception { @Test public void testNewlineLfAtEndOfFileLfNotOverlapWithCrLf() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NewlineAtEndOfFileCheck.class); - checkConfig.addProperty("lineSeparator", LineSeparatorOption.LF.toString()); final String[] expected = { "1: " + getCheckMessage(MSG_KEY_WRONG_ENDING), }; @@ -78,9 +72,6 @@ public void testNewlineLfAtEndOfFileLfNotOverlapWithCrLf() throws Exception { @Test public void testNewlineCrlfAtEndOfFile() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NewlineAtEndOfFileCheck.class); - checkConfig.addProperty("lineSeparator", LineSeparatorOption.CRLF.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNewlineAtEndOfFileCrlf3.java"), @@ -89,9 +80,6 @@ public void testNewlineCrlfAtEndOfFile() throws Exception { @Test public void testNewlineCrAtEndOfFile() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NewlineAtEndOfFileCheck.class); - checkConfig.addProperty("lineSeparator", LineSeparatorOption.CR.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNewlineAtEndOfFileCr.java"), @@ -100,9 +88,6 @@ public void testNewlineCrAtEndOfFile() throws Exception { @Test public void testAnyNewlineAtEndOfFile() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NewlineAtEndOfFileCheck.class); - checkConfig.addProperty("lineSeparator", LineSeparatorOption.LF_CR_CRLF.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNewlineAtEndOfFileCrlf2.java"), @@ -117,9 +102,6 @@ public void testAnyNewlineAtEndOfFile() throws Exception { @Test public void testNoNewlineLfAtEndOfFile() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NewlineAtEndOfFileCheck.class); - checkConfig.addProperty("lineSeparator", LineSeparatorOption.LF.toString()); final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_NEWLINE_EOF), }; @@ -130,9 +112,6 @@ public void testNoNewlineLfAtEndOfFile() throws Exception { @Test public void testNoNewlineAtEndOfFile() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NewlineAtEndOfFileCheck.class); - checkConfig.addProperty("lineSeparator", LineSeparatorOption.LF_CR_CRLF.toString()); final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_NEWLINE_EOF), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/NoCodeInFileCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/NoCodeInFileCheckTest.java index aef616219fb..63164e9a995 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/NoCodeInFileCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/NoCodeInFileCheckTest.java @@ -71,7 +71,6 @@ public void testSingleLineComment() throws Exception { @Test public void testMultiLineComment() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoCodeInFileCheck.class); final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_CODE), }; @@ -81,7 +80,6 @@ public void testMultiLineComment() throws Exception { @Test public void testFileContainingCode() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoCodeInFileCheck.class); verifyWithInlineConfigParser( getPath("InputNoCodeInFile4.java"), CommonUtil.EMPTY_STRING_ARRAY); @@ -89,7 +87,6 @@ public void testFileContainingCode() throws Exception { @Test public void testBothSingleLineAndMultiLineComment() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoCodeInFileCheck.class); final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_CODE), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/OuterTypeFilenameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/OuterTypeFilenameCheckTest.java index 6efe7189c13..a38a4e29c99 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/OuterTypeFilenameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/OuterTypeFilenameCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -52,8 +51,6 @@ public void testGetRequiredTokens() { @Test public void testGood1() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOuterTypeFilenameIllegalTokens.java"), expected); @@ -61,8 +58,6 @@ public void testGood1() throws Exception { @Test public void testGood2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOuterTypeFilename15Extensions.java"), expected); @@ -84,7 +79,6 @@ public void testGetAcceptableTokens() { @Test public void testNestedClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOuterTypeFilename1.java"), expected); @@ -92,7 +86,6 @@ public void testNestedClass() throws Exception { @Test public void testNestedClass2() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), }; @@ -102,7 +95,6 @@ public void testNestedClass2() throws Exception { @Test public void testFinePublic() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOuterTypeFilename2.java"), expected); @@ -110,7 +102,6 @@ public void testFinePublic() throws Exception { @Test public void testPublicClassIsNotFirst() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOuterTypeFilenameCheckPublic.java"), expected); @@ -118,7 +109,6 @@ public void testPublicClassIsNotFirst() throws Exception { @Test public void testNoPublicClasses() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), }; @@ -128,7 +118,6 @@ public void testNoPublicClasses() throws Exception { @Test public void testFineDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOuterTypeFilename3.java"), expected); @@ -136,7 +125,6 @@ public void testFineDefault() throws Exception { @Test public void testWrongDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = { "10:2: " + getCheckMessage(MSG_KEY), }; @@ -146,7 +134,6 @@ public void testWrongDefault() throws Exception { @Test public void testPackageAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -156,7 +143,6 @@ public void testPackageAnnotation() throws Exception { @Test public void testOuterTypeFilenameRecords() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = { "10:1: " + getCheckMessage(MSG_KEY), @@ -168,7 +154,6 @@ public void testOuterTypeFilenameRecords() throws Exception { @Test public void testOuterTypeFilenameRecordsMethodRecordDef() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String[] expected = { "10:1: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/TodoCommentCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/TodoCommentCheckTest.java index 778b8728194..8284ca6fe7e 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/TodoCommentCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/TodoCommentCheckTest.java @@ -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 TodoCommentCheckTest @@ -47,9 +46,6 @@ public void testGetRequiredTokens() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(TodoCommentCheck.class); - checkConfig.addProperty("format", "FIXME:"); final String[] expected = { "1:3: " + getCheckMessage(MSG_KEY, "FIXME:"), "164:7: " + getCheckMessage(MSG_KEY, "FIXME:"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheckTest.java index 5d34f19d40f..a14a92ca45c 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheckTest.java @@ -25,7 +25,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 TrailingCommentCheckTest extends AbstractModuleTestSupport { @@ -55,7 +54,6 @@ public void testGetAcceptableTokens() { @Test public void testDefaults() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(TrailingCommentCheck.class); final String[] expected = { "13:12: " + getCheckMessage(MSG_KEY), "17:12: " + getCheckMessage(MSG_KEY), @@ -72,8 +70,6 @@ public void testDefaults() throws Exception { @Test public void testLegalComment() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(TrailingCommentCheck.class); - checkConfig.addProperty("legalComment", "^NOI18N$"); final String[] expected = { "13:12: " + getCheckMessage(MSG_KEY), "17:12: " + getCheckMessage(MSG_KEY), @@ -88,8 +84,6 @@ public void testLegalComment() throws Exception { @Test public void testFormat() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(TrailingCommentCheck.class); - checkConfig.addProperty("format", "NOT MATCH"); final String[] expected = { "1:1: " + getCheckMessage(MSG_KEY), "12:12: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/UncommentedMainCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/UncommentedMainCheckTest.java index 5f84d8469f7..99835456391 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/UncommentedMainCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/UncommentedMainCheckTest.java @@ -29,7 +29,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -45,8 +44,6 @@ protected String getPackageLocation() { @Test public void testDefaults() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UncommentedMainCheck.class); final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY), "26:5: " + getCheckMessage(MSG_KEY), @@ -60,9 +57,6 @@ public void testDefaults() @Test public void testExcludedClasses() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UncommentedMainCheck.class); - checkConfig.addProperty("excludedClasses", "\\.Main.*$"); final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY), "35:5: " + getCheckMessage(MSG_KEY), @@ -85,7 +79,6 @@ public void testTokens() { @Test public void testDeepDepth() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UncommentedMainCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputUncommentedMain2.java"), expected); @@ -93,8 +86,6 @@ public void testDeepDepth() throws Exception { @Test public void testVisitPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UncommentedMainCheck.class); - checkConfig.addProperty("excludedClasses", "uncommentedmain\\.InputUncommentedMain5"); final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY), }; @@ -104,7 +95,6 @@ public void testVisitPackage() throws Exception { @Test public void testWrongName() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UncommentedMainCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputUncommentedMain3.java"), expected); @@ -112,7 +102,6 @@ public void testWrongName() throws Exception { @Test public void testWrongArrayType() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UncommentedMainCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputUncommentedMain4.java"), expected); @@ -135,7 +124,6 @@ public void testIllegalStateException() { @Test public void testRecords() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UncommentedMainCheck.class); final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/UpperEllCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/UpperEllCheckTest.java index 4e2020c75dd..882bc6ebfa0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/UpperEllCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/UpperEllCheckTest.java @@ -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 UpperEllCheckTest @@ -48,8 +47,6 @@ public void testGetRequiredTokens() { @Test public void testWithChecker() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UpperEllCheck.class); final String[] expected = { "96:40: " + getCheckMessage(MSG_KEY), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheckTest.java index 2547e6bbdb7..068a514c8f0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheckTest.java @@ -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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -46,7 +45,6 @@ public void testGetRequiredTokens() { @Test public void testCorrect() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -55,7 +53,6 @@ public void testCorrect() throws Exception { @Test public void testIncorrect() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); final String[] expected = { "14:11: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnn"), "19:15: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation1"), @@ -88,10 +85,6 @@ public void testIncorrect() throws Exception { @Test public void testIncorrectAllTokens() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("tokens", "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, " - + "CTOR_DEF, VARIABLE_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF, " - + "ENUM_CONSTANT_DEF, PACKAGE_DEF"); final String[] expected = { "14:11: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnn3"), "19:15: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation_13"), @@ -145,7 +138,6 @@ public void testGetAcceptableTokens() { @Test public void testWithoutAnnotations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputAnnotationLocationEmpty.java"), expected); @@ -153,10 +145,6 @@ public void testWithoutAnnotations() throws Exception { @Test public void testWithParameters() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("allowSamelineSingleParameterlessAnnotation", "true"); - checkConfig.addProperty("allowSamelineParameterizedAnnotation", "true"); - checkConfig.addProperty("allowSamelineMultipleAnnotations", "true"); final String[] expected = { "25:9: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation_12", 8, 4), "33:9: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation_12", 8, 4), @@ -178,8 +166,6 @@ public void testWithParameters() throws Exception { @Test public void testWithMultipleAnnotations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("allowSamelineSingleParameterlessAnnotation", "false"); final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation11"), "14:17: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation12"), @@ -192,9 +178,6 @@ public void testWithMultipleAnnotations() throws Exception { @Test public void testAllTokens() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("tokens", "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, " - + "CTOR_DEF, VARIABLE_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputAnnotationLocationWithoutAnnotations.java"), expected); @@ -202,8 +185,6 @@ public void testAllTokens() throws Exception { @Test public void testAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("tokens", "ANNOTATION_DEF, ANNOTATION_FIELD_DEF"); final String[] expected = { "18:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "AnnotationAnnotation", 2, 0), "19:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "AnnotationAnnotation"), @@ -216,8 +197,6 @@ public void testAnnotation() throws Exception { @Test public void testClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("tokens", "CLASS_DEF, CTOR_DEF, VARIABLE_DEF"); final String[] expected = { "18:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "ClassAnnotation", 2, 0), "19:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "ClassAnnotation"), @@ -232,8 +211,6 @@ public void testClass() throws Exception { @Test public void testEnum() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("tokens", "ENUM_DEF, ENUM_CONSTANT_DEF"); final String[] expected = { "18:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "EnumAnnotation", 2, 0), "19:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "EnumAnnotation"), @@ -246,8 +223,6 @@ public void testEnum() throws Exception { @Test public void testInterface() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("tokens", "INTERFACE_DEF, METHOD_DEF"); final String[] expected = { "18:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "InterfaceAnnotation", 2, 0), "19:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "InterfaceAnnotation"), @@ -260,8 +235,6 @@ public void testInterface() throws Exception { @Test public void testPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("tokens", "PACKAGE_DEF"); final String[] expected = { "12:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "PackageAnnotation", 2, 0), "13:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "PackageAnnotation"), @@ -272,12 +245,6 @@ public void testPackage() throws Exception { @Test public void testAnnotationInForEachLoopParameterAndVariableDef() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("tokens", "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF," - + " CTOR_DEF, VARIABLE_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF"); - checkConfig.addProperty("allowSamelineMultipleAnnotations", "false"); - checkConfig.addProperty("allowSamelineSingleParameterlessAnnotation", "false"); - checkConfig.addProperty("allowSamelineParameterizedAnnotation", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputAnnotationLocationDeprecatedAndCustom.java"), expected); @@ -285,10 +252,6 @@ public void testAnnotationInForEachLoopParameterAndVariableDef() throws Exceptio @Test public void testAnnotationMultiple() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("allowSamelineMultipleAnnotations", "true"); - checkConfig.addProperty("allowSamelineSingleParameterlessAnnotation", "false"); - checkConfig.addProperty("allowSamelineParameterizedAnnotation", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputAnnotationLocationMultiple.java"), expected); @@ -296,10 +259,6 @@ public void testAnnotationMultiple() throws Exception { @Test public void testAnnotationParameterized() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("allowSamelineMultipleAnnotations", "false"); - checkConfig.addProperty("allowSamelineSingleParameterlessAnnotation", "false"); - checkConfig.addProperty("allowSamelineParameterizedAnnotation", "true"); final String[] expected = { "18:5: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "Annotation"), "20:5: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "Annotation"), @@ -315,10 +274,6 @@ public void testAnnotationParameterized() throws Exception { @Test public void testAnnotationSingleParameterless() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); - checkConfig.addProperty("allowSamelineMultipleAnnotations", "false"); - checkConfig.addProperty("allowSamelineSingleParameterlessAnnotation", "true"); - checkConfig.addProperty("allowSamelineParameterizedAnnotation", "false"); final String[] expected = { "22:17: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "Annotation"), "24:5: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "Annotation"), @@ -334,7 +289,6 @@ public void testAnnotationSingleParameterless() throws Exception { @Test public void testAnnotationLocationRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationLocationCheck.class); final String[] expected = { "19:5: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "SuppressWarnings"), "22:5: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "SuppressWarnings"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationOnSameLineCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationOnSameLineCheckTest.java index 77775c62c61..eca88af1dda 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationOnSameLineCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationOnSameLineCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -71,7 +70,6 @@ public void testGetAcceptableTokens() { @Test public void testCheck() throws Exception { - final DefaultConfiguration config = createModuleConfig(AnnotationOnSameLineCheck.class); final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Annotation"), "18:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Annotation"), @@ -84,11 +82,6 @@ public void testCheck() throws Exception { @Test public void testCheckAcceptableTokens() throws Exception { - final DefaultConfiguration config = createModuleConfig(AnnotationOnSameLineCheck.class); - config.addProperty("tokens", "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, " - + "CTOR_DEF, VARIABLE_DEF, PARAMETER_DEF, ANNOTATION_DEF, TYPECAST, " - + "LITERAL_THROWS, IMPLEMENTS_CLAUSE, TYPE_ARGUMENT, LITERAL_NEW, DOT, " - + "ANNOTATION_FIELD_DEF"); final String[] expected = { "18:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Annotation3"), "19:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Annotation"), @@ -101,7 +94,6 @@ public void testCheckAcceptableTokens() throws Exception { @Test public void testCheck2() throws Exception { - final DefaultConfiguration config = createModuleConfig(AnnotationOnSameLineCheck.class); final String[] expected = { "19:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Ann"), "24:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "SuppressWarnings"), @@ -114,11 +106,6 @@ public void testCheck2() throws Exception { @Test public void testCheckOnDifferentTokens() throws Exception { - final DefaultConfiguration config = createModuleConfig(AnnotationOnSameLineCheck.class); - config.addProperty("tokens", "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, " - + "CTOR_DEF, VARIABLE_DEF, PARAMETER_DEF, ANNOTATION_DEF, TYPECAST, " - + "LITERAL_THROWS, IMPLEMENTS_CLAUSE, TYPE_ARGUMENT, LITERAL_NEW, DOT, " - + "ANNOTATION_FIELD_DEF"); final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Ann"), "17:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Ann"), @@ -143,10 +130,6 @@ public void testCheckOnDifferentTokens() throws Exception { @Test public void testAnnotationOnSameLineRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration config = createModuleConfig(AnnotationOnSameLineCheck.class); - config.addProperty("tokens", "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF," - + " CTOR_DEF, VARIABLE_DEF, RECORD_DEF, COMPACT_CTOR_DEF"); - final String[] expected = { "13:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "NonNull1"), "17:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "SuppressWarnings"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheckTest.java index 24803d9d355..33572ff8314 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheckTest.java @@ -32,7 +32,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -81,7 +80,6 @@ public void testClosingParensOptionValueOf() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); final String[] expected = { "13:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), "14:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), @@ -108,10 +106,6 @@ public void testDefault() throws Exception { */ @Test public void testParensAlways() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "always"); - checkConfig.addProperty("elementStyle", "ignore"); - checkConfig.addProperty("trailingArrayComma", "ignore"); final String[] expected = { "12:1: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_MISSING), "27:1: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_MISSING), @@ -131,10 +125,6 @@ public void testParensAlways() throws Exception { */ @Test public void testParensNever() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "NEVER"); - checkConfig.addProperty("elementStyle", "ignore"); - checkConfig.addProperty("trailingArrayComma", "ignore"); final String[] expected = { "22:1: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_PRESENT), "39:1: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_PRESENT), @@ -149,10 +139,6 @@ public void testParensNever() throws Exception { @Test public void testStyleExpanded() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "ignore"); - checkConfig.addProperty("elementStyle", "EXPANDED"); - checkConfig.addProperty("trailingArrayComma", "ignore"); final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), "21:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), @@ -172,10 +158,6 @@ public void testStyleExpanded() throws Exception { @Test public void testStyleCompact() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "ignore"); - checkConfig.addProperty("elementStyle", "COMPACT"); - checkConfig.addProperty("trailingArrayComma", "ignore"); final String[] expected = { "52:5: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT"), "56:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT"), @@ -190,10 +172,6 @@ public void testStyleCompact() throws Exception { @Test public void testStyleCompactNoArray() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "ignore"); - checkConfig.addProperty("elementStyle", "compact_no_array"); - checkConfig.addProperty("trailingArrayComma", "ignore"); final String[] expected = { "13:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), "14:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), @@ -212,10 +190,6 @@ public void testStyleCompactNoArray() throws Exception { @Test public void testCommaAlwaysViolations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "ignore"); - checkConfig.addProperty("elementStyle", "ignore"); - checkConfig.addProperty("trailingArrayComma", "ALWAYS"); final String[] expected = { "12:20: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), "15:30: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), @@ -238,10 +212,6 @@ public void testCommaAlwaysViolations() throws Exception { @Test public void testCommaAlwaysViolationsNonCompilable() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "ignore"); - checkConfig.addProperty("elementStyle", "ignore"); - checkConfig.addProperty("trailingArrayComma", "ALWAYS"); final String[] expected = { "15:37: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), "15:65: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), @@ -253,10 +223,6 @@ public void testCommaAlwaysViolationsNonCompilable() throws Exception { @Test public void testCommaAlwaysNoViolations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "ignore"); - checkConfig.addProperty("elementStyle", "ignore"); - checkConfig.addProperty("trailingArrayComma", "ALWAYS"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -265,10 +231,6 @@ public void testCommaAlwaysNoViolations() throws Exception { @Test public void testCommaAlwaysNoViolationsNonCompilable() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "ignore"); - checkConfig.addProperty("elementStyle", "ignore"); - checkConfig.addProperty("trailingArrayComma", "ALWAYS"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -277,8 +239,6 @@ public void testCommaAlwaysNoViolationsNonCompilable() throws Exception { @Test public void testTrailingArrayIgnore() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("trailingArrayComma", "ignore"); final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), "22:13: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), @@ -292,10 +252,6 @@ public void testTrailingArrayIgnore() throws Exception { @Test public void testCommaNeverViolations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "ignore"); - checkConfig.addProperty("elementStyle", "ignore"); - checkConfig.addProperty("trailingArrayComma", "NEVER"); final String[] expected = { "15:32: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), "19:42: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), @@ -313,10 +269,6 @@ public void testCommaNeverViolations() throws Exception { @Test public void testCommaNeverNoViolations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "ignore"); - checkConfig.addProperty("elementStyle", "ignore"); - checkConfig.addProperty("trailingArrayComma", "NEVER"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -325,10 +277,6 @@ public void testCommaNeverNoViolations() throws Exception { @Test public void testEverythingMixed() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "ignore"); - checkConfig.addProperty("elementStyle", "ignore"); - checkConfig.addProperty("trailingArrayComma", "ignore"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -337,8 +285,6 @@ public void testEverythingMixed() throws Exception { @Test public void testAnnotationsWithoutDefaultValues() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "never"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -370,10 +316,6 @@ public void testGetOption() { @Test public void testStyleNotInList() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AnnotationUseStyleCheck.class); - checkConfig.addProperty("closingParens", "ignore"); - checkConfig.addProperty("elementStyle", "compact_no_array"); - checkConfig.addProperty("trailingArrayComma", "ignore"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheckTest.java index 0e280e82fb0..4283d6593c2 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheckTest.java @@ -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.JavadocTokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -64,7 +63,6 @@ public void testGetRequiredJavadocTokens() { */ @Test public void testBadDeprecatedAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingDeprecatedCheck.class); final String[] expected = { "14: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), @@ -87,7 +85,6 @@ public void testBadDeprecatedAnnotation() throws Exception { */ @Test public void testBadDeprecatedJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingDeprecatedCheck.class); final String[] expected = { "18: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), @@ -106,7 +103,6 @@ public void testBadDeprecatedJavadoc() throws Exception { */ @Test public void testSpecialCaseDeprecated() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingDeprecatedCheck.class); final String[] expected = { "12: " + getCheckMessage(MSG_KEY_JAVADOC_DUPLICATE_TAG, "@deprecated"), @@ -130,7 +126,6 @@ public void testSpecialCaseDeprecated() throws Exception { */ @Test public void testGoodDeprecated() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingDeprecatedCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -140,7 +135,6 @@ public void testGoodDeprecated() throws Exception { @Test public void testTwoInJavadocWithoutAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingDeprecatedCheck.class); final String[] expected = { "15: " + getCheckMessage(MSG_KEY_JAVADOC_DUPLICATE_TAG, "@deprecated"), @@ -153,7 +147,6 @@ public void testTwoInJavadocWithoutAnnotation() throws Exception { @Test public void testEmptyJavadocLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingDeprecatedCheck.class); final String[] expected = { "18: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), @@ -165,7 +158,6 @@ public void testEmptyJavadocLine() throws Exception { @Test public void testPackageInfo() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingDeprecatedCheck.class); final String[] expected = { "9: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), @@ -177,7 +169,6 @@ public void testPackageInfo() throws Exception { @Test public void testDepPackageInfoBelowComment() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingDeprecatedCheck.class); final String[] expected = { "14: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), @@ -189,7 +180,6 @@ public void testDepPackageInfoBelowComment() throws Exception { @Test public void testPackageInfoBelowComment() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingDeprecatedCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckTest.java index a5ac18950aa..dec13feee91 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckTest.java @@ -27,7 +27,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -44,7 +43,6 @@ protected String getPackageLocation() { */ @Test public void testBadOverrideFromObject() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), @@ -63,8 +61,6 @@ public void testBadOverrideFromObject() throws Exception { */ @Test public void testBadOverrideFromObjectJ5Compatible() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); - checkConfig.addProperty("javaFiveCompatibility", "true"); final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), @@ -83,7 +79,6 @@ public void testBadOverrideFromObjectJ5Compatible() throws Exception { */ @Test public void testBadOverrideFromOther() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), "33:5: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), @@ -104,8 +99,6 @@ public void testBadOverrideFromOther() throws Exception { */ @Test public void testBadOverrideFromOtherJ5Compatible() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); - checkConfig.addProperty("javaFiveCompatibility", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -119,7 +112,6 @@ public void testBadOverrideFromOtherJ5Compatible() throws Exception { */ @Test public void testBadAnnotationOverride() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); final String[] expected = { "17:9: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), "23:17: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), @@ -137,8 +129,6 @@ public void testBadAnnotationOverride() throws Exception { */ @Test public void testBadAnnotationOverrideJ5Compatible() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); - checkConfig.addProperty("javaFiveCompatibility", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -150,7 +140,6 @@ public void testBadAnnotationOverrideJ5Compatible() throws Exception { */ @Test public void testNotOverride() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY_TAG_NOT_VALID_ON, "{@inheritDoc}"), "20:5: " + getCheckMessage(MSG_KEY_TAG_NOT_VALID_ON, "{@inheritDoc}"), @@ -166,8 +155,6 @@ public void testNotOverride() throws Exception { */ @Test public void testGoodOverrideFromObject() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); - checkConfig.addProperty("javaFiveCompatibility", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -181,8 +168,6 @@ public void testGoodOverrideFromObject() throws Exception { */ @Test public void testGoodOverrideFromObjectJ5Compatible() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); - checkConfig.addProperty("javaFiveCompatibility", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -196,7 +181,6 @@ public void testGoodOverrideFromObjectJ5Compatible() throws Exception { */ @Test public void testGoodOverrideFromOther() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -209,8 +193,6 @@ public void testGoodOverrideFromOther() throws Exception { */ @Test public void testGoodOverrideFromOtherJ5Compatible() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); - checkConfig.addProperty("javaFiveCompatibility", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -224,7 +206,6 @@ public void testGoodOverrideFromOtherJ5Compatible() throws Exception { */ @Test public void testGoodAnnotationOverride() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -237,8 +218,6 @@ public void testGoodAnnotationOverride() throws Exception { */ @Test public void testGoodAnnotationOverrideJ5Compatible() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MissingOverrideCheck.class); - checkConfig.addProperty("javaFiveCompatibility", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/PackageAnnotationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/PackageAnnotationCheckTest.java index 88de4c28a7f..f43533ef9fc 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/PackageAnnotationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/PackageAnnotationCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -41,7 +40,6 @@ protected String getPackageLocation() { */ @Test public void testGoodPackageAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageAnnotationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -59,7 +57,6 @@ public void testGetAcceptableTokens() { @Test public void testNoPackageAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageAnnotationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -69,7 +66,6 @@ public void testNoPackageAnnotation() throws Exception { @Test public void testBadPackageAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageAnnotationCheck.class); final String[] expected = { "10:1: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckTest.java index 4ce9955c995..2decdf02b7f 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckTest.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { @@ -39,7 +38,6 @@ protected String getPackageLocation() { */ @Test public void testSingleDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); final String[] expected = { "18:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), @@ -62,8 +60,6 @@ public void testSingleDefault() throws Exception { */ @Test public void testSingleAll() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", ".*"); final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -105,8 +101,6 @@ public void testSingleAll() throws Exception { */ @Test public void testSingleNoUnchecked() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*"); final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -130,9 +124,6 @@ public void testSingleNoUnchecked() throws Exception { */ @Test public void testSingleNoUncheckedTokens() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*"); - checkConfig.addProperty("tokens", "CLASS_DEF,METHOD_DEF"); final String[] expected = { "13:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -153,8 +144,6 @@ public void testSingleNoUncheckedTokens() throws Exception { */ @Test public void testSingleNoUnWildcard() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", ".*un.*"); final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -187,8 +176,6 @@ public void testSingleNoUnWildcard() throws Exception { */ @Test public void testSingleNoUncheckedUnused() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*|^unused$"); final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -218,8 +205,6 @@ public void testSingleNoUncheckedUnused() throws Exception { */ @Test public void testSingleNoUncheckedUnusedAll() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*|^unused$*|.*"); final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -261,7 +246,6 @@ public void testSingleNoUncheckedUnusedAll() throws Exception { */ @Test public void testCompactDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); final String[] expected = { "18:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), @@ -276,7 +260,6 @@ public void testCompactDefault() throws Exception { @Test public void testCompactDefaultNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); final String[] expected = { "18:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), @@ -306,8 +289,6 @@ public void testCompactDefaultNonConstant() throws Exception { */ @Test public void testCompactAll() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", ".*"); final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -335,8 +316,6 @@ public void testCompactAll() throws Exception { @Test public void testCompactAllNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", ".*"); final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -397,8 +376,6 @@ public void testCompactAllNonConstant() throws Exception { */ @Test public void testCompactNoUnchecked() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*"); final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -417,9 +394,6 @@ public void testCompactNoUnchecked() throws Exception { */ @Test public void testCompactNoUncheckedTokens() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*"); - checkConfig.addProperty("tokens", "CLASS_DEF"); final String[] expected = { "13:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -431,9 +405,6 @@ public void testCompactNoUncheckedTokens() throws Exception { @Test public void testCompactNoUncheckedTokensNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*"); - checkConfig.addProperty("tokens", "CLASS_DEF"); final String[] expected = { "13:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -451,8 +422,6 @@ public void testCompactNoUncheckedTokensNonConstant() throws Exception { */ @Test public void testCompactNoUnWildcard() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "un.*"); final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -473,8 +442,6 @@ public void testCompactNoUnWildcard() throws Exception { @Test public void testCompactNoUnWildcardNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "un.*"); final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -516,8 +483,6 @@ public void testCompactNoUnWildcardNonConstant() throws Exception { */ @Test public void testCompactNoUncheckedUnused() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*|^unused$"); final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -537,8 +502,6 @@ public void testCompactNoUncheckedUnused() throws Exception { @Test public void testCompactNoUncheckedUnusedNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*|^unused$"); final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -574,8 +537,6 @@ public void testCompactNoUncheckedUnusedNonConstant() throws Exception { */ @Test public void testCompactNoUncheckedUnusedAll() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*|^unused$*|.*"); final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -603,8 +564,6 @@ public void testCompactNoUncheckedUnusedAll() throws Exception { @Test public void testCompactNoUncheckedUnusedAllNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*|^unused$*|.*"); final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -665,7 +624,6 @@ public void testCompactNoUncheckedUnusedAllNonConstant() throws Exception { */ @Test public void testExpandedDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); final String[] expected = { "18:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), @@ -680,7 +638,6 @@ public void testExpandedDefault() throws Exception { @Test public void testExpandedDefaultNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); final String[] expected = { "18:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), @@ -708,8 +665,6 @@ public void testExpandedDefaultNonConstant() throws Exception { */ @Test public void testExpandedAll() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", ".*"); final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -737,8 +692,6 @@ public void testExpandedAll() throws Exception { @Test public void testExpandedAllNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", ".*"); final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -795,8 +748,6 @@ public void testExpandedAllNonConstant() throws Exception { */ @Test public void testExpandedNoUnchecked() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*"); final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -812,8 +763,6 @@ public void testExpandedNoUnchecked() throws Exception { @Test public void testExpandedNoUncheckedNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*"); final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -841,9 +790,6 @@ public void testExpandedNoUncheckedNonConstant() throws Exception { */ @Test public void testExpandedNoUncheckedTokens() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*"); - checkConfig.addProperty("tokens", "CLASS_DEF"); final String[] expected = { "13:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -855,9 +801,6 @@ public void testExpandedNoUncheckedTokens() throws Exception { @Test public void testExpandedNoUncheckedTokensNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*"); - checkConfig.addProperty("tokens", "CLASS_DEF"); final String[] expected = { "13:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -875,8 +818,6 @@ public void testExpandedNoUncheckedTokensNonConstant() throws Exception { */ @Test public void testExpandedNoUnWildcard() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "un.*"); final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -897,8 +838,6 @@ public void testExpandedNoUnWildcard() throws Exception { @Test public void testExpandedNoUnWildcardNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "un.*"); final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -936,8 +875,6 @@ public void testExpandedNoUnWildcardNonConstant() throws Exception { */ @Test public void testExpandedNoUncheckedUnused() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*|^unused$"); final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -957,8 +894,6 @@ public void testExpandedNoUncheckedUnused() throws Exception { @Test public void testExpandedNoUncheckedUnusedNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*|^unused$"); final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -995,8 +930,6 @@ public void testExpandedNoUncheckedUnusedNonConstant() throws Exception { */ @Test public void testExpandedNoUncheckedUnusedAll() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*|^unused$*|.*"); final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -1024,8 +957,6 @@ public void testExpandedNoUncheckedUnusedAll() throws Exception { @Test public void testExpandedNoUncheckedUnusedAllNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*|^unused$*|.*"); final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -1079,7 +1010,6 @@ public void testExpandedNoUncheckedUnusedAllNonConstant() throws Exception { @Test public void testUncheckedInConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -1089,7 +1019,6 @@ public void testUncheckedInConstant() throws Exception { @Test public void testValuePairAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -1099,7 +1028,6 @@ public void testValuePairAnnotation() throws Exception { @Test public void testWorkingProperlyOnComplexAnnotations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); final String[] expected = { "30:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), @@ -1113,7 +1041,6 @@ public void testWorkingProperlyOnComplexAnnotations() throws Exception { @Test public void testWorkingProperlyOnComplexAnnotationsNonConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); final String[] expected = { "30:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), @@ -1128,8 +1055,6 @@ public void testWorkingProperlyOnComplexAnnotationsNonConstant() throws Exceptio @Test public void testSuppressWarningsRecords() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SuppressWarningsCheck.class); - checkConfig.addProperty("format", "^unchecked$*|^unused$*|.*"); final String[] expected = { "24:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheckTest.java index a2feff486d7..488641b5a6a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheckTest.java @@ -25,7 +25,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 AvoidNestedBlocksCheckTest @@ -47,8 +46,6 @@ public void testGetRequiredTokens() { @Test public void testStrictSettings() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidNestedBlocksCheck.class); final String[] expected = { "25:9: " + getCheckMessage(MSG_KEY_BLOCK_NESTED), "47:17: " + getCheckMessage(MSG_KEY_BLOCK_NESTED), @@ -62,9 +59,6 @@ public void testStrictSettings() @Test public void testAllowSwitchInCase() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidNestedBlocksCheck.class); - checkConfig.addProperty("allowInSwitchCase", "true"); final String[] expected = { "21:9: " + getCheckMessage(MSG_KEY_BLOCK_NESTED), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyBlockCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyBlockCheckTest.java index 7a08cb309e2..3d23da5146a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyBlockCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyBlockCheckTest.java @@ -27,7 +27,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.CheckstyleException; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -52,8 +51,6 @@ public void testBlockOptionValueOf() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EmptyBlockCheck.class); final String[] expected = { "38:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), "40:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), @@ -71,9 +68,6 @@ public void testDefault() @Test public void testText() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EmptyBlockCheck.class); - checkConfig.addProperty("option", BlockOption.TEXT.toString()); final String[] expected = { "38:13: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "try"), "40:17: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "finally"), @@ -88,9 +82,6 @@ public void testText() @Test public void testStatement() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EmptyBlockCheck.class); - checkConfig.addProperty("option", BlockOption.STATEMENT.toString()); final String[] expected = { "38:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), "40:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), @@ -107,12 +98,6 @@ public void testStatement() @Test public void allowEmptyLoops() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EmptyBlockCheck.class); - checkConfig.addProperty("option", BlockOption.STATEMENT.toString()); - checkConfig.addProperty("tokens", "LITERAL_TRY, LITERAL_CATCH, " - + "LITERAL_FINALLY, LITERAL_DO, LITERAL_IF, " - + "LITERAL_ELSE, INSTANCE_INIT, STATIC_INIT, LITERAL_SWITCH"); final String[] expected = { "21:21: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), "24:34: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), @@ -125,12 +110,6 @@ public void allowEmptyLoops() throws Exception { @Test public void allowEmptyLoopsText() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EmptyBlockCheck.class); - checkConfig.addProperty("option", BlockOption.TEXT.toString()); - checkConfig.addProperty("tokens", "LITERAL_TRY, LITERAL_CATCH," - + " LITERAL_FINALLY, LITERAL_DO, LITERAL_IF," - + " LITERAL_ELSE, INSTANCE_INIT, STATIC_INIT, LITERAL_SWITCH"); final String[] expected = { "26:21: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "if"), "29:34: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "if"), @@ -143,8 +122,6 @@ public void allowEmptyLoopsText() throws Exception { @Test public void testInvalidOption() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyBlockCheck.class); - checkConfig.addProperty("option", "invalid_option"); try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -164,9 +141,6 @@ public void testInvalidOption() throws Exception { @Test public void testAllowEmptyCaseWithText() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyBlockCheck.class); - checkConfig.addProperty("option", BlockOption.TEXT.toString()); - checkConfig.addProperty("tokens", "LITERAL_CASE"); final String[] expected = { "16:28: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "case"), "22:13: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "case"), @@ -180,9 +154,6 @@ public void testAllowEmptyCaseWithText() throws Exception { @Test public void testForbidCaseWithoutStmt() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyBlockCheck.class); - checkConfig.addProperty("option", BlockOption.STATEMENT.toString()); - checkConfig.addProperty("tokens", "LITERAL_CASE"); final String[] expected = { "16:28: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "case"), "22:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "case"), @@ -198,9 +169,6 @@ public void testForbidCaseWithoutStmt() throws Exception { @Test public void testAllowEmptyDefaultWithText() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyBlockCheck.class); - checkConfig.addProperty("option", BlockOption.TEXT.toString()); - checkConfig.addProperty("tokens", "LITERAL_DEFAULT"); final String[] expected = { "15:30: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "default"), "21:13: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "default"), @@ -215,9 +183,6 @@ public void testAllowEmptyDefaultWithText() throws Exception { @Test public void testForbidDefaultWithoutStatement() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyBlockCheck.class); - checkConfig.addProperty("option", BlockOption.STATEMENT.toString()); - checkConfig.addProperty("tokens", "LITERAL_DEFAULT"); final String[] expected = { "15:30: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "default"), "21:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "default"), @@ -235,9 +200,6 @@ public void testForbidDefaultWithoutStatement() throws Exception { @Test public void testAnnotationDefaultKeyword() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyBlockCheck.class); - checkConfig.addProperty("option", BlockOption.STATEMENT.toString()); - checkConfig.addProperty("tokens", "LITERAL_DEFAULT"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final String path = getPath("InputEmptyBlockAnnotationDefaultKeyword.java"); verifyWithInlineConfigParser( @@ -246,13 +208,9 @@ public void testAnnotationDefaultKeyword() throws Exception { @Test public void testEmptyBlockSwitchExpressions() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyBlockCheck.class); - checkConfig.addProperty("tokens", - "LITERAL_DEFAULT, LITERAL_CASE, LITERAL_SWITCH"); - final String[] expected = { "17:30: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "default"), - }; + }; verifyWithInlineConfigParser( getNonCompilablePath("InputEmptyBlockSwitchExpressions.java"), expected); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheckTest.java index 0df6e460c67..979b66aab67 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheckTest.java @@ -25,7 +25,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 EmptyCatchBlockCheckTest extends AbstractModuleTestSupport { @@ -45,8 +44,6 @@ public void testGetRequiredTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EmptyCatchBlockCheck.class); final String[] expected = { "25:31: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), "32:83: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), @@ -57,10 +54,6 @@ public void testDefault() throws Exception { @Test public void testWithUserSetValues() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EmptyCatchBlockCheck.class); - checkConfig.addProperty("exceptionVariableName", "expected|ignore|myException"); - checkConfig.addProperty("commentFormat", "This is expected"); final String[] expected = { "26:31: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), "54:78: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), @@ -77,10 +70,6 @@ public void testWithUserSetValues() throws Exception { @Test public void testLinesAreProperlySplitSystemIndependently() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EmptyCatchBlockCheck.class); - checkConfig.addProperty("exceptionVariableName", "expected|ignore|myException"); - checkConfig.addProperty("commentFormat", "This is expected"); final String[] expected = { "25:31: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), "53:78: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckTest.java index 135d2765bc1..8bab354d439 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckTest.java @@ -29,7 +29,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.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -60,7 +59,6 @@ public void testGetRequiredTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "19:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -74,8 +72,6 @@ public void testDefault() throws Exception { @Test public void testNl() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NL.toString()); final String[] expected = { "36:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14), "40:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14), @@ -94,8 +90,6 @@ public void testNl() throws Exception { @Test public void testNlow() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NLOW.toString()); final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "19:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -116,7 +110,6 @@ public void testNlow() throws Exception { @Test public void testDefault2() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "22:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -140,8 +133,6 @@ public void testDefault2() throws Exception { @Test public void testNewline2() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NL.toString()); final String[] expected = { "19:44: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 44), "26:20: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 20), @@ -158,7 +149,6 @@ public void testNewline2() throws Exception { @Test public void testDefault3() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "20:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -193,8 +183,6 @@ public void testDefault3() throws Exception { @Test public void testNewline3() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NL.toString()); final String[] expected = { "31:33: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 33), "96:19: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 19), @@ -209,7 +197,6 @@ public void testNewline3() throws Exception { @Test public void testMissingBraces() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "20:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -225,7 +212,6 @@ public void testMissingBraces() throws Exception { @Test public void testDefaultWithAnnotations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); final String[] expected = { "23:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "27:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -240,8 +226,6 @@ public void testDefaultWithAnnotations() throws Exception { @Test public void testNlWithAnnotations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NL.toString()); final String[] expected = { "48:55: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 55), "51:41: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 41), @@ -254,8 +238,6 @@ public void testNlWithAnnotations() throws Exception { @Test public void testNlowWithAnnotations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NLOW.toString()); final String[] expected = { "23:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "27:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -270,8 +252,6 @@ public void testNlowWithAnnotations() throws Exception { @Test public void testLineBreakAfter() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.EOL.toString()); final String[] expected = { "22:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "25:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -296,9 +276,6 @@ public void testLineBreakAfter() throws Exception { @Test public void testIgnoreEnumsOptionTrue() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.EOL.toString()); - checkConfig.addProperty("ignoreEnums", "true"); final String[] expectedWhileTrue = { "21:44: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 44), }; @@ -308,9 +285,6 @@ public void testIgnoreEnumsOptionTrue() throws Exception { @Test public void testIgnoreEnumsOptionFalse() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.EOL.toString()); - checkConfig.addProperty("ignoreEnums", "false"); final String[] expectedWhileFalse = { "17:17: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 17), "21:44: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 44), @@ -321,7 +295,6 @@ public void testIgnoreEnumsOptionFalse() throws Exception { @Test public void testDefaultLambda() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "24:32: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 32), @@ -334,8 +307,6 @@ public void testDefaultLambda() throws Exception { @Test public void testNewLineOptionWithLambda() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NL.toString()); final String[] expected = { "18:32: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 32), "24:32: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 32), @@ -347,8 +318,6 @@ public void testNewLineOptionWithLambda() throws Exception { @Test public void testEolSwitch() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.EOL.toString()); final String[] expected = { "22:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 13), "26:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 13), @@ -362,8 +331,6 @@ public void testEolSwitch() throws Exception { @Test public void testNlSwitch() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NL.toString()); final String[] expected = { "24:21: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 21), "56:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14), @@ -374,8 +341,6 @@ public void testNlSwitch() throws Exception { @Test public void testNlowSwitch() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NLOW.toString()); final String[] expected = { "22:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 13), }; @@ -385,7 +350,6 @@ public void testNlowSwitch() throws Exception { @Test public void testLeftCurlySwitchExpressions() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); final String[] expected = { "20:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 9), "22:17: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 17), @@ -404,8 +368,6 @@ public void testLeftCurlySwitchExpressions() throws Exception { @Test public void testLeftCurlySwitchExpressionsNewLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NL.toString()); final String[] expected = { "17:57: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 57), @@ -453,8 +415,6 @@ public void testGetAcceptableTokens() { @Test public void testFirstLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.EOL.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputLeftCurlyTestFirstLine.java"), expected); @@ -462,8 +422,6 @@ public void testFirstLine() throws Exception { @Test public void testCoverageIncrease() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NLOW.toString()); final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), "30:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -481,8 +439,6 @@ public void testCoverageIncrease() throws Exception { @Test public void testLeftCurlyRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", LeftCurlyOption.NLOW.toString()); final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), "24:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 9), @@ -497,8 +453,6 @@ public void testLeftCurlyRecordsAndCompactCtors() throws Exception { @Test public void testInvalidOption() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class); - checkConfig.addProperty("option", "invalid_option"); try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheckTest.java index 3469a2a03cc..e9154b0bc69 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheckTest.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class NeedBracesCheckTest extends AbstractModuleTestSupport { @@ -36,8 +35,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NeedBracesCheck.class); final String[] expected = { "30:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "do"), "42:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"), @@ -69,12 +66,6 @@ public void testIt() throws Exception { @Test public void testItWithAllowsOn() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("allowSingleLineStatement", "true"); - checkConfig.addProperty("allowEmptyLoopBody", "true"); - checkConfig.addProperty("tokens", "LITERAL_DO, LITERAL_ELSE, LITERAL_FOR, LITERAL_IF, " - + "LITERAL_WHILE, LITERAL_CASE, LITERAL_DEFAULT, LAMBDA"); final String[] expected = { "44:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"), "47:13: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"), @@ -101,9 +92,6 @@ public void testItWithAllowsOn() throws Exception { @Test public void testSingleLineStatements() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("allowSingleLineStatement", "true"); final String[] expected = { "32:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"), "38:43: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"), @@ -123,10 +111,6 @@ public void testSingleLineStatements() throws Exception { @Test public void testSingleLineLambda() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("tokens", "LAMBDA"); - checkConfig.addProperty("allowSingleLineStatement", "true"); final String[] expected = { "16:29: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), "19:22: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), @@ -139,9 +123,6 @@ public void testSingleLineLambda() throws Exception { @Test public void testDoNotAllowSingleLineLambda() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("tokens", "LAMBDA"); final String[] expected = { "14:28: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), "15:29: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), @@ -156,10 +137,6 @@ public void testDoNotAllowSingleLineLambda() throws Exception { @Test public void testSingleLineCaseDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("tokens", "LITERAL_CASE, LITERAL_DEFAULT"); - checkConfig.addProperty("allowSingleLineStatement", "true"); final String[] expected = { "81:13: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), "84:13: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), @@ -172,10 +149,6 @@ public void testSingleLineCaseDefault() throws Exception { @Test public void testSingleLineCaseDefault2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("tokens", "LITERAL_CASE, LITERAL_DEFAULT"); - checkConfig.addProperty("allowSingleLineStatement", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNeedBracesTestSingleLineCaseDefault2.java"), expected); @@ -183,9 +156,6 @@ public void testSingleLineCaseDefault2() throws Exception { @Test public void testSingleLineCaseDefaultNoSingleLine() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("tokens", "LITERAL_CASE, LITERAL_DEFAULT"); final String[] expected = { "18:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), "19:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), @@ -200,9 +170,6 @@ public void testSingleLineCaseDefaultNoSingleLine() throws Exception { @Test public void testCycles() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("tokens", "LITERAL_WHILE, LITERAL_DO, LITERAL_FOR"); - checkConfig.addProperty("allowSingleLineStatement", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNeedBracesTestCycles.java"), expected); @@ -210,9 +177,6 @@ public void testCycles() throws Exception { @Test public void testConditions() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("tokens", "LITERAL_ELSE, LITERAL_CASE, LITERAL_DEFAULT"); - checkConfig.addProperty("allowSingleLineStatement", "true"); final String[] expected = { "50:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), "53:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), @@ -224,9 +188,6 @@ public void testConditions() throws Exception { @Test public void testAllowEmptyLoopBodyTrue() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("allowEmptyLoopBody", "true"); final String[] expected = { "106:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"), }; @@ -236,8 +197,6 @@ public void testAllowEmptyLoopBodyTrue() throws Exception { @Test public void testAllowEmptyLoopBodyFalse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NeedBracesCheck.class); final String[] expected = { "19:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"), "23:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"), @@ -263,9 +222,6 @@ public void testAllowEmptyLoopBodyFalse() throws Exception { @Test public void testEmptySingleLineDefaultStmt() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("tokens", "LITERAL_DEFAULT"); - checkConfig.addProperty("allowSingleLineStatement", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNeedBracesEmptySingleLineDefaultStmt.java"), expected); @@ -273,11 +229,6 @@ public void testEmptySingleLineDefaultStmt() throws Exception { @Test public void testNeedBracesSwitchExpressionNoSingleLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("tokens", - "LITERAL_CASE, LITERAL_DEFAULT, LAMBDA"); - checkConfig.addProperty("allowSingleLineStatement", "false"); - final String[] expected = { "16:13: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), "18:47: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), @@ -303,11 +254,6 @@ public void testNeedBracesSwitchExpressionNoSingleLine() throws Exception { @Test public void testNeedBracesSwitchExpression() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NeedBracesCheck.class); - checkConfig.addProperty("tokens", - "LITERAL_CASE, LITERAL_DEFAULT, LAMBDA"); - checkConfig.addProperty("allowSingleLineStatement", "true"); - final String[] expected = { "16:13: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), "18:47: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckTest.java index dfa52ed6fd4..2d26098a3e9 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckTest.java @@ -28,7 +28,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.CheckstyleException; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -51,7 +50,6 @@ public void testRightCurlyOptionValueOf() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); final String[] expected = { "25:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17), "28:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17), @@ -65,11 +63,6 @@ public void testDefault() throws Exception { @Test public void testSame() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.SAME.toString()); - checkConfig.addProperty("tokens", "LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, " - + "LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, " - + "ANNOTATION_DEF, ENUM_DEF"); final String[] expected = { "26:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17), "29:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17), @@ -86,8 +79,6 @@ public void testSame() throws Exception { @Test public void testSameOmitOneLiners() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.SAME.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRightCurlyTestSameOmitOneLiners.java"), expected); @@ -95,11 +86,6 @@ public void testSameOmitOneLiners() throws Exception { @Test public void testSameDoesNotComplainForNonMultilineConstructs() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.SAME.toString()); - checkConfig.addProperty("tokens", "LITERAL_DO, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT," - + " INSTANCE_INIT, CLASS_DEF, METHOD_DEF, CTOR_DEF, ANNOTATION_DEF, ENUM_DEF," - + " INTERFACE_DEF"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRightCurlyTestSame.java"), expected); @@ -107,10 +93,6 @@ public void testSameDoesNotComplainForNonMultilineConstructs() throws Exception @Test public void testAlone() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); - checkConfig.addProperty("tokens", "LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, " - + "LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"); final String[] expected = { "57:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13), "94:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27), @@ -129,10 +111,6 @@ public void testAlone() throws Exception { @Test public void testNewLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF, CTOR_DEF, " - + "ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF"); final String[] expected = { "86:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), "111:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -157,10 +135,6 @@ public void testNewLine() throws Exception { @Test public void testShouldStartLine2() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE_OR_SINGLELINE.toString()); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF, " - + "ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF"); final String[] expected = { "86:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), "111:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -180,10 +154,6 @@ public void testShouldStartLine2() throws Exception { @Test public void testForceLineBreakBefore() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); - checkConfig.addProperty("tokens", "LITERAL_FOR," - + " LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"); final String[] expected = { "38:43: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 43), "41:17: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 17), @@ -197,7 +167,6 @@ public void testForceLineBreakBefore() throws Exception { @Test public void testForceLineBreakBefore2() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRightCurlyTestForceLineBreakBefore2.java"), expected); @@ -205,11 +174,6 @@ public void testForceLineBreakBefore2() throws Exception { @Test public void testNullPointerException() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, " - + "LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF, " - + "INTERFACE_DEF"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRightCurlyTestNullPointerException.java"), expected); @@ -217,11 +181,6 @@ public void testNullPointerException() throws Exception { @Test public void testWithAnnotations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); - checkConfig.addProperty("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"); final String[] expected = { "18:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77), "21:65: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 65), @@ -300,12 +259,6 @@ public void testWithAnnotations() throws Exception { @Test public void testAloneOrSingleLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE_OR_SINGLELINE.toString()); - checkConfig.addProperty("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, " - + "INTERFACE_DEF"); final String[] expected = { "70:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26), "84:42: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 42), @@ -352,7 +305,6 @@ public void testAloneOrSingleLine() throws Exception { @Test public void testCatchWithoutFinally() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); final String[] expected = { "19:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13), }; @@ -362,9 +314,6 @@ public void testCatchWithoutFinally() throws Exception { @Test public void testSingleLineClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); - checkConfig.addProperty("tokens", "CLASS_DEF"); final String[] expected = { "29:56: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 56), }; @@ -374,8 +323,6 @@ public void testSingleLineClass() throws Exception { @Test public void testInvalidOption() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", "invalid_option"); try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -395,9 +342,6 @@ public void testInvalidOption() throws Exception { @Test public void testRightCurlySameAndLiteralDo() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.SAME.toString()); - checkConfig.addProperty("tokens", "LITERAL_DO"); final String[] expected = { "70:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9), "75:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13), @@ -409,8 +353,6 @@ public void testRightCurlySameAndLiteralDo() throws Exception { @Test public void testTryWithResourceSame() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.SAME.toString()); final String[] expected = { "19:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9), "32:67: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 67), @@ -423,8 +365,6 @@ public void testTryWithResourceSame() throws Exception { @Test public void testTryWithResourceAlone() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); final String[] expected = { "27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9), "32:67: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 67), @@ -441,8 +381,6 @@ public void testTryWithResourceAlone() throws Exception { @Test public void testTryWithResourceAloneSingle() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE_OR_SINGLELINE.toString()); final String[] expected = { "27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9), "36:64: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 64), @@ -455,8 +393,6 @@ public void testTryWithResourceAloneSingle() throws Exception { @Test public void testBracePolicyAloneAndSinglelineIfBlocks() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); final String[] expected = { "13:32: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 32), "15:45: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 45), @@ -468,8 +404,6 @@ public void testBracePolicyAloneAndSinglelineIfBlocks() throws Exception { @Test public void testRightCurlyIsAloneLambda() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRightCurlyTestIsAloneLambda.java"), expected); @@ -477,9 +411,6 @@ public void testRightCurlyIsAloneLambda() throws Exception { @Test public void testRightCurlyIsAloneOrSinglelineLambda() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", - RightCurlyOption.ALONE_OR_SINGLELINE.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRightCurlyTestIsAloneOrSinglelineLambda.java"), expected); @@ -487,8 +418,6 @@ public void testRightCurlyIsAloneOrSinglelineLambda() throws Exception { @Test public void testRightCurlyIsSameLambda() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.SAME.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRightCurlyTestIsSameLambda.java"), expected); @@ -496,11 +425,6 @@ public void testRightCurlyIsSameLambda() throws Exception { @Test public void testOptionAlone() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF, LITERAL_IF, LITERAL_ELSE, " - + "LITERAL_DO, LITERAL_WHILE, LITERAL_FOR, STATIC_INIT, " - + "INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF"); final String[] expected = { "16:15: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 15), "17:21: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 21), @@ -531,11 +455,6 @@ public void testOptionAlone() throws Exception { @Test public void testOptionAloneOrSingleLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE_OR_SINGLELINE.toString()); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF, LITERAL_IF, LITERAL_ELSE, " - + "LITERAL_DO, LITERAL_WHILE, LITERAL_FOR, STATIC_INIT, " - + "INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF"); final String[] expected = { "21:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26), "30:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37), @@ -554,10 +473,6 @@ public void testOptionAloneOrSingleLine() throws Exception { @Test public void testBlocksEndingWithSemiOptionSame() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.SAME.toString()); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF, " - + "CTOR_DEF, ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF"); final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), "21:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -579,10 +494,6 @@ public void testBlocksEndingWithSemiOptionSame() throws Exception { @Test public void testBlocksEndingWithSemiOptionAlone() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF, " - + "CTOR_DEF, ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF"); final String[] expected = { "13:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31), "16:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -611,11 +522,6 @@ public void testBlocksEndingWithSemiOptionAlone() throws Exception { @Test public void testBlocksEndingWithSemiOptionAloneOrSingleLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", - RightCurlyOption.ALONE_OR_SINGLELINE.toString()); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF, " - + "CTOR_DEF, ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF"); final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), "21:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -637,9 +543,6 @@ public void testBlocksEndingWithSemiOptionAloneOrSingleLine() throws Exception { @Test public void testNewTokensAlone() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); - checkConfig.addProperty("tokens", "ENUM_DEF"); final String[] expected = { "13:19: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 19), "16:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20), @@ -651,10 +554,6 @@ public void testNewTokensAlone() throws Exception { @Test public void testNewTokensAloneOrSingleLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", - RightCurlyOption.ALONE_OR_SINGLELINE.toString()); - checkConfig.addProperty("tokens", "ENUM_DEF"); final String[] expected = { "16:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20), }; @@ -664,9 +563,6 @@ public void testNewTokensAloneOrSingleLine() throws Exception { @Test public void testNewTokensSame() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.SAME.toString()); - checkConfig.addProperty("tokens", "ENUM_DEF"); final String[] expected = { "16:20: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 20), }; @@ -676,12 +572,6 @@ public void testNewTokensSame() throws Exception { @Test public void testRightCurlyDoubleBrace() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.ALONE.toString()); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR," - + " LITERAL_WHILE, STATIC_INIT," - + " INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF, RECORD_DEF," - + " COMPACT_CTOR_DEF"); final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 1), "14:2: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 2), @@ -692,11 +582,6 @@ public void testRightCurlyDoubleBrace() throws Exception { @Test public void testRightCurlyEmptyOnSingleLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR," - + " LITERAL_WHILE, STATIC_INIT," - + " INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF, RECORD_DEF," - + " COMPACT_CTOR_DEF"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRightCurlyTestEmptyOnSingleLine.java"), expected); @@ -704,10 +589,6 @@ public void testRightCurlyEmptyOnSingleLine() throws Exception { @Test public void testRightCurlyEndOfFile() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.SAME.toString()); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF, CTOR_DEF," - + " LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"); final String[] expected = { "16:2: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 2), "16:3: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 3), @@ -718,11 +599,6 @@ public void testRightCurlyEndOfFile() throws Exception { @Test public void testRightCurlyRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class); - checkConfig.addProperty("option", RightCurlyOption.SAME.toString()); - checkConfig.addProperty("tokens", "RECORD_DEF, COMPACT_CTOR_DEF," - + " CTOR_DEF, METHOD_DEF"); - final String[] expected = { "23:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9), "23:11: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 11), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ArrayTrailingCommaCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ArrayTrailingCommaCheckTest.java index 79e9b63964a..d904b3dba09 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ArrayTrailingCommaCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ArrayTrailingCommaCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class ArrayTrailingCommaCheckTest extends AbstractModuleTestSupport { @@ -38,8 +37,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ArrayTrailingCommaCheck.class); final String[] expected = { "23:9: " + getCheckMessage(MSG_KEY), "43:9: " + getCheckMessage(MSG_KEY), @@ -60,9 +57,6 @@ public void testTokensNotNull() { @Test public void testAlwaysDemandTrailingComma() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ArrayTrailingCommaCheck.class); - checkConfig.addProperty("alwaysDemandTrailingComma", "true"); final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY), "22:29: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidDoubleBraceInitializationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidDoubleBraceInitializationCheckTest.java index 444dca45fd3..ea872c98f53 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidDoubleBraceInitializationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidDoubleBraceInitializationCheckTest.java @@ -25,7 +25,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 AvoidDoubleBraceInitializationCheckTest extends AbstractModuleTestSupport { @@ -37,8 +36,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidDoubleBraceInitializationCheck.class); final String[] expected = { "14:53: " + getCheckMessage(MSG_KEY), "19:40: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidInlineConditionalsCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidInlineConditionalsCheckTest.java index aedb69091de..c522f5d81c0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidInlineConditionalsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidInlineConditionalsCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class AvoidInlineConditionalsCheckTest extends AbstractModuleTestSupport { @@ -38,8 +37,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidInlineConditionalsCheck.class); final String[] expected = { "34:29: " + getCheckMessage(MSG_KEY), "35:20: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidNoArgumentSuperConstructorCallCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidNoArgumentSuperConstructorCallCheckTest.java index d29ec42b545..6713ff7b815 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidNoArgumentSuperConstructorCallCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidNoArgumentSuperConstructorCallCheckTest.java @@ -25,7 +25,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 AvoidNoArgumentSuperConstructorCallCheckTest @@ -38,8 +37,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidNoArgumentSuperConstructorCallCheck.class); final String[] expected = { "12:9: " + getCheckMessage(MSG_CTOR), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/CovariantEqualsCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/CovariantEqualsCheckTest.java index 152e12e5ea1..c25b8131af4 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/CovariantEqualsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/CovariantEqualsCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class CovariantEqualsCheckTest extends AbstractModuleTestSupport { @@ -38,8 +37,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CovariantEqualsCheck.class); final String[] expected = { "17:24: " + getCheckMessage(MSG_KEY), "36:20: " + getCheckMessage(MSG_KEY), @@ -55,8 +52,6 @@ public void testDefault() @Test public void testCovariantEqualsRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CovariantEqualsCheck.class); final String[] expected = { "13:24: " + getCheckMessage(MSG_KEY), "29:28: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckTest.java index 65006ab3ef5..2ec87810cdc 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckTest.java @@ -31,7 +31,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.api.Violation; @@ -46,8 +45,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DeclarationOrderCheck.class); final String[] expected = { "16:5: " + getCheckMessage(MSG_ACCESS), @@ -78,10 +75,6 @@ public void testDefault() throws Exception { @Test public void testOnlyConstructors() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DeclarationOrderCheck.class); - checkConfig.addProperty("ignoreConstructors", "false"); - checkConfig.addProperty("ignoreModifiers", "true"); final String[] expected = { "53:9: " + getCheckMessage(MSG_STATIC), @@ -98,10 +91,6 @@ public void testOnlyConstructors() throws Exception { @Test public void testOnlyModifiers() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DeclarationOrderCheck.class); - checkConfig.addProperty("ignoreConstructors", "true"); - checkConfig.addProperty("ignoreModifiers", "false"); final String[] expected = { "16:5: " + getCheckMessage(MSG_ACCESS), @@ -178,7 +167,6 @@ public void testImproperToken() { @Test public void testForwardReference() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DeclarationOrderCheck.class); final String[] expected = { "20:5: " + getCheckMessage(MSG_ACCESS), "21:5: " + getCheckMessage(MSG_ACCESS), @@ -196,7 +184,6 @@ public void testForwardReference() throws Exception { @Test public void testDeclarationOrderRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DeclarationOrderCheck.class); final String[] expected = { "21:9: " + getCheckMessage(MSG_CONSTRUCTOR), "24:9: " + getCheckMessage(MSG_STATIC), @@ -211,7 +198,6 @@ public void testDeclarationOrderRecordsAndCompactCtors() throws Exception { @Test public void testDeclarationOrderInterfaceMemberScopeIsPublic() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DeclarationOrderCheck.class); final String[] expected = { "21:5: " + getCheckMessage(MSG_STATIC), }; @@ -222,7 +208,6 @@ public void testDeclarationOrderInterfaceMemberScopeIsPublic() throws Exception @Test public void testVariableAccess() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DeclarationOrderCheck.class); final String[] expected = { "23:5: " + getCheckMessage(MSG_ACCESS), }; @@ -232,7 +217,6 @@ public void testVariableAccess() throws Exception { @Test public void testAvoidDuplicatesForStaticFinalFields() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DeclarationOrderCheck.class); final String[] expected = { "14:5: " + getCheckMessage(MSG_STATIC), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckTest.java index 3ef79a79ade..2ad3e9011dc 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckTest.java @@ -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.utils.CommonUtil; public class DefaultComesLastCheckTest extends AbstractModuleTestSupport { @@ -38,8 +37,6 @@ protected String getPackageLocation() { @Test public void testSkipIfLastAndSharedWithCase() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DefaultComesLastCheck.class); - checkConfig.addProperty("skipIfLastAndSharedWithCase", "true"); final String[] expected = { "23:13: " + getCheckMessage(MSG_KEY_SKIP_IF_LAST_AND_SHARED_WITH_CASE), "31:13: " + getCheckMessage(MSG_KEY_SKIP_IF_LAST_AND_SHARED_WITH_CASE), @@ -58,7 +55,6 @@ public void testSkipIfLastAndSharedWithCase() throws Exception { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DefaultComesLastCheck.class); final String[] expected = { "31:9: " + getCheckMessage(MSG_KEY), "38:24: " + getCheckMessage(MSG_KEY), @@ -83,7 +79,6 @@ public void testDefault() throws Exception { @Test public void testDefaultMethodsInJava8() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DefaultComesLastCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputDefaultComesLastDefaultMethodsInInterface.java"), @@ -92,7 +87,6 @@ public void testDefaultMethodsInJava8() @Test public void testDefaultComesLastSwitchExpressions() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DefaultComesLastCheck.class); final String[] expected = { "16:13: " + getCheckMessage(MSG_KEY), "32:13: " + getCheckMessage(MSG_KEY), @@ -105,8 +99,6 @@ public void testDefaultComesLastSwitchExpressions() throws Exception { @Test public void testDefaultComesLastSwitchExpressionsSkipIfLast() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DefaultComesLastCheck.class); - checkConfig.addProperty("skipIfLastAndSharedWithCase", "true"); final String[] expected = { "33:13: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckTest.java index 002eab94b2a..0b9fd117cff 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class EmptyStatementCheckTest extends AbstractModuleTestSupport { @@ -38,8 +37,6 @@ protected String getPackageLocation() { @Test public void testEmptyStatements() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EmptyStatementCheck.class); final String[] expected = { "18:7: " + getCheckMessage(MSG_KEY), "23:7: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheckTest.java index 995555af44c..3c5a64e4679 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheckTest.java @@ -26,7 +26,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { @@ -37,8 +36,6 @@ protected String getPackageLocation() { @Test public void testEqualsWithDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsAvoidNullCheck.class); final String[] expected = { "44:27: " + getCheckMessage(MSG_EQUALS_IGNORE_CASE_AVOID_NULL), @@ -103,9 +100,6 @@ public void testEqualsWithDefault() throws Exception { @Test public void testEqualsWithoutEqualsIgnoreCase() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsAvoidNullCheck.class); - checkConfig.addProperty("ignoreEqualsIgnoreCase", "true"); final String[] expected = { "245:21: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -158,8 +152,6 @@ public void testEqualsWithoutEqualsIgnoreCase() throws Exception { @Test public void testEqualsOnTheSameLine() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsAvoidNullCheck.class); final String[] expected = { "14:28: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -171,8 +163,6 @@ public void testEqualsOnTheSameLine() throws Exception { @Test public void testEqualsNested() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsAvoidNullCheck.class); final String[] expected = { "25:44: " + getCheckMessage(MSG_EQUALS_IGNORE_CASE_AVOID_NULL), @@ -190,8 +180,6 @@ public void testEqualsNested() throws Exception { @Test public void testInputEqualsAvoidNullEnhancedInstanceof() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsAvoidNullCheck.class); final String[] expected = { "15:45: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -208,8 +196,6 @@ public void testInputEqualsAvoidNullEnhancedInstanceof() throws Exception { @Test public void testMisc() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsAvoidNullCheck.class); final String[] expected = { "20:17: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -220,8 +206,6 @@ public void testMisc() throws Exception { @Test public void testRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsAvoidNullCheck.class); final String[] expected = { "15:23: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -236,8 +220,6 @@ public void testRecordsAndCompactCtors() throws Exception { @Test public void testEqualsAvoidNullTextBlocks() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsAvoidNullCheck.class); final String[] expected = { "13:28: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsHashCodeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsHashCodeCheckTest.java index 4042b5fe69e..e166717c4b3 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsHashCodeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsHashCodeCheckTest.java @@ -45,8 +45,6 @@ protected String getPackageLocation() { @Test public void testSemantic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsHashCodeCheck.class); final String[] expected = { "96:13: " + getCheckMessage(MSG_KEY_HASHCODE), }; @@ -56,8 +54,6 @@ public void testSemantic() throws Exception { @Test public void testNoEquals() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsHashCodeCheck.class); final String[] expected = { "10:5: " + getCheckMessage(MSG_KEY_EQUALS), }; @@ -67,8 +63,6 @@ public void testNoEquals() throws Exception { @Test public void testBooleanMethods() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsHashCodeCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEqualsHashCode.java"), expected); @@ -107,8 +101,6 @@ public void testMultipleInputs() throws Exception { @Test public void testEqualsParameter() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EqualsHashCodeCheck.class); final String[] expected = { "16:9: " + getCheckMessage(MSG_KEY_EQUALS), "24:9: " + getCheckMessage(MSG_KEY_HASHCODE), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java index 09f3ceb3d6c..257cf6af8d3 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class ExplicitInitializationCheckTest extends AbstractModuleTestSupport { @@ -36,8 +35,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ExplicitInitializationCheck.class); final String[] expected = { "11:17: " + getCheckMessage(MSG_KEY, "x", 0), "12:20: " + getCheckMessage(MSG_KEY, "bar", "null"), @@ -76,9 +73,6 @@ public void testTokensNotNull() { @Test public void testOnlyObjectReferences() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ExplicitInitializationCheck.class); - checkConfig.addProperty("onlyObjectReferences", "true"); final String[] expected = { "12:20: " + getCheckMessage(MSG_KEY, "bar", "null"), "21:22: " + getCheckMessage(MSG_KEY, "str1", "null"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckTest.java index f3cf9ffaf34..ea2d293ba73 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckTest.java @@ -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.utils.CommonUtil; public class FallThroughCheckTest extends AbstractModuleTestSupport { @@ -38,7 +37,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FallThroughCheck.class); final String[] expected = { "22:13: " + getCheckMessage(MSG_FALL_THROUGH), "46:13: " + getCheckMessage(MSG_FALL_THROUGH), @@ -71,7 +69,6 @@ public void testDefault() throws Exception { @Test public void testTryWithResources() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FallThroughCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputFallThrough.java"), @@ -80,8 +77,6 @@ public void testTryWithResources() throws Exception { @Test public void testLastCaseGroup() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FallThroughCheck.class); - checkConfig.addProperty("checkLastCaseGroup", "true"); final String[] expected = { "22:13: " + getCheckMessage(MSG_FALL_THROUGH), "46:13: " + getCheckMessage(MSG_FALL_THROUGH), @@ -111,9 +106,6 @@ public void testLastCaseGroup() throws Exception { @Test public void testOwnPattern() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FallThroughCheck.class); - checkConfig.addProperty("reliefPattern", "Continue with next case"); final String[] expected = { "22:13: " + getCheckMessage(MSG_FALL_THROUGH), @@ -160,9 +152,6 @@ public void testOwnPattern() throws Exception { @Test public void testOwnPatternTryWithResources() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FallThroughCheck.class); - checkConfig.addProperty("reliefPattern", "Continue with next case"); final String[] expected = { "54:9: " + getCheckMessage(MSG_FALL_THROUGH), @@ -186,7 +175,6 @@ public void testTokensNotNull() { @Test public void testFallThroughNoElse() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FallThroughCheck.class); final String[] expected = { "28:13: " + getCheckMessage(MSG_FALL_THROUGH), "43:13: " + getCheckMessage(MSG_FALL_THROUGH), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java index b9f19b43709..58c1e4b3ecd 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -40,8 +39,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalLocalVariableCheck.class); final String[] expected = { "17:13: " + getCheckMessage(MSG_KEY, "i"), @@ -89,8 +86,6 @@ public void testDefault() throws Exception { @Test public void testRecordsInput() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalLocalVariableCheck.class); final String[] expected = { "20:17: " + getCheckMessage(MSG_KEY, "b"), }; @@ -100,9 +95,6 @@ public void testRecordsInput() throws Exception { @Test public void testParameter() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalLocalVariableCheck.class); - checkConfig.addProperty("tokens", "PARAMETER_DEF"); final String[] expected = { "53:28: " + getCheckMessage(MSG_KEY, "aArg"), @@ -115,9 +107,6 @@ public void testParameter() throws Exception { @Test public void testNativeMethods() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalLocalVariableCheck.class); - checkConfig.addProperty("tokens", "PARAMETER_DEF"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -126,9 +115,6 @@ public void testNativeMethods() throws Exception { @Test public void testFalsePositive() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalLocalVariableCheck.class); - checkConfig.addProperty("tokens", "VARIABLE_DEF, PARAMETER_DEF"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -137,10 +123,6 @@ public void testFalsePositive() throws Exception { @Test public void testEnhancedForLoopVariableTrue() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalLocalVariableCheck.class); - checkConfig.addProperty("tokens", "VARIABLE_DEF, PARAMETER_DEF"); - checkConfig.addProperty("validateEnhancedForLoopVariable", "true"); final String[] expected = { "16:20: " + getCheckMessage(MSG_KEY, "a"), "23:13: " + getCheckMessage(MSG_KEY, "x"), @@ -157,9 +139,6 @@ public void testEnhancedForLoopVariableTrue() throws Exception { @Test public void testEnhancedForLoopVariableFalse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalLocalVariableCheck.class); - checkConfig.addProperty("tokens", "VARIABLE_DEF, PARAMETER_DEF"); final String[] expected = { "23:13: " + getCheckMessage(MSG_KEY, "x"), "29:66: " + getCheckMessage(MSG_KEY, "snippets"), @@ -174,9 +153,6 @@ public void testEnhancedForLoopVariableFalse() throws Exception { @Test public void testLambda() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalLocalVariableCheck.class); - checkConfig.addProperty("tokens", "PARAMETER_DEF,VARIABLE_DEF"); final String[] expected = { "40:16: " + getCheckMessage(MSG_KEY, "result"), }; @@ -188,9 +164,6 @@ public void testLambda() @Test public void testVariableNameShadowing() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalLocalVariableCheck.class); - checkConfig.addProperty("tokens", "PARAMETER_DEF,VARIABLE_DEF"); final String[] expected = { "12:28: " + getCheckMessage(MSG_KEY, "text"), @@ -218,7 +191,6 @@ public void testImproperToken() { @Test public void testVariableWhichIsAssignedMultipleTimes() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FinalLocalVariableCheck.class); final String[] expected = { "57:13: " + getCheckMessage(MSG_KEY, "i"), @@ -234,7 +206,6 @@ public void testVariableWhichIsAssignedMultipleTimes() throws Exception { @Test public void testVariableIsAssignedInsideAndOutsideSwitchBlock() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FinalLocalVariableCheck.class); final String[] expected = { "39:13: " + getCheckMessage(MSG_KEY, "b"), }; @@ -245,7 +216,6 @@ public void testVariableIsAssignedInsideAndOutsideSwitchBlock() throws Exception @Test public void testFinalLocalVariableFalsePositives() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FinalLocalVariableCheck.class); final String[] expected = { "352:16: " + getCheckMessage(MSG_KEY, "c2"), "2195:16: " + getCheckMessage(MSG_KEY, "b"), @@ -256,7 +226,6 @@ public void testFinalLocalVariableFalsePositives() throws Exception { @Test public void testMultipleAndNestedConditions() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FinalLocalVariableCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputFinalLocalVariableMultipleAndNestedConditions.java"), @@ -265,8 +234,6 @@ public void testMultipleAndNestedConditions() throws Exception { @Test public void testMultiTypeCatch() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FinalLocalVariableCheck.class); - checkConfig.addProperty("tokens", "PARAMETER_DEF,VARIABLE_DEF"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputFinalLocalVariableMultiCatch.java"), @@ -275,7 +242,6 @@ public void testMultiTypeCatch() throws Exception { @Test public void testLeavingSlistToken() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FinalLocalVariableCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputFinalLocalVariableLeavingSlistToken.java"), expected); @@ -283,7 +249,6 @@ public void testLeavingSlistToken() throws Exception { @Test public void testBreakOrReturn() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FinalLocalVariableCheck.class); final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY, "e"), }; @@ -293,7 +258,6 @@ public void testBreakOrReturn() throws Exception { @Test public void testAnonymousClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FinalLocalVariableCheck.class); final String[] expected = { "13:16: " + getCheckMessage(MSG_KEY, "testSupport"), }; @@ -303,8 +267,6 @@ public void testAnonymousClass() throws Exception { @Test public void testReceiverParameter() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FinalLocalVariableCheck.class); - checkConfig.addProperty("tokens", "PARAMETER_DEF,VARIABLE_DEF"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputFinalLocalVariableReceiverParameter.java"), expected); @@ -312,7 +274,6 @@ public void testReceiverParameter() throws Exception { @Test public void testFinalLocalVariableSwitchExpressions() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FinalLocalVariableCheck.class); final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY, "e"), "53:19: " + getCheckMessage(MSG_KEY, "e"), @@ -326,7 +287,6 @@ public void testFinalLocalVariableSwitchExpressions() throws Exception { @Test public void testFinalLocalVariableSwitchAssignment() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(FinalLocalVariableCheck.class); final String[] expected = { "21:13: " + getCheckMessage(MSG_KEY, "a"), "44:13: " + getCheckMessage(MSG_KEY, "b"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckTest.java index 5cd2c844a3e..1ff369e6683 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckTest.java @@ -47,8 +47,6 @@ protected String getPackageLocation() { @Test public void testStaticVisibilityFromLambdas() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); final String[] expected = { "31:34: " + getCheckMessage(MSG_KEY, "value"), "63:31: " + getCheckMessage(MSG_KEY, "languageCode"), @@ -73,8 +71,6 @@ public void testStaticVisibilityFromLambdas() throws Exception { @Test public void testStaticVisibilityFromAnonymousClasses() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); final String[] expected = { "22:45: " + getCheckMessage(MSG_KEY, "other"), "28:42: " + getCheckMessage(MSG_KEY, "other"), @@ -89,9 +85,6 @@ public void testStaticVisibilityFromAnonymousClasses() throws Exception { @Test public void testNoParameters() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); - checkConfig.addProperty("tokens", "VARIABLE_DEF"); final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), "39:13: " + getCheckMessage(MSG_KEY, "hidden"), @@ -119,8 +112,6 @@ public void testNoParameters() @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), "33:34: " + getCheckMessage(MSG_KEY, "hidden"), @@ -209,9 +200,6 @@ public void testIgnoreFormat() @Test public void testIgnoreSetter() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); - checkConfig.addProperty("ignoreSetter", "true"); final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), "33:34: " + getCheckMessage(MSG_KEY, "hidden"), @@ -253,10 +241,6 @@ public void testIgnoreSetter() @Test public void testIgnoreChainSetter() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); - checkConfig.addProperty("ignoreSetter", "true"); - checkConfig.addProperty("setterCanReturnItsClass", "true"); final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), "33:34: " + getCheckMessage(MSG_KEY, "hidden"), @@ -296,9 +280,6 @@ public void testIgnoreChainSetter() @Test public void testIgnoreConstructorParameter() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); - checkConfig.addProperty("ignoreConstructorParameter", "true"); final String[] expected = { "29:13: " + getCheckMessage(MSG_KEY, "hidden"), "38:13: " + getCheckMessage(MSG_KEY, "hidden"), @@ -341,8 +322,6 @@ public void testIgnoreConstructorParameter() @Test public void testReordered() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), "33:40: " + getCheckMessage(MSG_KEY, "hidden"), @@ -371,9 +350,6 @@ public void testReordered() @Test public void testIgnoreAbstractMethods() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); - checkConfig.addProperty("ignoreAbstractMethods", "true"); final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), @@ -417,7 +393,6 @@ public void testIgnoreAbstractMethods() throws Exception { @Test public void testReceiverParameter() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(HiddenFieldCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHiddenFieldReceiver.java"), expected); @@ -425,9 +400,6 @@ public void testReceiverParameter() throws Exception { @Test public void testHiddenFieldEnhancedInstanceof() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); - checkConfig.addProperty("tokens", "PATTERN_VARIABLE_DEF"); final String[] expected = { "26:39: " + getCheckMessage(MSG_KEY, "price"), @@ -439,8 +411,6 @@ public void testHiddenFieldEnhancedInstanceof() throws Exception { @Test public void testHiddenFieldSwitchExpression() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); final String[] expected = { "28:13: " + getCheckMessage(MSG_KEY, "x"), @@ -464,8 +434,6 @@ public void testHiddenFieldSwitchExpression() throws Exception { @Test public void testHiddenFieldRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HiddenFieldCheck.class); final String[] expected = { "23:17: " + getCheckMessage(MSG_KEY, "myHiddenInt"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalCatchCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalCatchCheckTest.java index 529cde4095a..6e9c6182450 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalCatchCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalCatchCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class IllegalCatchCheckTest extends AbstractModuleTestSupport { @@ -36,7 +35,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalCatchCheck.class); final String[] expected = { "14:11: " + getCheckMessage(MSG_KEY, "RuntimeException"), @@ -53,10 +51,6 @@ public void testDefault() throws Exception { @Test public void testIllegalClassNames() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalCatchCheck.class); - checkConfig.addProperty("illegalClassNames", - "java.lang.Error, java.lang.Exception, java.lang.Throwable"); - final String[] expected = { "14:11: " + getCheckMessage(MSG_KEY, "Exception"), "15:11: " + getCheckMessage(MSG_KEY, "Throwable"), @@ -70,14 +64,7 @@ public void testIllegalClassNames() throws Exception { @Test public void testIllegalClassNamesBad() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalCatchCheck.class); - checkConfig.addProperty("illegalClassNames", - "java.lang.Error, java.lang.Exception, NullPointerException"); - // check that incorrect names don't break the Check - checkConfig.addProperty("illegalClassNames", - "java.lang.IOException."); - final String[] expected = { "15:11: " + getCheckMessage(MSG_KEY, "Exception"), "23:11: " + getCheckMessage(MSG_KEY, "java.lang.Exception"), @@ -89,11 +76,6 @@ public void testIllegalClassNamesBad() throws Exception { @Test public void testMultipleTypes() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalCatchCheck.class); - checkConfig.addProperty("illegalClassNames", - "java.lang.Error, java.lang.Exception, NullPointerException," - + " OneMoreException, RuntimeException, SQLException"); - final String[] expected = { "15:11: " + getCheckMessage(MSG_KEY, "RuntimeException"), "15:11: " + getCheckMessage(MSG_KEY, "SQLException"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java index ca38df5efff..a3be6057a84 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java @@ -31,7 +31,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.JavaParser; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -49,8 +48,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalInstantiationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputIllegalInstantiationSemantic.java"), expected); @@ -58,15 +55,6 @@ public void testDefault() throws Exception { @Test public void testClasses() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalInstantiationCheck.class); - checkConfig.addProperty( - "classes", - "java.lang.Boolean," - + "com.puppycrawl.tools.checkstyle.checks.coding." - + "illegalinstantiation.InputModifier," - + "java.io.File," - + "java.awt.Color"); final String[] expected = { "24:21: " + getCheckMessage(MSG_KEY, "java.lang.Boolean"), "29:21: " + getCheckMessage(MSG_KEY, "java.lang.Boolean"), @@ -83,11 +71,6 @@ public void testClasses() throws Exception { @Test public void testSameClassNameAsJavaLang() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalInstantiationCheck.class); - checkConfig.addProperty( - "classes", - "java.lang.InputTest"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputIllegalInstantiationSameClassNameJavaLang.java"), @@ -96,8 +79,6 @@ public void testSameClassNameAsJavaLang() throws Exception { @Test public void testJava8() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalInstantiationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputIllegalInstantiation.java"), @@ -106,11 +87,6 @@ public void testJava8() throws Exception { @Test public void testNoPackage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalInstantiationCheck.class); - checkConfig.addProperty( - "classes", - "java.lang.Boolean"); final String[] expected = { "10:20: " + getCheckMessage(MSG_KEY, "java.lang.Boolean"), }; @@ -120,11 +96,6 @@ public void testNoPackage() throws Exception { @Test public void testJavaLangPackage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalInstantiationCheck.class); - checkConfig.addProperty( - "classes", - "java.lang.Boolean,java.lang.String"); final String[] expected = { "13:19: " + getCheckMessage(MSG_KEY, "java.lang.Boolean"), "21:20: " + getCheckMessage(MSG_KEY, "java.lang.String"), @@ -136,11 +107,6 @@ public void testJavaLangPackage() throws Exception { @Test public void testWrongPackage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalInstantiationCheck.class); - checkConfig.addProperty( - "classes", - "jjva.lang.Boolean,java.lang*Boolean"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputIllegalInstantiationLang2.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckTest.java index 02cd120840f..de508da5c19 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class IllegalThrowsCheckTest extends AbstractModuleTestSupport { @@ -37,7 +36,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalThrowsCheck.class); final String[] expected = { "19:51: " + getCheckMessage(MSG_KEY, "RuntimeException"), @@ -51,14 +49,7 @@ public void testDefault() throws Exception { @Test public void testIllegalClassNames() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalThrowsCheck.class); - checkConfig.addProperty("illegalClassNames", - "java.lang.Error, java.lang.Exception, NullPointerException"); - // check that incorrect names don't break the Check - checkConfig.addProperty("illegalClassNames", - "java.lang.IOException."); - final String[] expected = { "15:33: " + getCheckMessage(MSG_KEY, "NullPointerException"), "24:73: " + getCheckMessage(MSG_KEY, "java.lang.Error"), @@ -73,8 +64,6 @@ public void testIllegalClassNames() throws Exception { */ @Test public void testIgnoreMethodNames() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalThrowsCheck.class); - checkConfig.addProperty("ignoredMethodNames", "methodTwo"); final String[] expected = { "19:51: " + getCheckMessage(MSG_KEY, "RuntimeException"), @@ -90,11 +79,6 @@ public void testIgnoreMethodNames() throws Exception { */ @Test public void testIllegalClassNamesWithIgnoreMethodNames() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalThrowsCheck.class); - checkConfig.addProperty("illegalClassNames", - "java.lang.Error, java.lang.Exception, NullPointerException, Throwable"); - checkConfig.addProperty("ignoredMethodNames", "methodTwo"); - final String[] expected = { "14:33: " + getCheckMessage(MSG_KEY, "NullPointerException"), "27:35: " + getCheckMessage(MSG_KEY, "Throwable"), @@ -110,8 +94,6 @@ public void testIllegalClassNamesWithIgnoreMethodNames() throws Exception { */ @Test public void testIgnoreOverriddenMethods() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalThrowsCheck.class); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -125,8 +107,6 @@ public void testIgnoreOverriddenMethods() throws Exception { */ @Test public void testNotIgnoreOverriddenMethods() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalThrowsCheck.class); - checkConfig.addProperty("ignoreOverriddenMethods", "false"); final String[] expected = { "17:36: " + getCheckMessage(MSG_KEY, "RuntimeException"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenCheckTest.java index e2ad74f36f3..f558afba326 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenCheckTest.java @@ -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.internal.utils.CheckUtil; import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; @@ -41,8 +40,6 @@ protected String getPackageLocation() { @Test public void testCheckWithDefaultSettings() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenCheck.class); final String[] expected = { "36:14: " + getCheckMessage(MSG_KEY, "label:"), "38:25: " + getCheckMessage(MSG_KEY, "anotherLabel:"), @@ -54,9 +51,6 @@ public void testCheckWithDefaultSettings() @Test public void testPreviouslyIllegalTokens() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenCheck.class); - checkConfig.addProperty("tokens", "LITERAL_SWITCH,POST_INC,POST_DEC"); final String[] expected = { "18:9: " + getCheckMessage(MSG_KEY, "switch"), "21:18: " + getCheckMessage(MSG_KEY, "--"), @@ -68,9 +62,6 @@ public void testPreviouslyIllegalTokens() @Test public void testNative() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenCheck.class); - checkConfig.addProperty("tokens", "LITERAL_NATIVE"); final String[] expected = { "27:12: " + getCheckMessage(MSG_KEY, "native"), }; @@ -81,9 +72,6 @@ public void testNative() throws Exception { @Test public void testCommentContentToken() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenCheck.class); - checkConfig.addProperty("tokens", "COMMENT_CONTENT"); final String path = getPath("InputIllegalTokens4.java"); final String lineSeparator = @@ -114,9 +102,6 @@ public void testCommentContentToken() @Test public void testBlockCommentBeginToken() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenCheck.class); - checkConfig.addProperty("tokens", "BLOCK_COMMENT_BEGIN"); final String[] expected = { "1:1: " + getCheckMessage(MSG_KEY, "/*"), @@ -129,9 +114,6 @@ public void testBlockCommentBeginToken() @Test public void testBlockCommentEndToken() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenCheck.class); - checkConfig.addProperty("tokens", "BLOCK_COMMENT_END"); final String[] expected = { "6:1: " + getCheckMessage(MSG_KEY, "*/"), @@ -144,9 +126,6 @@ public void testBlockCommentEndToken() @Test public void testSingleLineCommentToken() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenCheck.class); - checkConfig.addProperty("tokens", "SINGLE_LINE_COMMENT"); final String[] expected = { "38:27: " + getCheckMessage(MSG_KEY, "//"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheckTest.java index 71f94c1984a..6d60928c957 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheckTest.java @@ -31,7 +31,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; import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; import com.puppycrawl.tools.checkstyle.utils.TokenUtil; @@ -47,11 +46,6 @@ protected String getPackageLocation() { @Test public void testCaseSensitive() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenTextCheck.class); - checkConfig.addProperty("tokens", "STRING_LITERAL"); - checkConfig.addProperty("format", "a href"); - checkConfig.addProperty("ignoreCase", "false"); final String[] expected = { "34:28: " + getCheckMessage(MSG_KEY, "a href"), }; @@ -62,11 +56,6 @@ public void testCaseSensitive() @Test public void testCaseInSensitive() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenTextCheck.class); - checkConfig.addProperty("tokens", "STRING_LITERAL"); - checkConfig.addProperty("format", "a href"); - checkConfig.addProperty("ignoreCase", "true"); final String[] expected = { "34:28: " + getCheckMessage(MSG_KEY, "a href"), "35:32: " + getCheckMessage(MSG_KEY, "a href"), @@ -78,12 +67,7 @@ public void testCaseInSensitive() @Test public void testCustomMessage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenTextCheck.class); - checkConfig.addProperty("tokens", "STRING_LITERAL"); - checkConfig.addProperty("format", "a href"); - checkConfig.addProperty("message", "My custom message"); final String[] expected = { "34:28: " + "My custom message", }; @@ -94,12 +78,7 @@ public void testCustomMessage() @Test public void testNullCustomMessage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenTextCheck.class); - checkConfig.addProperty("tokens", "STRING_LITERAL"); - checkConfig.addProperty("format", "a href"); - checkConfig.addProperty("message", null); final String[] expected = { "34:28: " + getCheckMessage(MSG_KEY, "a href"), }; @@ -109,10 +88,6 @@ public void testNullCustomMessage() @Test public void testIllegalTokenTextTextBlocks() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenTextCheck.class); - checkConfig.addProperty("tokens", "STRING_LITERAL, TEXT_BLOCK_CONTENT"); - checkConfig.addProperty("format", "a href"); final String[] expected = { "16:28: " + getCheckMessage(MSG_KEY, "a href"), @@ -127,10 +102,6 @@ public void testIllegalTokenTextTextBlocks() throws Exception { @Test public void testIllegalTokenTextTextBlocksQuotes() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenTextCheck.class); - checkConfig.addProperty("tokens", "STRING_LITERAL, TEXT_BLOCK_CONTENT"); - checkConfig.addProperty("format", "\""); final String[] expected = { "16:28: " + getCheckMessage(MSG_KEY, "\""), @@ -157,12 +128,7 @@ public void testTokensNotNull() { @Test public void testCommentToken() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalTokenTextCheck.class); - checkConfig.addProperty("tokens", "COMMENT_CONTENT"); - checkConfig.addProperty("format", "a href"); - checkConfig.addProperty("message", null); final String[] expected = { "1:3: " + getCheckMessage(MSG_KEY, "a href"), "45:28: " + getCheckMessage(MSG_KEY, "a href"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java index 8a63ee87bca..7e16b316478 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java @@ -42,8 +42,6 @@ protected String getPackageLocation() { @Test public void testValidateAbstractClassNamesSetToTrue() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("validateAbstractClassNames", "true"); final String[] expected = { "27:38: " + getCheckMessage(MSG_KEY, "AbstractClass"), "44:5: " + getCheckMessage(MSG_KEY, "AbstractClass"), @@ -57,8 +55,6 @@ public void testValidateAbstractClassNamesSetToTrue() throws Exception { @Test public void testValidateAbstractClassNamesSetToFalse() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("validateAbstractClassNames", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -67,7 +63,6 @@ public void testValidateAbstractClassNamesSetToFalse() throws Exception { @Test public void testDefaults() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); final String[] expected = { "34:13: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"), "35:13: " + getCheckMessage(MSG_KEY, "TreeSet"), @@ -81,8 +76,6 @@ public void testDefaults() throws Exception { @Test public void testDefaultsEmptyStringMemberModifiers() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("memberModifiers", ""); final String[] expected = { "34:13: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"), @@ -97,9 +90,6 @@ public void testDefaultsEmptyStringMemberModifiers() throws Exception { @Test public void testIgnoreMethodNames() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("ignoredMethodNames", "table2"); - checkConfig.addProperty("validateAbstractClassNames", "true"); final String[] expected = { "23:13: " + getCheckMessage(MSG_KEY, "AbstractClass"), "26:13: " + getCheckMessage(MSG_KEY, @@ -117,8 +107,6 @@ public void testIgnoreMethodNames() throws Exception { @Test public void testFormat() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalAbstractClassNameFormat", "^$"); final String[] expected = { "34:13: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"), @@ -133,9 +121,6 @@ public void testFormat() throws Exception { @Test public void testLegalAbstractClassNames() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("validateAbstractClassNames", "true"); - checkConfig.addProperty("legalAbstractClassNames", "AbstractClass"); final String[] expected = { "26:13: " + getCheckMessage(MSG_KEY, @@ -153,10 +138,6 @@ public void testLegalAbstractClassNames() throws Exception { @Test public void testSameFileNameFalsePositive() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalClassNames", - "java.util.GregorianCalendar, SubCal, java.util.List"); - final String[] expected = { "28:5: " + getCheckMessage(MSG_KEY, "SubCal"), "43:5: " + getCheckMessage(MSG_KEY, "java.util.List"), @@ -168,9 +149,6 @@ public void testSameFileNameFalsePositive() throws Exception { @Test public void testSameFileNameGeneral() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalClassNames", - "List, InputIllegalTypeGregCal, java.io.File, ArrayList, Boolean"); final String[] expected = { "25:5: " + getCheckMessage(MSG_KEY, "InputIllegalTypeGregCal"), "29:43: " + getCheckMessage(MSG_KEY, "InputIllegalTypeGregCal"), @@ -187,8 +165,6 @@ public void testSameFileNameGeneral() throws Exception { @Test public void testArrayTypes() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalClassNames", "Boolean[], Boolean[][]"); final String[] expected = { "20:12: " + getCheckMessage(MSG_KEY, "Boolean[]"), "22:12: " + getCheckMessage(MSG_KEY, "Boolean[][]"), @@ -203,8 +179,6 @@ public void testArrayTypes() throws Exception { @Test public void testPlainAndArrayTypes() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalClassNames", "Boolean, Boolean[][]"); final String[] expected = { "20:12: " + getCheckMessage(MSG_KEY, "Boolean"), "24:12: " + getCheckMessage(MSG_KEY, "Boolean[][]"), @@ -218,10 +192,6 @@ public void testPlainAndArrayTypes() throws Exception { @Test public void testGenerics() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalClassNames", - "Boolean, Foo, Serializable"); - checkConfig.addProperty("memberModifiers", "LITERAL_PUBLIC, FINAL"); final String[] expected = { "28:16: " + getCheckMessage(MSG_KEY, "Boolean"), "29:31: " + getCheckMessage(MSG_KEY, "Boolean"), @@ -247,10 +217,6 @@ public void testGenerics() throws Exception { @Test public void testExtendsImplements() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalClassNames", - "Boolean, Foo, Hashtable, Serializable"); - checkConfig.addProperty("memberModifiers", "LITERAL_PUBLIC"); final String[] expected = { "24:17: " + getCheckMessage(MSG_KEY, "Hashtable"), "25:14: " + getCheckMessage(MSG_KEY, "Boolean"), @@ -268,8 +234,6 @@ public void testExtendsImplements() throws Exception { @Test public void testStarImports() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalClassNames", "List"); final String[] expected = { "25:5: " + getCheckMessage(MSG_KEY, "List"), @@ -281,9 +245,6 @@ public void testStarImports() throws Exception { @Test public void testStaticImports() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalClassNames", "SomeStaticClass"); - checkConfig.addProperty("ignoredMethodNames", "foo1"); final String[] expected = { "28:6: " + getCheckMessage(MSG_KEY, "SomeStaticClass"), @@ -296,10 +257,6 @@ public void testStaticImports() throws Exception { @Test public void testMemberModifiers() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("validateAbstractClassNames", "true"); - checkConfig.addProperty("memberModifiers", "LITERAL_PRIVATE, LITERAL_PROTECTED," - + " LITERAL_STATIC"); final String[] expected = { "22:13: " + getCheckMessage(MSG_KEY, "AbstractClass"), "25:13: " + getCheckMessage(MSG_KEY, "java.util.AbstractList"), @@ -316,8 +273,6 @@ public void testMemberModifiers() throws Exception { @Test public void testPackageClassName() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalClassNames", "com.PackageClass"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -343,7 +298,6 @@ public void testClearDataBetweenFiles() throws Exception { @Test public void testIllegalTypeEnhancedInstanceof() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); final String[] expected = { "28:9: " + getCheckMessage(MSG_KEY, "LinkedHashMap"), "31:28: " + getCheckMessage(MSG_KEY, "LinkedHashMap"), @@ -359,12 +313,6 @@ public void testIllegalTypeEnhancedInstanceof() throws Exception { @Test public void testIllegalTypeRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalClassNames", "HashMap, HashSet, LinkedHashMap," - + " LinkedHashSet, TreeMap, TreeSet, java.util.HashMap, java.util.HashSet," - + " java.util.LinkedHashMap, java.util.LinkedHashSet, java.util.TreeMap," - + " java.util.TreeSet, Cloneable"); - final String[] expected = { "27:14: " + getCheckMessage(MSG_KEY, "LinkedHashMap"), "31:52: " + getCheckMessage(MSG_KEY, "Cloneable"), @@ -382,8 +330,6 @@ public void testIllegalTypeRecordsAndCompactCtors() throws Exception { @Test public void testIllegalTypeNewArrayStructure() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); - checkConfig.addProperty("illegalClassNames", "HashMap"); final String[] expected = { "26:13: " + getCheckMessage(MSG_KEY, "HashMap"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckTest.java index 83d7b9c00df..b6acc5b1d69 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class InnerAssignmentCheckTest @@ -38,8 +37,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InnerAssignmentCheck.class); final String[] expected = { "22:15: " + getCheckMessage(MSG_KEY), "22:19: " + getCheckMessage(MSG_KEY), @@ -67,8 +64,6 @@ public void testIt() throws Exception { @Test public void testLambdaExpression() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InnerAssignmentCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInnerAssignmentLambdaExpressions.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MagicNumberCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MagicNumberCheckTest.java index 1bc49dd925c..4c69c2a98ca 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MagicNumberCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MagicNumberCheckTest.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class MagicNumberCheckTest extends AbstractModuleTestSupport { @@ -37,8 +36,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MagicNumberCheck.class); final String[] expected = { "54:26: " + getCheckMessage(MSG_KEY, "3_000"), "55:32: " + getCheckMessage(MSG_KEY, "1.5_0"), @@ -93,10 +90,6 @@ public void testDefault() @Test public void testIgnoreSome() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MagicNumberCheck.class); - checkConfig.addProperty("ignoreNumbers", "0, 1, 3.0, 8, 16, 3000"); - checkConfig.addProperty("ignoreAnnotation", "true"); final String[] expected = { "36:25: " + getCheckMessage(MSG_KEY, "2"), "42:35: " + getCheckMessage(MSG_KEY, "2"), @@ -144,10 +137,6 @@ public void testIgnoreSome() @Test public void testIgnoreNone() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MagicNumberCheck.class); - checkConfig.addProperty("ignoreNumbers", ""); - checkConfig.addProperty("ignoreAnnotation", "true"); final String[] expected = { "41:24: " + getCheckMessage(MSG_KEY, "1"), "42:25: " + getCheckMessage(MSG_KEY, "2"), @@ -223,10 +212,6 @@ public void testIgnoreNone() @Test public void testIntegersOnly() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MagicNumberCheck.class); - checkConfig.addProperty("tokens", "NUM_INT, NUM_LONG"); - checkConfig.addProperty("ignoreAnnotation", "true"); final String[] expected = { "55:26: " + getCheckMessage(MSG_KEY, "3_000"), "57:27: " + getCheckMessage(MSG_KEY, "3"), @@ -272,12 +257,6 @@ public void testIntegersOnly() @Test public void testIgnoreNegativeOctalHex() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MagicNumberCheck.class); - checkConfig.addProperty("ignoreNumbers", - "-9223372036854775808, -2147483648, -1, 0, 1, 2, -2"); - checkConfig.addProperty("tokens", "NUM_INT, NUM_LONG"); - checkConfig.addProperty("ignoreAnnotation", "true"); final String[] expected = { "55:26: " + getCheckMessage(MSG_KEY, "3_000"), "57:27: " + getCheckMessage(MSG_KEY, "3"), @@ -318,10 +297,6 @@ public void testIgnoreNegativeOctalHex() throws Exception { @Test public void testIgnoreHashCodeMethod() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MagicNumberCheck.class); - checkConfig.addProperty("ignoreHashCodeMethod", "true"); - checkConfig.addProperty("ignoreAnnotation", "true"); final String[] expected = { "55:26: " + getCheckMessage(MSG_KEY, "3_000"), "56:32: " + getCheckMessage(MSG_KEY, "1.5_0"), @@ -371,9 +346,6 @@ public void testIgnoreHashCodeMethod() throws Exception { @Test public void testIgnoreFieldDeclaration() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MagicNumberCheck.class); - checkConfig.addProperty("ignoreFieldDeclaration", "true"); final String[] expected = { "55:26: " + getCheckMessage(MSG_KEY, "3_000"), "56:32: " + getCheckMessage(MSG_KEY, "1.5_0"), @@ -415,10 +387,6 @@ public void testIgnoreFieldDeclaration() @Test public void testWaiverParentToken() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MagicNumberCheck.class); - checkConfig.addProperty("constantWaiverParentToken", "ASSIGN, ARRAY_INIT," - + " EXPR, UNARY_PLUS, UNARY_MINUS, TYPECAST, ELIST, STAR, DIV, PLUS, MINUS"); final String[] expected = { "55:26: " + getCheckMessage(MSG_KEY, "3_000"), "56:32: " + getCheckMessage(MSG_KEY, "1.5_0"), @@ -479,8 +447,6 @@ public void testWaiverParentToken() @Test public void testMagicNumberRecordsDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MagicNumberCheck.class); final String[] expected = { "19:11: " + getCheckMessage(MSG_KEY, "6"), "21:36: " + getCheckMessage(MSG_KEY, "7"), @@ -495,9 +461,6 @@ public void testMagicNumberRecordsDefault() @Test public void testMagicNumberIgnoreFieldDeclarationRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MagicNumberCheck.class); - checkConfig.addProperty("ignoreFieldDeclaration", "true"); final String[] expected = { "19:11: " + getCheckMessage(MSG_KEY, "6"), "25:29: " + getCheckMessage(MSG_KEY, "8"), @@ -511,9 +474,6 @@ public void testMagicNumberIgnoreFieldDeclarationRecords() @Test public void testIgnoreInAnnotationElementDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MagicNumberCheck.class); - checkConfig.addProperty("ignoreAnnotationElementDefaults", "false"); final String[] expected = { "18:29: " + getCheckMessage(MSG_KEY, "10"), "19:33: " + getCheckMessage(MSG_KEY, "11"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheckTest.java index 06219ec61e4..219c253edc0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -41,8 +40,6 @@ protected String getPackageLocation() { @Test public void testCheckWithEmptyQuery() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMatchXpath.java"), expected); @@ -51,9 +48,6 @@ public void testCheckWithEmptyQuery() @Test public void testNoStackoverflowError() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", "//STRING_LITERAL[not(@text='')]"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMatchXpathNoStackoverflowError.java"), expected); @@ -62,9 +56,6 @@ public void testNoStackoverflowError() @Test public void testCheckWithImplicitEmptyQuery() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", ""); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMatchXpath2.java"), expected); @@ -73,9 +64,6 @@ public void testCheckWithImplicitEmptyQuery() @Test public void testCheckWithMatchingMethodNames() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", "//METHOD_DEF[./IDENT[@text='test' or @text='foo']]"); final String[] expected = { "11:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), "13:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), @@ -87,10 +75,6 @@ public void testCheckWithMatchingMethodNames() @Test public void testCheckWithNoMatchingMethodName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", "//METHOD_DEF[./IDENT[@text='wrongName' or " - + "@text='nonExistingMethod']]"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMatchXpath4.java"), expected); @@ -98,10 +82,6 @@ public void testCheckWithNoMatchingMethodName() @Test public void testCheckWithSingleLineCommentsStartsWithSpace() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", "//SINGLE_LINE_COMMENT" - + "[./COMMENT_CONTENT[not(starts-with(@text, ' '))]]"); final String[] expected = { "13:25: " + getCheckMessage(MatchXpathCheck.MSG_KEY), "14:27: " + getCheckMessage(MatchXpathCheck.MSG_KEY), @@ -112,11 +92,6 @@ public void testCheckWithSingleLineCommentsStartsWithSpace() throws Exception { @Test public void testCheckWithBlockComments() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", "//BLOCK_COMMENT_BEGIN" - + "[./COMMENT_CONTENT[contains(@text, '{') " - + "and not(starts-with(@text, '\\nMatchXpath'))]]"); final String[] expected = { "12:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), "14:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), @@ -127,11 +102,6 @@ public void testCheckWithBlockComments() throws Exception { @Test public void testCheckWithMultilineComments() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", "//BLOCK_COMMENT_BEGIN" - + "[./COMMENT_CONTENT[contains(@text, '\\n Forbidden comment\\n') " - + "and not(starts-with(@text, '\\nMatchXpath'))]]"); final String[] expected = { "14:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), "20:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), @@ -143,17 +113,6 @@ public void testCheckWithMultilineComments() throws Exception { @Test public void testCheckWithDoubleBraceInitialization() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - - checkConfig.addProperty("query", "//INSTANCE_INIT[not(../*[not(\n" - + " self::LCURLY or\n" - + " self::INSTANCE_INIT or\n" - + " self::RCURLY or\n" - + " self::SINGLE_LINE_COMMENT or\n" - + " self::BLOCK_COMMENT_BEGIN\n" - + " )])]"); - checkConfig.addMessage("matchxpath.match", "Do not use double-brace initialization"); final String[] expected = { "18:35: Do not use double-brace initialization", }; @@ -164,11 +123,6 @@ public void testCheckWithDoubleBraceInitialization() @Test public void testImitateIllegalThrowsCheck() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", "//LITERAL_THROWS[./IDENT[@text='Throwable' or " - + "@text='RuntimeException' or ends-with(@text, 'Error')]]"); - checkConfig.addMessage("matchxpath.match", "Illegal throws statement"); final String[] expected = { "13:25: Illegal throws statement", "15:25: Illegal throws statement", @@ -181,11 +135,6 @@ public void testImitateIllegalThrowsCheck() @Test public void testImitateExecutableStatementCountCheck() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", "//METHOD_DEF[count(./SLIST/*) > 2]"); - checkConfig.addMessage("matchxpath.match", "Executable number of statements " - + "exceed threshold"); final String[] expected = { "25:5: Executable number of statements exceed threshold", }; @@ -196,11 +145,6 @@ public void testImitateExecutableStatementCountCheck() @Test public void testForbidPrintStackTrace() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", "//LITERAL_CATCH" - + "//METHOD_CALL[.//IDENT[@text = 'printStackTrace']]/.."); - checkConfig.addMessage("matchxpath.match", "printStackTrace() method calls are forbidden"); final String[] expected = { "18:27: printStackTrace() method calls are forbidden", }; @@ -211,10 +155,6 @@ public void testForbidPrintStackTrace() @Test public void testForbidParameterizedConstructor() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", "//CTOR_DEF[count(./PARAMETERS/*) > 0]"); - checkConfig.addMessage("matchxpath.match", "Parameterized constructors are not allowed"); final String[] expected = { "13:5: Parameterized constructors are not allowed", "15:5: Parameterized constructors are not allowed", @@ -227,10 +167,6 @@ public void testForbidParameterizedConstructor() @Test public void testAvoidInstanceCreationWithoutVar() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MatchXpathCheck.class); - checkConfig.addProperty("query", "//VARIABLE_DEF[./ASSIGN/EXPR/LITERAL_NEW " - + "and not(./TYPE/IDENT[@text='var'])]"); final String[] expected = { "13:9: " + getCheckMessage(MatchXpathCheck.MSG_KEY), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingCtorCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingCtorCheckTest.java index 28ad7f8f2e2..fa6d6878dcc 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingCtorCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingCtorCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class MissingCtorCheckTest extends AbstractModuleTestSupport { @@ -36,8 +35,6 @@ protected String getPackageLocation() { @Test public void testMissingSwitchDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingCtorCheck.class); final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), @@ -58,8 +55,6 @@ public void testTokensNotNull() { @Test public void testMissingCtorClassOnOneLine() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingCtorCheck.class); final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingSwitchDefaultCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingSwitchDefaultCheckTest.java index bb5b19df682..6e27b52a83b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingSwitchDefaultCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingSwitchDefaultCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class MissingSwitchDefaultCheckTest extends AbstractModuleTestSupport { @@ -37,8 +36,6 @@ protected String getPackageLocation() { @Test public void testMissingSwitchDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingSwitchDefaultCheck.class); final String[] expected = { "23:9: " + getCheckMessage(MSG_KEY, "default"), "35:17: " + getCheckMessage(MSG_KEY, "default"), @@ -59,8 +56,6 @@ public void testTokensNotNull() { @Test public void testMissingSwitchDefaultSwitchExpressions() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingSwitchDefaultCheck.class); final String[] expected = { "14:9: " + getCheckMessage(MSG_KEY, "default"), }; @@ -71,8 +66,6 @@ public void testMissingSwitchDefaultSwitchExpressions() throws Exception { @Test public void testMissingSwitchDefaultSwitchExpressionsTwo() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingSwitchDefaultCheck.class); final String[] expected = { "14:9: " + getCheckMessage(MSG_KEY, "default"), "26:9: " + getCheckMessage(MSG_KEY, "default"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java index 34cf589d477..ac6ed424165 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java @@ -32,7 +32,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.JavaParser; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -50,8 +49,6 @@ protected String getPackageLocation() { @Test public void testModifiedControlVariable() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ModifiedControlVariableCheck.class); final String[] expected = { "17:14: " + getCheckMessage(MSG_KEY, "i"), "20:15: " + getCheckMessage(MSG_KEY, "i"), @@ -69,9 +66,6 @@ public void testModifiedControlVariable() throws Exception { @Test public void testEnhancedForLoopVariableTrue() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ModifiedControlVariableCheck.class); - checkConfig.addProperty("skipEnhancedForLoopVariable", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -81,8 +75,6 @@ public void testEnhancedForLoopVariableTrue() throws Exception { @Test public void testEnhancedForLoopVariableFalse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ModifiedControlVariableCheck.class); final String[] expected = { "16:18: " + getCheckMessage(MSG_KEY, "line"), @@ -94,9 +86,6 @@ public void testEnhancedForLoopVariableFalse() throws Exception { @Test public void testEnhancedForLoopVariable2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ModifiedControlVariableCheck.class); - checkConfig.addProperty("skipEnhancedForLoopVariable", "true"); final String[] expected = { "21:18: " + getCheckMessage(MSG_KEY, "i"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheckTest.java index bd1bfddaaa7..de4446142dc 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheckTest.java @@ -42,10 +42,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MultipleStringLiteralsCheck.class); - checkConfig.addProperty("allowedDuplicates", "2"); - checkConfig.addProperty("ignoreStringsRegexp", ""); final String[] expected = { "14:16: " + getCheckMessage(MSG_KEY, "\"StringContents\"", 3), @@ -60,9 +56,6 @@ public void testIt() throws Exception { @Test public void testItIgnoreEmpty() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MultipleStringLiteralsCheck.class); - checkConfig.addProperty("allowedDuplicates", "2"); final String[] expected = { "14:16: " + getCheckMessage(MSG_KEY, "\"StringContents\"", 3), @@ -98,10 +91,6 @@ public void testMultipleInputs() throws Exception { @Test public void testItIgnoreEmptyAndComspace() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MultipleStringLiteralsCheck.class); - checkConfig.addProperty("allowedDuplicates", "2"); - checkConfig.addProperty("ignoreStringsRegexp", "^((\"\")|(\", \"))$"); final String[] expected = { "14:16: " + getCheckMessage(MSG_KEY, "\"StringContents\"", 3), @@ -114,10 +103,6 @@ public void testItIgnoreEmptyAndComspace() throws Exception { @Test public void testItWithoutIgnoringAnnotations() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MultipleStringLiteralsCheck.class); - checkConfig.addProperty("allowedDuplicates", "3"); - checkConfig.addProperty("ignoreOccurrenceContext", ""); final String[] expected = { "28:23: " + getCheckMessage(MSG_KEY, "\"unchecked\"", 4), @@ -138,15 +123,12 @@ public void testTokensNotNull() { @Test public void testDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MultipleStringLiteralsCheck.class); final String[] expected = { "14:16: " + getCheckMessage(MSG_KEY, "\"StringContents\"", 3), "16:17: " + getCheckMessage(MSG_KEY, "\"DoubleString\"", 2), "19:23: " + getCheckMessage(MSG_KEY, "\", \"", 3), }; - createChecker(checkConfig); verifyWithInlineConfigParser( getPath("InputMultipleStringLiterals6.java"), expected); @@ -154,15 +136,10 @@ public void testDefaultConfiguration() throws Exception { @Test public void testIgnores() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MultipleStringLiteralsCheck.class); - checkConfig.addProperty("ignoreStringsRegexp", null); - checkConfig.addProperty("ignoreOccurrenceContext", "VARIABLE_DEF"); final String[] expected = { "28:23: " + getCheckMessage(MSG_KEY, "\"unchecked\"", 4), }; - createChecker(checkConfig); verifyWithInlineConfigParser( getPath("InputMultipleStringLiterals7.java"), expected); @@ -170,10 +147,6 @@ public void testIgnores() throws Exception { @Test public void testMultipleStringLiteralsTextBlocks() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MultipleStringLiteralsCheck.class); - checkConfig.addProperty("ignoreStringsRegexp", null); - checkConfig.addProperty("ignoreOccurrenceContext", "ANNOTATION"); final String[] expected = { "14:22: " + getCheckMessage(MSG_KEY, "\"string\"", 3), @@ -196,7 +169,6 @@ public void testMultipleStringLiteralsTextBlocks() throws Exception { + " bar\"", 2), }; - createChecker(checkConfig); verifyWithInlineConfigParser( getNonCompilablePath("InputMultipleStringLiteralsTextBlocks.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleVariableDeclarationsCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleVariableDeclarationsCheckTest.java index 15b761fcd01..11d068edac5 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleVariableDeclarationsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleVariableDeclarationsCheckTest.java @@ -26,7 +26,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class MultipleVariableDeclarationsCheckTest extends AbstractModuleTestSupport { @@ -37,8 +36,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MultipleVariableDeclarationsCheck.class); final String[] expected = { "11:5: " + getCheckMessage(MSG_MULTIPLE_COMMA), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheckTest.java index bdcdc92ad98..17c32dad4d5 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class NestedForDepthCheckTest extends AbstractModuleTestSupport { @@ -46,9 +45,6 @@ protected String getPackageLocation() { */ @Test public void testNestedTooDeep() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NestedForDepthCheck.class); - checkConfig.addProperty("max", "2"); final String[] expected = { "32:11: " + getCheckMessage(MSG_KEY, 3, 2), @@ -73,9 +69,6 @@ public void testNestedTooDeep() throws Exception { */ @Test public void testNestedOk() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NestedForDepthCheck.class); - checkConfig.addProperty("max", "4"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheckTest.java index 883846308d7..c0c0232a5f1 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class NestedIfDepthCheckTest extends AbstractModuleTestSupport { @@ -37,8 +36,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NestedIfDepthCheck.class); final String[] expected = { "26:17: " + getCheckMessage(MSG_KEY, 2, 1), @@ -51,9 +48,6 @@ public void testDefault() throws Exception { @Test public void testCustomizedDepth() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NestedIfDepthCheck.class); - checkConfig.addProperty("max", "2"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheckTest.java index df16fc69977..5a859500403 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class NestedTryDepthCheckTest extends AbstractModuleTestSupport { @@ -36,8 +35,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NestedTryDepthCheck.class); final String[] expected = { "29:17: " + getCheckMessage(MSG_KEY, 2, 1), @@ -51,9 +48,6 @@ public void testDefault() throws Exception { @Test public void testCustomizedDepth() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NestedTryDepthCheck.class); - checkConfig.addProperty("max", "2"); final String[] expected = { "41:21: " + getCheckMessage(MSG_KEY, 3, 2), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoArrayTrailingCommaCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoArrayTrailingCommaCheckTest.java index 759130e337b..cd8a670b726 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoArrayTrailingCommaCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoArrayTrailingCommaCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class NoArrayTrailingCommaCheckTest extends AbstractModuleTestSupport { @@ -36,8 +35,6 @@ public String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NoArrayTrailingCommaCheck.class); final String[] expected = { "20:14: " + getCheckMessage(MSG_KEY), "25:32: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoCloneCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoCloneCheckTest.java index 26a67694cb1..e1f00198318 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoCloneCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoCloneCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class NoCloneCheckTest extends AbstractModuleTestSupport { @@ -38,8 +37,6 @@ protected String getPackageLocation() { @Test public void testHasClone() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NoCloneCheck.class); final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY), "34:5: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoEnumTrailingCommaCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoEnumTrailingCommaCheckTest.java index 9c07afa8aa1..c096becec12 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoEnumTrailingCommaCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoEnumTrailingCommaCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class NoEnumTrailingCommaCheckTest extends AbstractModuleTestSupport { @@ -36,8 +35,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NoEnumTrailingCommaCheck.class); final String[] expected = { "23:12: " + getCheckMessage(MSG_KEY), "28:12: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoFinalizerCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoFinalizerCheckTest.java index b2d1952fb0c..50682ec41be 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoFinalizerCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoFinalizerCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -54,8 +53,6 @@ public void testGetAcceptableTokens() { @Test public void testHasFinalizer() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NoFinalizerCheck.class); final String[] expected = { "11:5: " + getCheckMessage(MSG_KEY), }; @@ -66,8 +63,6 @@ public void testHasFinalizer() @Test public void testHasNoFinalizer() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NoFinalizerCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNoFinalizerFallThrough.java"), expected); @@ -76,8 +71,6 @@ public void testHasNoFinalizer() @Test public void testHasNoFinalizerTryWithResource() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NoFinalizerCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputNoFinalizerFallThrough.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OneStatementPerLineCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OneStatementPerLineCheckTest.java index 864267d5da1..01468c88d92 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OneStatementPerLineCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OneStatementPerLineCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { @@ -37,7 +36,6 @@ protected String getPackageLocation() { @Test public void testMultiCaseClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OneStatementPerLineCheck.class); final String[] expected = { "13:59: " + getCheckMessage(MSG_KEY), "93:21: " + getCheckMessage(MSG_KEY), @@ -63,8 +61,6 @@ public void testTokensNotNull() { @Test public void testWithMultilineStatements() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OneStatementPerLineCheck.class); - checkConfig.addProperty("treatTryResourcesAsStatement", "true"); final String[] expected = { "49:21: " + getCheckMessage(MSG_KEY), "66:17: " + getCheckMessage(MSG_KEY), @@ -83,7 +79,6 @@ public void testWithMultilineStatements() throws Exception { @Test public void oneStatementNonCompilableInputTest() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OneStatementPerLineCheck.class); final String[] expected = { "39:6: " + getCheckMessage(MSG_KEY), "44:58: " + getCheckMessage(MSG_KEY), @@ -99,8 +94,6 @@ public void oneStatementNonCompilableInputTest() throws Exception { @Test public void testResourceReferenceVariableIgnored() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OneStatementPerLineCheck.class); - checkConfig.addProperty("treatTryResourcesAsStatement", "true"); final String[] expected = { "32:42: " + getCheckMessage(MSG_KEY), "36:43: " + getCheckMessage(MSG_KEY), @@ -115,7 +108,6 @@ public void testResourceReferenceVariableIgnored() throws Exception { @Test public void testResourcesIgnored() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OneStatementPerLineCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputOneStatementPerLineTryWithResourcesIgnore.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OverloadMethodsDeclarationOrderCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OverloadMethodsDeclarationOrderCheckTest.java index dd6e0def70c..2cffe39731c 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OverloadMethodsDeclarationOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OverloadMethodsDeclarationOrderCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class OverloadMethodsDeclarationOrderCheckTest extends AbstractModuleTestSupport { @@ -37,8 +36,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OverloadMethodsDeclarationOrderCheck.class); final String[] expected = { "32:5: " + getCheckMessage(MSG_KEY, 21), @@ -52,8 +49,6 @@ public void testDefault() throws Exception { @Test public void testOverloadMethodsDeclarationOrderRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OverloadMethodsDeclarationOrderCheck.class); final String[] expected = { "21:9: " + getCheckMessage(MSG_KEY, 15), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/PackageDeclarationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/PackageDeclarationCheckTest.java index 0f38f94cfe4..e3cb127131e 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/PackageDeclarationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/PackageDeclarationCheckTest.java @@ -39,7 +39,6 @@ protected String getPackageLocation() { @Test public void testDefaultNoPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY_MISSING), @@ -51,7 +50,6 @@ public void testDefaultNoPackage() throws Exception { @Test public void testDefaultWithPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -61,7 +59,6 @@ public void testDefaultWithPackage() throws Exception { @Test public void testOnFileWithCommentOnly() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -71,7 +68,6 @@ public void testOnFileWithCommentOnly() throws Exception { @Test public void testFileForDiffDirectoryMismatch() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY_MISMATCH), @@ -83,7 +79,6 @@ public void testFileForDiffDirectoryMismatch() throws Exception { @Test public void testFileForDirectoryMismatchAtParent() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY_MISMATCH), @@ -96,7 +91,6 @@ public void testFileForDirectoryMismatchAtParent() throws Exception { @Test public void testFileForDirectoryMismatchAtSubpackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY_MISMATCH), @@ -109,8 +103,6 @@ public void testFileForDirectoryMismatchAtSubpackage() throws Exception { @Test public void testFileIgnoreDiffDirectoryMismatch() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); - checkConfig.addProperty("matchDirectoryStructure", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -120,8 +112,6 @@ public void testFileIgnoreDiffDirectoryMismatch() throws Exception { @Test public void testFileIgnoreDirectoryMismatchAtParent() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); - checkConfig.addProperty("matchDirectoryStructure", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -131,8 +121,6 @@ public void testFileIgnoreDirectoryMismatchAtParent() throws Exception { @Test public void testFileIgnoreDirectoryMismatchAtSubpackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); - checkConfig.addProperty("matchDirectoryStructure", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -142,7 +130,6 @@ public void testFileIgnoreDirectoryMismatchAtSubpackage() throws Exception { @Test public void testNoPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY_MISSING), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java index 4a6e5217e6f..05fe7504910 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java @@ -32,7 +32,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.JavaParser; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -50,8 +49,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterAssignmentCheck.class); final String[] expected = { "15:15: " + getCheckMessage(MSG_KEY, "field"), "16:15: " + getCheckMessage(MSG_KEY, "field"), @@ -65,7 +62,6 @@ public void testDefault() @Test public void testReceiverParameter() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParameterAssignmentCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputParameterAssignmentReceiver.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/RequireThisCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/RequireThisCheckTest.java index ec9f7a87094..02743473278 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/RequireThisCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/RequireThisCheckTest.java @@ -35,7 +35,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.JavaParser; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -53,9 +52,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = { "20:9: " + getCheckMessage(MSG_VARIABLE, "i", ""), "26:9: " + getCheckMessage(MSG_METHOD, "method1", ""), @@ -83,10 +79,6 @@ public void testIt() throws Exception { @Test public void testMethodsOnly() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("checkFields", "false"); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = { "25:9: " + getCheckMessage(MSG_METHOD, "method1", ""), "124:9: " + getCheckMessage(MSG_METHOD, "instanceMethod", ""), @@ -100,10 +92,6 @@ public void testMethodsOnly() throws Exception { @Test public void testFieldsOnly() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("checkMethods", "false"); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = { "19:9: " + getCheckMessage(MSG_VARIABLE, "i", ""), "39:9: " + getCheckMessage(MSG_VARIABLE, "i", ""), @@ -127,10 +115,6 @@ public void testFieldsOnly() throws Exception { @Test public void testFieldsInExpressions() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("checkMethods", "false"); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = { "18:28: " + getCheckMessage(MSG_VARIABLE, "id", ""), "19:28: " + getCheckMessage(MSG_VARIABLE, "length", ""), @@ -159,9 +143,6 @@ public void testFieldsInExpressions() throws Exception { @Test public void testGenerics() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRequireThis15Extensions.java"), expected); @@ -169,9 +150,6 @@ public void testGenerics() throws Exception { @Test public void testGithubIssue41() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = { "16:19: " + getCheckMessage(MSG_VARIABLE, "number", ""), "17:16: " + getCheckMessage(MSG_METHOD, "other", ""), @@ -191,8 +169,6 @@ public void testTokensNotNull() { @Test public void testWithAnonymousClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = { "28:25: " + getCheckMessage(MSG_METHOD, "doSideEffect", ""), "32:24: " + getCheckMessage(MSG_VARIABLE, "bar", "InputRequireThisAnonymousEmpty."), @@ -218,8 +194,6 @@ public void testDefaultSwitch() { @Test public void testValidateOnlyOverlappingFalse() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = { "29:9: " + getCheckMessage(MSG_VARIABLE, "field1", ""), "30:9: " + getCheckMessage(MSG_VARIABLE, "fieldFinal1", ""), @@ -273,7 +247,6 @@ public void testValidateOnlyOverlappingFalse() throws Exception { @Test public void testValidateOnlyOverlappingTrue() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); final String[] expected = { "29:9: " + getCheckMessage(MSG_VARIABLE, "field1", ""), "52:9: " + getCheckMessage(MSG_VARIABLE, "field1", ""), @@ -294,7 +267,6 @@ public void testValidateOnlyOverlappingTrue() throws Exception { @Test public void testReceiverParameter() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRequireThisReceiver.java"), expected); @@ -302,8 +274,6 @@ public void testReceiverParameter() throws Exception { @Test public void testBraceAlone() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRequireThisBraceAlone.java"), expected); @@ -311,8 +281,6 @@ public void testBraceAlone() throws Exception { @Test public void testStatic() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRequireThisStatic.java"), expected); @@ -320,7 +288,6 @@ public void testStatic() throws Exception { @Test public void testMethodReferences() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); final String[] expected = { "24:9: " + getCheckMessage(MSG_VARIABLE, "tags", ""), }; @@ -330,9 +297,6 @@ public void testMethodReferences() throws Exception { @Test public void testAllowLocalVars() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); - checkConfig.addProperty("checkMethods", "false"); final String[] expected = { "18:9: " + getCheckMessage(MSG_VARIABLE, "s1", ""), "26:9: " + getCheckMessage(MSG_VARIABLE, "s1", ""), @@ -347,9 +311,6 @@ public void testAllowLocalVars() throws Exception { @Test public void testAllowLambdaParameters() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); - checkConfig.addProperty("checkMethods", "false"); final String[] expected = { "24:9: " + getCheckMessage(MSG_VARIABLE, "s1", ""), "46:21: " + getCheckMessage(MSG_VARIABLE, "z", ""), @@ -362,8 +323,6 @@ public void testAllowLambdaParameters() throws Exception { @Test public void testCatchVariables() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = { "38:21: " + getCheckMessage(MSG_VARIABLE, "ex", ""), }; @@ -373,8 +332,6 @@ public void testCatchVariables() throws Exception { @Test public void testEnumConstant() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRequireThisEnumConstant.java"), expected); @@ -382,8 +339,6 @@ public void testEnumConstant() throws Exception { @Test public void testAnnotationInterface() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRequireThisAnnotationInterface.java"), expected); @@ -391,8 +346,6 @@ public void testAnnotationInterface() throws Exception { @Test public void testFor() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = { "22:13: " + getCheckMessage(MSG_VARIABLE, "bottom", ""), "30:34: " + getCheckMessage(MSG_VARIABLE, "name", ""), @@ -403,7 +356,6 @@ public void testFor() throws Exception { @Test public void testFinalInstanceVariable() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); final String[] expected = { "18:9: " + getCheckMessage(MSG_VARIABLE, "y", ""), "19:9: " + getCheckMessage(MSG_VARIABLE, "z", ""), @@ -414,7 +366,6 @@ public void testFinalInstanceVariable() throws Exception { @Test public void test() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRequireThisCaseGroup.java"), expected); @@ -422,8 +373,6 @@ public void test() throws Exception { @Test public void testExtendedMethod() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRequireThisExtendedMethod.java"), expected); @@ -431,9 +380,6 @@ public void testExtendedMethod() throws Exception { @Test public void testRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("checkFields", "false"); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = { "18:13: " + getCheckMessage(MSG_METHOD, "method1", ""), "19:13: " + getCheckMessage(MSG_METHOD, "method2", ""), @@ -451,8 +397,6 @@ public void testRecordsAndCompactCtors() throws Exception { @Test public void testRecordCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputRequireThisRecordCompactCtors.java"), @@ -461,9 +405,6 @@ public void testRecordCompactCtors() throws Exception { @Test public void testRecordsAsTopLevel() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); - checkConfig.addProperty("checkFields", "true"); - checkConfig.addProperty("validateOnlyOverlapping", "false"); final String[] expected = { "17:9: " + getCheckMessage(MSG_METHOD, "method1", ""), "18:9: " + getCheckMessage(MSG_METHOD, "method2", ""), @@ -480,7 +421,6 @@ public void testRecordsAsTopLevel() throws Exception { @Test public void testRecordsDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RequireThisCheck.class); final String[] expected = { "26:9: " + getCheckMessage(MSG_VARIABLE, "x", ""), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckTest.java index f88f0ce9ea2..7722621ff23 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckTest.java @@ -32,7 +32,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.JavaParser; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -49,8 +48,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ReturnCountCheck.class); final String[] expected = { "28:5: " + getCheckMessage(MSG_KEY_VOID, 7, 1), "40:5: " + getCheckMessage(MSG_KEY_VOID, 2, 1), @@ -63,9 +60,6 @@ public void testDefault() throws Exception { @Test public void testFormat() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ReturnCountCheck.class); - checkConfig.addProperty("format", "^$"); final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY, 7, 2), "28:5: " + getCheckMessage(MSG_KEY_VOID, 7, 1), @@ -79,8 +73,6 @@ public void testFormat() throws Exception { @Test public void testMethodsAndLambdas() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ReturnCountCheck.class); - checkConfig.addProperty("max", "1"); final String[] expected = { "25:55: " + getCheckMessage(MSG_KEY, 2, 1), "37:49: " + getCheckMessage(MSG_KEY, 2, 1), @@ -94,8 +86,6 @@ public void testMethodsAndLambdas() throws Exception { @Test public void testLambdasOnly() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ReturnCountCheck.class); - checkConfig.addProperty("tokens", "LAMBDA"); final String[] expected = { "43:42: " + getCheckMessage(MSG_KEY, 3, 2), }; @@ -105,8 +95,6 @@ public void testLambdasOnly() throws Exception { @Test public void testMethodsOnly() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ReturnCountCheck.class); - checkConfig.addProperty("tokens", "METHOD_DEF"); final String[] expected = { "35:5: " + getCheckMessage(MSG_KEY, 3, 2), "42:5: " + getCheckMessage(MSG_KEY, 4, 2), @@ -119,8 +107,6 @@ public void testMethodsOnly() throws Exception { @Test public void testWithReturnOnlyAsTokens() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ReturnCountCheck.class); - checkConfig.addProperty("tokens", "LITERAL_RETURN"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputReturnCountLambda4.java"), expected); @@ -152,9 +138,6 @@ public void testImproperToken() { @Test public void testMaxForVoid() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ReturnCountCheck.class); - checkConfig.addProperty("max", "2"); - checkConfig.addProperty("maxForVoid", "0"); final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY_VOID, 1, 0), "18:5: " + getCheckMessage(MSG_KEY_VOID, 1, 0), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanExpressionCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanExpressionCheckTest.java index 89f31ec947d..ea72c62e660 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanExpressionCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanExpressionCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class SimplifyBooleanExpressionCheckTest extends AbstractModuleTestSupport { @@ -37,8 +36,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SimplifyBooleanExpressionCheck.class); final String[] expected = { "22:18: " + getCheckMessage(MSG_KEY), "43:36: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanReturnCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanReturnCheckTest.java index d321d1cf302..9d4ff2a258b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanReturnCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanReturnCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class SimplifyBooleanReturnCheckTest extends AbstractModuleTestSupport { @@ -37,8 +36,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SimplifyBooleanReturnCheck.class); final String[] expected = { "22:9: " + getCheckMessage(MSG_KEY), "35:9: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/StringLiteralEqualityCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/StringLiteralEqualityCheckTest.java index 25563304e0f..435f7699064 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/StringLiteralEqualityCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/StringLiteralEqualityCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class StringLiteralEqualityCheckTest extends AbstractModuleTestSupport { @@ -37,8 +36,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(StringLiteralEqualityCheck.class); final String[] expected = { "17:18: " + getCheckMessage(MSG_KEY, "=="), "22:20: " + getCheckMessage(MSG_KEY, "=="), @@ -50,8 +47,6 @@ public void testIt() throws Exception { @Test public void testStringLiteralEqualityTextBlocks() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(StringLiteralEqualityCheck.class); final String[] expected = { "14:34: " + getCheckMessage(MSG_KEY, "=="), "22:21: " + getCheckMessage(MSG_KEY, "=="), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperCloneCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperCloneCheckTest.java index 2046c74f9fe..dab13330bc2 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperCloneCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperCloneCheckTest.java @@ -31,7 +31,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.JavaParser; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; @@ -48,8 +47,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SuperCloneCheck.class); final String[] expected = { "33:19: " + getCheckMessage(MSG_KEY, "clone", "super.clone"), "41:19: " + getCheckMessage(MSG_KEY, "clone", "super.clone"), @@ -61,8 +58,6 @@ public void testIt() throws Exception { @Test public void testAnotherInputFile() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SuperCloneCheck.class); final String[] expected = { "14:17: " + getCheckMessage(MSG_KEY, "clone", "super.clone"), "48:17: " + getCheckMessage(MSG_KEY, "clone", "super.clone"), @@ -73,8 +68,6 @@ public void testAnotherInputFile() throws Exception { @Test public void testMethodReference() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SuperCloneCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputSuperCloneMethodReference.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckTest.java index 231f1e51e74..c9a7cc22ec0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckTest.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class SuperFinalizeCheckTest extends AbstractModuleTestSupport { @@ -36,8 +35,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SuperFinalizeCheck.class); final String[] expected = { "34:17: " + getCheckMessage(MSG_KEY, "finalize", "super.finalize"), "41:17: " + getCheckMessage(MSG_KEY, "finalize", "super.finalize"), @@ -49,8 +46,6 @@ public void testIt() throws Exception { @Test public void testMethodReference() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SuperFinalizeCheck.class); final String[] expected = { "23:20: " + getCheckMessage(MSG_KEY, "finalize", "super.finalize"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckTest.java index e8d21581668..b53ced4e4f7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckTest.java @@ -31,7 +31,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; /** * Test fixture for the UnnecessaryParenthesesCheck. @@ -46,8 +45,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessaryParenthesesCheck.class); final String[] expected = { "18:22: " + getCheckMessage(MSG_ASSIGN), @@ -104,8 +101,6 @@ public void testDefault() throws Exception { @Test public void test15Extensions() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessaryParenthesesCheck.class); final String[] expected = { "28:23: " + getCheckMessage(MSG_EXPR), "28:51: " + getCheckMessage(MSG_LITERAL, "1"), @@ -116,9 +111,6 @@ public void test15Extensions() throws Exception { @Test public void testLambdas() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessaryParenthesesCheck.class); - checkConfig.addProperty("tokens", "LAMBDA"); final String[] expected = { "17:35: " + getCheckMessage(MSG_LAMBDA), "18:35: " + getCheckMessage(MSG_LAMBDA), @@ -135,8 +127,6 @@ public void testLambdas() throws Exception { @Test public void testUnnecessaryParenthesesSwitchExpression() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessaryParenthesesCheck.class); final String[] expected = { "21:50: " + getCheckMessage(MSG_ASSIGN), "24:19: " + getCheckMessage(MSG_LITERAL, 2), @@ -158,8 +148,6 @@ public void testUnnecessaryParenthesesSwitchExpression() throws Exception { @Test public void testUnnecessaryParenthesesTextBlocks() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessaryParenthesesCheck.class); final String[] expected = { "19:27: " + getCheckMessage(MSG_STRING, "\"this\""), "19:38: " + getCheckMessage(MSG_STRING, "\"that\""), @@ -189,8 +177,6 @@ public void testTokensNotNull() { @Test public void testIfStatement() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessaryParenthesesCheck.class); final String[] expected = { "20:20: " + getCheckMessage(MSG_EXPR), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterOuterTypeDeclarationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterOuterTypeDeclarationCheckTest.java index f4ac4e79f99..a22cd5f9a46 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterOuterTypeDeclarationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterOuterTypeDeclarationCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -40,8 +39,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessarySemicolonAfterOuterTypeDeclarationCheck.class); final String[] expected = { "28:2: " + getCheckMessage(MSG_SEMI), @@ -57,8 +54,6 @@ public void testDefault() throws Exception { @Test public void testUnnecessarySemicolonAfterOuterTypeDeclarationRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessarySemicolonAfterOuterTypeDeclarationCheck.class); final String[] expected = { "17:2: " + getCheckMessage(MSG_SEMI), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest.java index a470c46c8d9..47854a7b130 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -40,8 +39,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessarySemicolonAfterTypeMemberDeclarationCheck.class); final String[] expected = { "13:5: " + getCheckMessage(MSG_SEMI), @@ -67,8 +64,6 @@ public void testDefault() throws Exception { @Test public void testUnnecessarySemicolonAfterTypeMemberDeclarationRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessarySemicolonAfterTypeMemberDeclarationCheck.class); final String[] expected = { "14:5: " + getCheckMessage(MSG_SEMI), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInEnumerationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInEnumerationCheckTest.java index 81fee5f1b07..1cc9f742981 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInEnumerationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInEnumerationCheckTest.java @@ -25,7 +25,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; /** @@ -42,8 +41,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessarySemicolonInEnumerationCheck.class); final String[] expected = { "30:12: " + getCheckMessage(MSG_SEMI), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInTryWithResourcesCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInTryWithResourcesCheckTest.java index 6b453f32e11..50a44e749a0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInTryWithResourcesCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInTryWithResourcesCheckTest.java @@ -25,7 +25,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 UnnecessarySemicolonInTryWithResourcesCheckTest extends AbstractModuleTestSupport { @@ -38,8 +37,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessarySemicolonInTryWithResourcesCheck.class); final String[] expected = { "17:42: " + getCheckMessage(MSG_SEMI), @@ -53,9 +50,6 @@ public void testDefault() throws Exception { @Test public void testNoBraceAfterAllowed() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(UnnecessarySemicolonInTryWithResourcesCheck.class); - checkConfig.addProperty("allowWhenNoBraceAfterSemicolon", "false"); final String[] expected = { "16:42: " + getCheckMessage(MSG_SEMI), "19:13: " + getCheckMessage(MSG_SEMI), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckTest.java index 876a6871a78..62a58d0dd1b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckTest.java @@ -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.utils.CommonUtil; public class VariableDeclarationUsageDistanceCheckTest extends @@ -39,12 +38,6 @@ protected String getPackageLocation() { @Test public void testGeneralLogic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VariableDeclarationUsageDistanceCheck.class); - checkConfig.addProperty("allowedDistance", "1"); - checkConfig.addProperty("ignoreVariablePattern", ""); - checkConfig.addProperty("validateBetweenScopes", "true"); - checkConfig.addProperty("ignoreFinal", "false"); final String[] expected = { "42:9: " + getCheckMessage(MSG_KEY, "a", 2, 1), "50:9: " + getCheckMessage(MSG_KEY, "temp", 2, 1), @@ -89,12 +82,6 @@ public void testGeneralLogic() throws Exception { @Test public void testDistance() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VariableDeclarationUsageDistanceCheck.class); - checkConfig.addProperty("allowedDistance", "3"); - checkConfig.addProperty("ignoreVariablePattern", ""); - checkConfig.addProperty("validateBetweenScopes", "true"); - checkConfig.addProperty("ignoreFinal", "false"); final String[] expected = { "83:9: " + getCheckMessage(MSG_KEY, "count", 4, 3), "231:9: " + getCheckMessage(MSG_KEY, "t", 5, 3), @@ -112,13 +99,6 @@ public void testDistance() throws Exception { @Test public void testVariableRegExp() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VariableDeclarationUsageDistanceCheck.class); - checkConfig.addProperty("allowedDistance", "1"); - checkConfig.addProperty("ignoreVariablePattern", - "a|b|c|d|block|dist|t|m"); - checkConfig.addProperty("validateBetweenScopes", "true"); - checkConfig.addProperty("ignoreFinal", "false"); final String[] expected = { "50:9: " + getCheckMessage(MSG_KEY, "temp", 2, 1), "56:9: " + getCheckMessage(MSG_KEY, "temp", 2, 1), @@ -152,12 +132,6 @@ public void testVariableRegExp() throws Exception { @Test public void testValidateBetweenScopesOption() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VariableDeclarationUsageDistanceCheck.class); - checkConfig.addProperty("allowedDistance", "1"); - checkConfig.addProperty("ignoreVariablePattern", ""); - checkConfig.addProperty("validateBetweenScopes", "false"); - checkConfig.addProperty("ignoreFinal", "false"); final String[] expected = { "42:9: " + getCheckMessage(MSG_KEY, "a", 2, 1), "50:9: " + getCheckMessage(MSG_KEY, "temp", 2, 1), @@ -190,12 +164,6 @@ public void testValidateBetweenScopesOption() throws Exception { @Test public void testIgnoreFinalOption() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VariableDeclarationUsageDistanceCheck.class); - checkConfig.addProperty("allowedDistance", "1"); - checkConfig.addProperty("ignoreVariablePattern", ""); - checkConfig.addProperty("validateBetweenScopes", "true"); - checkConfig.addProperty("ignoreFinal", "true"); final String[] expected = { "42:9: " + getCheckMessage(MSG_KEY_EXT, "a", 2, 1), "50:9: " + getCheckMessage(MSG_KEY_EXT, "temp", 2, 1), @@ -247,8 +215,6 @@ public void testTokensNotNull() { @Test public void testDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VariableDeclarationUsageDistanceCheck.class); final String[] expected = { "83:9: " + getCheckMessage(MSG_KEY_EXT, "count", 4, 3), "231:9: " + getCheckMessage(MSG_KEY_EXT, "t", 5, 3), @@ -265,8 +231,6 @@ public void testDefaultConfiguration() throws Exception { @Test public void testAnonymousClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VariableDeclarationUsageDistanceCheck.class); final String[] expected = { "19:9: " + getCheckMessage(MSG_KEY_EXT, "prefs", 4, 3), }; @@ -278,8 +242,6 @@ public void testAnonymousClass() throws Exception { @Test public void testLabels() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VariableDeclarationUsageDistanceCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -288,12 +250,6 @@ public void testLabels() throws Exception { @Test public void testVariableDeclarationUsageDistanceSwitchExpressions() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VariableDeclarationUsageDistanceCheck.class); - checkConfig.addProperty("allowedDistance", "1"); - checkConfig.addProperty("ignoreVariablePattern", ""); - checkConfig.addProperty("validateBetweenScopes", "true"); - checkConfig.addProperty("ignoreFinal", "false"); final int maxDistance = 1; final String[] expected = { diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/DesignForExtensionCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/DesignForExtensionCheckTest.java index ffc9e8b27a8..d0ce81776c0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/DesignForExtensionCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/DesignForExtensionCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -47,8 +46,6 @@ public void testGetRequiredTokens() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(DesignForExtensionCheck.class); final String[] expected = { "50:5: " + getCheckMessage(MSG_KEY, "InputDesignForExtension", "doh"), "104:9: " + getCheckMessage(MSG_KEY, "anotherNonFinalClass", "someMethod"), @@ -67,7 +64,6 @@ public void testGetAcceptableTokens() { @Test public void testOverridableMethods() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DesignForExtensionCheck.class); final String[] expected = { "14:9: " + getCheckMessage(MSG_KEY, "A", "foo1"), "38:9: " + getCheckMessage(MSG_KEY, "A", "foo8"), @@ -95,8 +91,6 @@ public void testOverridableMethods() throws Exception { @Test public void testIgnoredAnnotationsOption() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DesignForExtensionCheck.class); - checkConfig.addProperty("ignoredAnnotations", "Override, Deprecated, MyAnnotation"); final String[] expected = { "39:5: " + getCheckMessage(MSG_KEY, "InputDesignForExtensionIgnoredAnnotations", "foo1"), @@ -113,9 +107,6 @@ public void testIgnoredAnnotationsOption() throws Exception { @Test public void testIgnoreAnnotationsOptionWithMultipleAnnotations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DesignForExtensionCheck.class); - checkConfig.addProperty("ignoredAnnotations", - "Override, Deprecated, Before, After, BeforeClass, AfterClass"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputDesignForExtensionMultipleAnnotations.java"), expected); @@ -123,8 +114,6 @@ public void testIgnoreAnnotationsOptionWithMultipleAnnotations() throws Exceptio @Test public void testNativeMethods() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DesignForExtensionCheck.class); - checkConfig.addProperty("ignoredAnnotations", "Deprecated"); final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY, "InputDesignForExtensionNativeMethods", "foo1"), "32:5: " + getCheckMessage(MSG_KEY, "InputDesignForExtensionNativeMethods", "foo6"), @@ -135,7 +124,6 @@ public void testNativeMethods() throws Exception { @Test public void testDesignForExtensionRecords() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DesignForExtensionCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -145,8 +133,6 @@ public void testDesignForExtensionRecords() throws Exception { @Test public void testRequiredJavadocPhrase() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DesignForExtensionCheck.class); - checkConfig.addProperty("requiredJavadocPhrase", "This implementation"); final String className = "InputDesignForExtensionRequiredJavadocPhrase"; final String[] expected = { "41:5: " + getCheckMessage(MSG_KEY, className, "foo5"), @@ -160,8 +146,6 @@ public void testRequiredJavadocPhrase() throws Exception { @Test public void testRequiredJavadocPhraseMultiLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DesignForExtensionCheck.class); - checkConfig.addProperty("requiredJavadocPhrase", "This[\\s\\S]*implementation"); final String className = "InputDesignForExtensionRequiredJavadocPhraseMultiLine"; final String[] expected = { "23:5: " + getCheckMessage(MSG_KEY, className, "foo2"), @@ -173,7 +157,6 @@ public void testRequiredJavadocPhraseMultiLine() throws Exception { @Test public void testInterfaceMemberScopeIsPublic() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(DesignForExtensionCheck.class); final String[] expected = { "15:9: " + getCheckMessage(MSG_KEY, "Inner", "getProperty"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/FinalClassCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/FinalClassCheckTest.java index 3451e60d8d8..a1c7368cda6 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/FinalClassCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/FinalClassCheckTest.java @@ -30,7 +30,6 @@ import org.powermock.reflect.Whitebox; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -58,8 +57,6 @@ public void testGetRequiredTokens() { @Test public void testFinalClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalClassCheck.class); final String[] expected = { "11:1: " + getCheckMessage(MSG_KEY, "InputFinalClass"), "19:4: " + getCheckMessage(MSG_KEY, "test4"), @@ -73,8 +70,6 @@ public void testFinalClass() throws Exception { @Test public void testClassWithPrivateCtorAndNestedExtendingSubclass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalClassCheck.class); final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY, "C"), }; @@ -87,8 +82,6 @@ public void testClassWithPrivateCtorAndNestedExtendingSubclass() throws Exceptio @Test public void testClassWithPrivateCtorAndNestedExtendingSubclassWithoutPackage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalClassCheck.class); final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY, "C"), }; @@ -100,8 +93,6 @@ public void testClassWithPrivateCtorAndNestedExtendingSubclassWithoutPackage() @Test public void testFinalClassConstructorInRecord() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FinalClassCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheckTest.java index ae840353134..1b836d83a4b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -48,8 +47,6 @@ public void testGetRequiredTokens() { @Test public void testUtilClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HideUtilityClassConstructorCheck.class); final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), }; @@ -60,8 +57,6 @@ public void testUtilClass() throws Exception { @Test public void testUtilClassPublicCtor() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HideUtilityClassConstructorCheck.class); final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), }; @@ -71,8 +66,6 @@ public void testUtilClassPublicCtor() throws Exception { @Test public void testUtilClassPrivateCtor() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HideUtilityClassConstructorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorPrivate.java"), expected); @@ -81,8 +74,6 @@ public void testUtilClassPrivateCtor() throws Exception { /** Non-static methods - always OK. */ @Test public void testNonUtilClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HideUtilityClassConstructorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorDesignForExtension.java"), @@ -91,8 +82,6 @@ public void testNonUtilClass() throws Exception { @Test public void testDerivedNonUtilClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HideUtilityClassConstructorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorNonUtilityClass.java"), @@ -101,8 +90,6 @@ public void testDerivedNonUtilClass() throws Exception { @Test public void testOnlyNonStaticFieldNonUtilClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HideUtilityClassConstructorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorRegression.java"), @@ -111,8 +98,6 @@ public void testOnlyNonStaticFieldNonUtilClass() throws Exception { @Test public void testEmptyAbstractClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HideUtilityClassConstructorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorAbstractSerializable.java"), @@ -121,8 +106,6 @@ public void testEmptyAbstractClass() throws Exception { @Test public void testEmptyAbstractClass2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HideUtilityClassConstructorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorAbstract.java"), @@ -131,8 +114,6 @@ public void testEmptyAbstractClass2() throws Exception { @Test public void testEmptyClassWithOnlyPrivateFields() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HideUtilityClassConstructorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorSerializable.java"), @@ -141,8 +122,6 @@ public void testEmptyClassWithOnlyPrivateFields() throws Exception { @Test public void testClassWithStaticInnerClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HideUtilityClassConstructorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath( @@ -152,8 +131,6 @@ public void testClassWithStaticInnerClass() throws Exception { @Test public void testProtectedCtor() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(HideUtilityClassConstructorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructor.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheckTest.java index e4e698f3b20..5758dd0f5a7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheckTest.java @@ -52,8 +52,6 @@ public void testGetRequiredTokens() { @Test public void testMembersBeforeInner() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InnerTypeLastCheck.class); final String[] expected = { "50:9: " + getCheckMessage(MSG_KEY), "71:9: " + getCheckMessage(MSG_KEY), @@ -67,8 +65,6 @@ public void testMembersBeforeInner() throws Exception { @Test public void testIfRootClassChecked() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InnerTypeLastCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInnerTypeLastClassRootClass.java"), expected); @@ -76,8 +72,6 @@ public void testIfRootClassChecked() throws Exception { @Test public void testIfRootClassChecked2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InnerTypeLastCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInnerTypeLastClassRootClass2.java"), expected); @@ -96,8 +90,6 @@ public void testIfRootClassChecked3() throws Exception { @Test public void testInnerTypeBeforeCtor() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InnerTypeLastCheck.class); final String[] expected = { "13:5: " + getCheckMessage(MSG_KEY), "22:5: " + getCheckMessage(MSG_KEY), @@ -109,8 +101,6 @@ public void testInnerTypeBeforeCtor() throws Exception { @Test public void testInnerTypeLastRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InnerTypeLastCheck.class); final String[] expected = { "17:9: " + getCheckMessage(MSG_KEY), @@ -127,8 +117,6 @@ public void testInnerTypeLastRecords() throws Exception { @Test public void testInnerTypeLastCstyleArray() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InnerTypeLastCheck.class); final String[] expected = { "11:5: " + getCheckMessage(MSG_KEY), "12:5: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InterfaceIsTypeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InterfaceIsTypeCheckTest.java index 30a6aab85f7..acb25a20bb8 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InterfaceIsTypeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InterfaceIsTypeCheckTest.java @@ -25,7 +25,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 InterfaceIsTypeCheckTest @@ -39,8 +38,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceIsTypeCheck.class); final String[] expected = { "28:5: " + getCheckMessage(MSG_KEY), }; @@ -51,9 +48,6 @@ public void testDefault() @Test public void testAllowMarker() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceIsTypeCheck.class); - checkConfig.addProperty("allowMarkerInterfaces", "false"); final String[] expected = { "23:5: " + getCheckMessage(MSG_KEY), "28:5: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java index 2c9438c2c31..f1457c37f6a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java @@ -45,7 +45,6 @@ protected String getPackageLocation() { @Test public void testClassExtendsGenericClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MutableExceptionCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -56,7 +55,6 @@ public void testClassExtendsGenericClass() throws Exception { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MutableExceptionCheck.class); final String[] expected = { "14:9: " + getCheckMessage(MSG_KEY, "errorCode"), @@ -90,9 +88,6 @@ public void testMultipleInputs() throws Exception { @Test public void testFormat() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MutableExceptionCheck.class); - checkConfig.addProperty("format", "^.*Failure$"); - checkConfig.addProperty("extendedClassNameFormat", "^.*ThreadDeath$"); final String[] expected = { "42:13: " + getCheckMessage(MSG_KEY, "errorCode"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckTest.java index b6fb319859f..32bb55f0cf7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckTest.java @@ -85,8 +85,6 @@ public void testAcceptableTokens() { @Test public void testFileWithOneTopLevelClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOneTopLevelClass.java"), expected); @@ -94,8 +92,6 @@ public void testFileWithOneTopLevelClass() throws Exception { @Test public void testFileWithOneTopLevelInterface() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOneTopLevelClassInterface.java"), expected); @@ -103,8 +99,6 @@ public void testFileWithOneTopLevelInterface() throws Exception { @Test public void testFileWithOneTopLevelEnum() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOneTopLevelClassEnum.java"), expected); @@ -112,8 +106,6 @@ public void testFileWithOneTopLevelEnum() throws Exception { @Test public void testFileWithOneTopLevelAnnotation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOneTopLevelClassAnnotation.java"), expected); @@ -121,8 +113,6 @@ public void testFileWithOneTopLevelAnnotation() throws Exception { @Test public void testFileWithNoPublicTopLevelClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassNoPublic2"), }; @@ -132,8 +122,6 @@ public void testFileWithNoPublicTopLevelClass() throws Exception { @Test public void testFileWithThreeTopLevelInterface() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassInterface3inner1"), "17:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassInterface3inner2"), @@ -144,8 +132,6 @@ public void testFileWithThreeTopLevelInterface() throws Exception { @Test public void testFileWithThreeTopLevelEnum() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassEnum2inner1"), "17:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassEnum2inner2"), @@ -156,8 +142,6 @@ public void testFileWithThreeTopLevelEnum() throws Exception { @Test public void testFileWithThreeTopLevelAnnotation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = { "15:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassAnnotation2A"), "20:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassAnnotation2B"), @@ -168,8 +152,6 @@ public void testFileWithThreeTopLevelAnnotation() throws Exception { @Test public void testFileWithFewTopLevelClasses() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = { "31:1: " + getCheckMessage(MSG_KEY, "NoSuperClone"), "35:1: " + getCheckMessage(MSG_KEY, "InnerClone"), @@ -185,8 +167,6 @@ public void testFileWithFewTopLevelClasses() throws Exception { @Test public void testFileWithSecondEnumTopLevelClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = { "16:1: " + getCheckMessage(MSG_KEY, "InputDeclarationOrderEnum2"), "26:1: " + getCheckMessage(MSG_KEY, "InputDeclarationOrderAnnotation2"), @@ -197,7 +177,6 @@ public void testFileWithSecondEnumTopLevelClass() throws Exception { @Test public void testPackageInfoWithNoTypesDeclared() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("package-info.java"), expected); @@ -205,8 +184,6 @@ public void testPackageInfoWithNoTypesDeclared() throws Exception { @Test public void testFileWithMultipleSameLine() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = { "9:47: " + getCheckMessage(MSG_KEY, "ViolatingSecondType"), }; @@ -216,8 +193,6 @@ public void testFileWithMultipleSameLine() throws Exception { @Test public void testFileWithIndentation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = { "13:2: " + getCheckMessage(MSG_KEY, "ViolatingIndentedClass1"), "17:5: " + getCheckMessage(MSG_KEY, "ViolatingIndentedClass2"), @@ -229,8 +204,6 @@ public void testFileWithIndentation() throws Exception { @Test public void testOneTopLevelClassRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = { "13:1: " + getCheckMessage(MSG_KEY, "TestRecord1"), "17:1: " + getCheckMessage(MSG_KEY, "TestRecord2"), @@ -241,8 +214,6 @@ public void testOneTopLevelClassRecords() throws Exception { @Test public void testOneTopLevelClassEmpty() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OneTopLevelClassCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputOneTopLevelClassEmpty.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckTest.java index 9522c4ae6f3..92446b70af7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.TokenTypes; @@ -41,7 +40,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ThrowsCountCheck.class); final String[] expected = { "25:20: " + getCheckMessage(MSG_KEY, 5, 4), @@ -56,8 +54,6 @@ public void testDefault() throws Exception { @Test public void testMax() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ThrowsCountCheck.class); - checkConfig.addProperty("max", "5"); final String[] expected = { "35:20: " + getCheckMessage(MSG_KEY, 6, 5), @@ -98,8 +94,6 @@ public void testWrongTokenType() { @Test public void testNotIgnorePrivateMethod() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ThrowsCountCheck.class); - checkConfig.addProperty("ignorePrivateMethods", "false"); final String[] expected = { "25:20: " + getCheckMessage(MSG_KEY, 5, 4), "30:20: " + getCheckMessage(MSG_KEY, 5, 4), @@ -113,7 +107,6 @@ public void testNotIgnorePrivateMethod() throws Exception { @Test public void testMethodWithAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ThrowsCountCheck.class); final String[] expected = { "26:26: " + getCheckMessage(MSG_KEY, 5, 4), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckTest.java index fb1578b8625..14f21347e9a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckTest.java @@ -33,7 +33,6 @@ import org.powermock.reflect.Whitebox; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.JavaParser; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -62,9 +61,6 @@ public void testGetRequiredTokens() { @Test public void testInner() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("publicMemberPattern", "^f[A-Z][a-zA-Z0-9]*$"); final String[] expected = { "47:24: " + getCheckMessage(MSG_KEY, "rData"), "50:27: " + getCheckMessage(MSG_KEY, "protectedVariable"), @@ -81,11 +77,6 @@ public void testInner() @Test public void testIgnoreAccess() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("publicMemberPattern", "^r[A-Z]"); - checkConfig.addProperty("protectedAllowed", "true"); - checkConfig.addProperty("packageAllowed", "true"); final String[] expected = { "34:20: " + getCheckMessage(MSG_KEY, "fData"), "94:20: " + getCheckMessage(MSG_KEY, "someValue"), @@ -96,9 +87,6 @@ public void testIgnoreAccess() @Test public void testSimple() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("publicMemberPattern", "^f[A-Z][a-zA-Z0-9]*$"); final String[] expected = { "49:19: " + getCheckMessage(MSG_KEY, "mNumCreated2"), "59:23: " + getCheckMessage(MSG_KEY, "sTest1"), @@ -113,9 +101,6 @@ public void testSimple() throws Exception { @Test public void testStrictJavadoc() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("publicMemberPattern", "^f[A-Z][a-zA-Z0-9]*$"); final String[] expected = { "49:9: " + getCheckMessage(MSG_KEY, "mLen"), "50:19: " + getCheckMessage(MSG_KEY, "mDeer"), @@ -127,9 +112,6 @@ public void testStrictJavadoc() throws Exception { @Test public void testAllowPublicFinalFieldsInImmutableClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicImmutableFields", "true"); final String[] expected = { "33:39: " + getCheckMessage(MSG_KEY, "includes"), "34:39: " + getCheckMessage(MSG_KEY, "excludes"), @@ -146,13 +128,6 @@ public void testAllowPublicFinalFieldsInImmutableClass() throws Exception { @Test public void testAllowPublicFinalFieldsInImmutableClassWithNonCanonicalClasses() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicImmutableFields", "true"); - checkConfig.addProperty("immutableClassCanonicalNames", "String, Integer, Byte, " - + "Character, Short, Boolean, Long, Double, Float, StackTraceElement, BigInteger, " - + "BigDecimal, File, Locale, UUID, URL, URI, Inet4Address, Inet6Address, " - + "InetSocketAddress"); final String[] expected = { "28:39: " + getCheckMessage(MSG_KEY, "includes"), "29:39: " + getCheckMessage(MSG_KEY, "excludes"), @@ -172,8 +147,6 @@ public void testAllowPublicFinalFieldsInImmutableClassWithNonCanonicalClasses() @Test public void testDisAllowPublicFinalAndImmutableFieldsInImmutableClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); final String[] expected = { "32:22: " + getCheckMessage(MSG_KEY, "someIntValue"), "33:39: " + getCheckMessage(MSG_KEY, "includes"), @@ -197,9 +170,6 @@ public void testDisAllowPublicFinalAndImmutableFieldsInImmutableClass() throws E @Test public void testAllowPublicFinalFieldsInNonFinalClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicFinalFields", "true"); final String[] expected = { "55:20: " + getCheckMessage(MSG_KEY, "value"), "57:24: " + getCheckMessage(MSG_KEY, "bValue"), @@ -211,11 +181,6 @@ public void testAllowPublicFinalFieldsInNonFinalClass() throws Exception { @Test public void testUserSpecifiedImmutableClassesList() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicImmutableFields", "true"); - checkConfig.addProperty("immutableClassCanonicalNames", "java.util.List, " - + "com.google.common.collect.ImmutableSet, java.lang.String"); final String[] expected = { "30:29: " + getCheckMessage(MSG_KEY, "money"), "47:35: " + getCheckMessage(MSG_KEY, "uri"), @@ -232,14 +197,6 @@ public void testUserSpecifiedImmutableClassesList() throws Exception { @Test public void testImmutableSpecifiedSameTypeName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicImmutableFields", "true"); - checkConfig.addProperty("immutableClassCanonicalNames", - "com.puppycrawl.tools.checkstyle.checks.design." - + "visibilitymodifier.InputVisibilityModifierGregorianCalendar, " - + "com.puppycrawl.tools.checkstyle.checks.design." - + "visibilitymodifier.inputs.InetSocketAddress"); final String[] expected = { "23:46: " + getCheckMessage(MSG_KEY, "calendar"), "28:45: " + getCheckMessage(MSG_KEY, "adr"), @@ -251,9 +208,6 @@ public void testImmutableSpecifiedSameTypeName() throws Exception { @Test public void testImmutableValueSameTypeName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicImmutableFields", "true"); final String[] expected = { "28:46: " + getCheckMessage(MSG_KEY, "calendar"), "29:59: " + getCheckMessage(MSG_KEY, "calendar2"), @@ -267,10 +221,6 @@ public void testImmutableValueSameTypeName() throws Exception { @Test public void testImmutableStarImportFalseNegative() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicImmutableFields", "true"); - checkConfig.addProperty("immutableClassCanonicalNames", "java.util.Arrays"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputVisibilityModifierImmutableStarImport.java"), expected); @@ -278,11 +228,6 @@ public void testImmutableStarImportFalseNegative() throws Exception { @Test public void testImmutableStarImportNoWarn() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicImmutableFields", "true"); - checkConfig.addProperty("immutableClassCanonicalNames", - "java.lang.String, com.google.common.collect.ImmutableSet"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputVisibilityModifierImmutableStarImport2.java"), @@ -291,8 +236,6 @@ public void testImmutableStarImportNoWarn() throws Exception { @Test public void testDefaultAnnotationPatterns() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); final String[] expected = { "61:19: " + getCheckMessage(MSG_KEY, "customAnnotatedPublic"), "64:12: " + getCheckMessage(MSG_KEY, "customAnnotatedPackage"), @@ -307,11 +250,6 @@ public void testDefaultAnnotationPatterns() throws Exception { @Test public void testCustomAnnotationPatterns() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("ignoreAnnotationCanonicalNames", - "com.puppycrawl.tools.checkstyle.checks.design." - + "InputVisibilityModifierAnnotated.CustomAnnotation"); final String[] expected = { "37:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"), "40:28: " + getCheckMessage(MSG_KEY, "fqPublicJUnitRule"), @@ -333,9 +271,6 @@ public void testCustomAnnotationPatterns() throws Exception { @Test public void testIgnoreAnnotationNoPattern() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("ignoreAnnotationCanonicalNames", ""); final String[] expected = { "36:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"), "39:28: " + getCheckMessage(MSG_KEY, "fqPublicJUnitRule"), @@ -360,8 +295,6 @@ public void testIgnoreAnnotationNoPattern() throws Exception { @Test public void testIgnoreAnnotationSameName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); final String[] expected = { "32:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"), "35:28: " + getCheckMessage(MSG_KEY, "publicJUnitClassRule"), @@ -384,8 +317,6 @@ public void testGetAcceptableTokens() { @Test public void testPublicImmutableFieldsNotAllowed() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); final String[] expected = { "31:22: " + getCheckMessage(MSG_KEY, "someIntValue"), "32:39: " + getCheckMessage(MSG_KEY, "includes"), @@ -399,8 +330,6 @@ public void testPublicImmutableFieldsNotAllowed() throws Exception { @Test public void testPublicFinalFieldsNotAllowed() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); final String[] expected = { "31:22: " + getCheckMessage(MSG_KEY, "someIntValue"), "32:39: " + getCheckMessage(MSG_KEY, "includes"), @@ -414,11 +343,6 @@ public void testPublicFinalFieldsNotAllowed() throws Exception { @Test public void testPublicFinalFieldsAllowed() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicFinalFields", "true"); - checkConfig.addProperty("immutableClassCanonicalNames", - "com.google.common.collect.ImmutableSet"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputVisibilityModifiersPublicImmutable3.java"), expected); @@ -426,9 +350,6 @@ public void testPublicFinalFieldsAllowed() throws Exception { @Test public void testPublicFinalFieldInEnum() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicImmutableFields", "true"); final String[] expected = { "35:23: " + getCheckMessage(MSG_KEY, "hole"), }; @@ -453,9 +374,6 @@ public void testWrongTokenType() { @Test public void testNullModifiers() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicImmutableFields", "true"); final String[] expected = { "32:50: " + getCheckMessage(MSG_KEY, "i"), }; @@ -465,14 +383,6 @@ public void testNullModifiers() throws Exception { @Test public void testVisibilityModifiersOfGenericFields() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("allowPublicImmutableFields", "true"); - checkConfig.addProperty("immutableClassCanonicalNames", - "com.google.common.collect.ImmutableMap, " - + "java.lang.String, " - + "java.util.Optional, " - + "java.math.BigDecimal"); final String[] expected = { "31:56: " + getCheckMessage(MSG_KEY, "perfSeries"), "32:66: " + getCheckMessage(MSG_KEY, "peopleMap"), @@ -522,10 +432,6 @@ public void testIsStarImportNullAst() throws Exception { @Test public void testPackageClassName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(VisibilityModifierCheck.class); - checkConfig.addProperty("immutableClassCanonicalNames", "PackageClass"); - checkConfig.addProperty("allowPublicImmutableFields", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputVisibilityModifierPackageClassName.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStarImportCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStarImportCheckTest.java index 0c0568e9235..7101841068e 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStarImportCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStarImportCheckTest.java @@ -25,7 +25,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 AvoidStarImportCheckTest @@ -39,8 +38,6 @@ protected String getPackageLocation() { @Test public void testDefaultOperation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidStarImportCheck.class); final String[] expected = { "12:54: " + getCheckMessage(MSG_KEY, "com.puppycrawl." + "tools.checkstyle.checks.imports.*"), @@ -59,10 +56,6 @@ public void testDefaultOperation() @Test public void testExcludes() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidStarImportCheck.class); - checkConfig.addProperty("excludes", - "java.io, java.lang, javax.swing.WindowConstants.*"); // allow the java.io/java.lang,javax.swing.WindowConstants star imports final String[] expected2 = { "12:54: " + getCheckMessage(MSG_KEY, "com.puppycrawl." @@ -76,8 +69,6 @@ public void testExcludes() @Test public void testAllowClassImports() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AvoidStarImportCheck.class); - checkConfig.addProperty("allowClassImports", "true"); // allow all class star imports final String[] expected2 = { "30:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), @@ -89,8 +80,6 @@ public void testAllowClassImports() throws Exception { @Test public void testAllowStaticMemberImports() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AvoidStarImportCheck.class); - checkConfig.addProperty("allowStaticMemberImports", "true"); // allow all static star imports final String[] expected2 = { "12:54: " + getCheckMessage(MSG_KEY, "com.puppycrawl." diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckTest.java index 10cfe5f043d..34cfed7c75d 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckTest.java @@ -25,7 +25,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 AvoidStaticImportCheckTest @@ -47,8 +46,6 @@ public void testGetRequiredTokens() { @Test public void testDefaultOperation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidStaticImportCheck.class); final String[] expected = { "26:27: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), "28:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), @@ -71,9 +68,6 @@ public void testDefaultOperation() @Test public void testStarExcludes() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidStaticImportCheck.class); - checkConfig.addProperty("excludes", "java.io.File.*, sun.net.ftpclient.FtpClient.*"); // allow the "java.io.File.*" AND "sun.net.ftpclient.FtpClient.*" star imports final String[] expected = { "28:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), @@ -93,9 +87,6 @@ public void testStarExcludes() @Test public void testMemberExcludes() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidStaticImportCheck.class); - checkConfig.addProperty("excludes", "java.io.File.listRoots, java.lang.Math.E"); // allow the java.io.File.listRoots and java.lang.Math.E member imports final String[] expected = { "28:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), @@ -116,15 +107,7 @@ public void testMemberExcludes() @Test public void testBogusMemberExcludes() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidStaticImportCheck.class); - // should NOT mask anything - checkConfig.addProperty( - "excludes", - "java.io.File.listRoots.listRoots, javax.swing.WindowConstants, javax.swing.*," - + " sun.net.ftpclient.FtpClient.*FtpClient, sun.net.ftpclient.FtpClientjunk," - + " java.io.File.listRootsmorejunk"); final String[] expected = { "28:27: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), "30:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), @@ -146,15 +129,8 @@ public void testBogusMemberExcludes() @Test public void testInnerClassMemberExcludesStar() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AvoidStaticImportCheck.class); - // should mask com.puppycrawl.tools.checkstyle.imports.avoidstaticimport. // InputAvoidStaticImportNestedClass.InnerClass.one - checkConfig.addProperty( - "excludes", - "com.puppycrawl.tools.checkstyle.checks.imports." - + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass.*"); final String[] expected = { "27:27: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), "29:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java index dace2140c07..2de87b0d33a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java @@ -70,13 +70,6 @@ public void testGetRequiredTokens() { @Test public void testCustom() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("standardPackageRegExp", "^(java|javax)\\."); - checkConfig.addProperty("thirdPartyPackageRegExp", "com|org"); - checkConfig.addProperty("customImportOrderRules", - "STATIC###SAME_PACKAGE(3)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), @@ -105,12 +98,6 @@ public void testCustom() throws Exception { */ @Test public void testStaticStandardThird() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("thirdPartyPackageRegExp", "com.|org."); - checkConfig.addProperty("customImportOrderRules", - "STATIC###STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), @@ -135,12 +122,6 @@ public void testStaticStandardThird() throws Exception { */ @Test public void testNonSpecifiedImports() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("thirdPartyPackageRegExp", "org."); - checkConfig.addProperty("customImportOrderRules", - "STATIC###STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE###SAME_PACKAGE(3)"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), @@ -162,9 +143,6 @@ public void testNonSpecifiedImports() throws Exception { @Test public void testOrderRuleEmpty() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", ""); final String[] expected = { "17:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.List"), }; @@ -175,12 +153,6 @@ public void testOrderRuleEmpty() throws Exception { @Test public void testOrderRuleWithOneGroup() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("thirdPartyPackageRegExp", "org."); - checkConfig.addProperty("customImportOrderRules", - "STANDARD_JAVA_PACKAGE"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), @@ -206,12 +178,6 @@ public void testOrderRuleWithOneGroup() throws Exception { @Test public void testStaticSamePackage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("thirdPartyPackageRegExp", "org."); - checkConfig.addProperty("customImportOrderRules", - "STATIC###SAME_PACKAGE(3)"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); final String[] expected = { "17:1: " + getCheckMessage(MSG_LEX, "java.util.*", "java.util.StringTokenizer"), "18:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.*"), @@ -234,13 +200,6 @@ public void testStaticSamePackage() throws Exception { @Test public void testWithoutLineSeparator() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("thirdPartyPackageRegExp", "org."); - checkConfig.addProperty("separateLineBetweenGroups", "false"); - checkConfig.addProperty("customImportOrderRules", - "STATIC###SAME_PACKAGE(3)"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); final String[] expected = { "17:1: " + getCheckMessage(MSG_LEX, "java.util.*", "java.util.StringTokenizer"), "18:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.*"), @@ -263,12 +222,6 @@ public void testWithoutLineSeparator() throws Exception { @Test public void testWithoutLineSeparator2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("separateLineBetweenGroups", "false"); - checkConfig.addProperty("customImportOrderRules", - "STATIC###STANDARD_JAVA_PACKAGE"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.io.File.createTempFile", "javax.swing.WindowConstants.*"), @@ -282,13 +235,6 @@ public void testWithoutLineSeparator2() throws Exception { @Test public void testNoValid() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("thirdPartyPackageRegExp", ".*"); - checkConfig.addProperty("specialImportsRegExp", "com.google"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); - checkConfig.addProperty("customImportOrderRules", - "STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -297,13 +243,6 @@ public void testNoValid() throws Exception { @Test public void testPossibleIndexOutOfBoundsException() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("thirdPartyPackageRegExp", ".*"); - checkConfig.addProperty("specialImportsRegExp", "com.google"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); - checkConfig.addProperty("customImportOrderRules", - "STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"); final String[] expected = { "17:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, THIRD, "org.w3c.dom.Node"), }; @@ -314,12 +253,6 @@ public void testPossibleIndexOutOfBoundsException() throws Exception { @Test public void testDefaultPackage2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("thirdPartyPackageRegExp", "com|org"); - checkConfig.addProperty("customImportOrderRules", - "STATIC###SAME_PACKAGE(3)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); final String[] expected = { "19:1: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", @@ -345,12 +278,6 @@ public void testDefaultPackage2() throws Exception { @Test public void testWithoutThirdPartyPackage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); - checkConfig.addProperty("separateLineBetweenGroups", "true"); - checkConfig.addProperty("customImportOrderRules", - "SAME_PACKAGE(3)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###STATIC"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -359,11 +286,6 @@ public void testWithoutThirdPartyPackage() throws Exception { @Test public void testThirdPartyAndSpecialImports() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("specialImportsRegExp", "antlr.*"); - checkConfig.addProperty("customImportOrderRules", - "SAME_PACKAGE(3)###THIRD_PARTY_PACKAGE###STATIC###SPECIAL_IMPORTS"); final String[] expected = { "23:1: " + getCheckMessage(MSG_ORDER, THIRD, SPECIAL, "com.google.common.collect.HashMultimap"), @@ -375,12 +297,6 @@ public void testThirdPartyAndSpecialImports() throws Exception { @Test public void testCompareImports() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("specialImportsRegExp", "com"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); - checkConfig.addProperty("customImportOrderRules", - "STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS"); final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.util.Map", "java.util.Map.Entry"), @@ -392,14 +308,6 @@ public void testCompareImports() throws Exception { @Test public void testFindBetterPatternMatch() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("standardPackageRegExp", "java|javax|event.*"); - checkConfig.addProperty("specialImportsRegExp", "An|lang|java|collect|event"); - checkConfig.addProperty("thirdPartyPackageRegExp", "com"); - checkConfig.addProperty("separateLineBetweenGroups", "true"); - checkConfig.addProperty("customImportOrderRules", - "STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE"); final String[] expected = { "20:1: " + getCheckMessage(MSG_ORDER, THIRD, SPECIAL, "com.google.common.annotations.Beta"), @@ -430,9 +338,6 @@ public void testBeginTreeClear() throws Exception { @Test public void testImportsContainingJava() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE"); final String[] expected = { "17:1: " + getCheckMessage(MSG_LINE_SEPARATOR, "com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck"), @@ -472,12 +377,6 @@ public void testGetFullImportIdent() throws Exception { @Test public void testSamePackageDepth2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "false"); - checkConfig.addProperty("separateLineBetweenGroups", "false"); - checkConfig.addProperty("customImportOrderRules", - "SAME_PACKAGE(2)"); final String[] expected = { "20:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.*"), "21:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.List"), @@ -498,12 +397,6 @@ public void testSamePackageDepth2() throws Exception { @Test public void testSamePackageDepth3() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "false"); - checkConfig.addProperty("separateLineBetweenGroups", "false"); - checkConfig.addProperty("customImportOrderRules", - "SAME_PACKAGE(3)"); final String[] expected = { "23:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.*"), "24:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, @@ -519,12 +412,6 @@ public void testSamePackageDepth3() throws Exception { @Test public void testSamePackageDepth4() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "false"); - checkConfig.addProperty("separateLineBetweenGroups", "false"); - checkConfig.addProperty("customImportOrderRules", - "SAME_PACKAGE(4)"); final String[] expected = { "25:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.locks.LockSupport"), @@ -537,12 +424,6 @@ public void testSamePackageDepth4() throws Exception { @Test public void testSamePackageDepthLongerThenActualPackage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "false"); - checkConfig.addProperty("separateLineBetweenGroups", "false"); - checkConfig.addProperty("customImportOrderRules", - "SAME_PACKAGE(5)"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -552,12 +433,6 @@ public void testSamePackageDepthLongerThenActualPackage() throws Exception { @Test public void testSamePackageDepthNegative() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "false"); - checkConfig.addProperty("separateLineBetweenGroups", "false"); - checkConfig.addProperty("customImportOrderRules", - "SAME_PACKAGE(-1)"); try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -581,13 +456,6 @@ public void testSamePackageDepthNegative() throws Exception { @Test public void testSamePackageDepthZero() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "false"); - checkConfig.addProperty("separateLineBetweenGroups", "false"); - checkConfig.addProperty("customImportOrderRules", - "SAME_PACKAGE(0)"); - try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -610,12 +478,6 @@ public void testSamePackageDepthZero() throws Exception { @Test public void testUnsupportedRule() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - // #AAA##BBBB###CCCC####DDDD - checkConfig.addProperty("customImportOrderRules", "SAME_PACKAGE(3)###UNSUPPORTED_RULE"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); - try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -638,11 +500,6 @@ public void testUnsupportedRule() throws Exception { @Test public void testSamePackageDepthNotInt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", "SAME_PACKAGE(INT_IS_REQUIRED_HERE)"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); - try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -665,9 +522,6 @@ public void testSamePackageDepthNotInt() throws Exception { @Test public void testNoImports() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", "SAME_PACKAGE(3)"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -676,10 +530,6 @@ public void testNoImports() throws Exception { @Test public void testDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - - createChecker(checkConfig); final String[] expected = { "20:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.awt.Button"), "32:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "com.puppycrawl.tools.checkstyle.*"), @@ -691,14 +541,6 @@ public void testDefaultConfiguration() throws Exception { @Test public void testRulesWithOverlappingPatterns() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "THIRD_PARTY_PACKAGE###SAME_PACKAGE(6)###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS"); - checkConfig.addProperty("standardPackageRegExp", "com.puppycrawl.tools.*Check$"); - checkConfig.addProperty("specialImportsRegExp", "com.puppycrawl.tools.*Tag*"); - checkConfig.addProperty("thirdPartyPackageRegExp", - "com.puppycrawl.tools.checkstyle.checks.javadoc.*Javadoc*"); final String[] expected = { "23:1: " + getCheckMessage(MSG_ORDER, THIRD, STD, "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocNodeImpl"), @@ -716,21 +558,12 @@ public void testRulesWithOverlappingPatterns() throws Exception { "com.puppycrawl.tools.checkstyle.checks.javadoc.NonEmptyAtclauseDescriptionCheck"), }; - createChecker(checkConfig); verifyWithInlineConfigParser( getPath("InputCustomImportOrder_OverlappingPatterns.java"), expected); } @Test public void testMultiplePatternMatchesSecondPatternIsLonger() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE"); - checkConfig.addProperty("specialImportsRegExp", "org"); - checkConfig.addProperty("standardPackageRegExp", "junit"); - - createChecker(checkConfig); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputCustomImportOrder_MultiplePatternMatches.java"), @@ -739,14 +572,6 @@ public void testMultiplePatternMatchesSecondPatternIsLonger() throws Exception { @Test public void testMultiplePatternMatchesFirstPatternHasLaterPosition() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE"); - checkConfig.addProperty("specialImportsRegExp", "Test"); - checkConfig.addProperty("standardPackageRegExp", "unit"); - - createChecker(checkConfig); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputCustomImportOrder_MultiplePatternMatches2.java"), @@ -755,14 +580,6 @@ public void testMultiplePatternMatchesFirstPatternHasLaterPosition() throws Exce @Test public void testMultiplePatternMatchesFirstPatternHasEarlierPosition() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE"); - checkConfig.addProperty("specialImportsRegExp", "unit"); - checkConfig.addProperty("standardPackageRegExp", "Test"); - - createChecker(checkConfig); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputCustomImportOrder_MultiplePatternMatches3.java"), @@ -771,14 +588,6 @@ public void testMultiplePatternMatchesFirstPatternHasEarlierPosition() throws Ex @Test public void testMultiplePatternMultipleImportFirstPatternHasLaterPosition() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE"); - checkConfig.addProperty("specialImportsRegExp", "Test"); - checkConfig.addProperty("standardPackageRegExp", "unit"); - - createChecker(checkConfig); final String[] expected = { "16:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, "org.junit.Test"), }; @@ -789,14 +598,6 @@ public void testMultiplePatternMultipleImportFirstPatternHasLaterPosition() thro @Test public void testNoPackage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "STATIC###THIRD_PARTY_PACKAGE"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); - checkConfig.addProperty("separateLineBetweenGroups", "true"); - - createChecker(checkConfig); final String[] expected = { "17:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.*"), "19:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.HashMap"), @@ -810,14 +611,6 @@ public void testNoPackage() throws Exception { @Test public void testNoPackage2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "STATIC###THIRD_PARTY_PACKAGE"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); - checkConfig.addProperty("separateLineBetweenGroups", "true"); - - createChecker(checkConfig); final String[] expected = { "18:1: " + getCheckMessage(MSG_LINE_SEPARATOR, "com.sun.accessibility.internal.resources.*"), @@ -832,15 +625,6 @@ public void testNoPackage2() throws Exception { @Test public void testNoPackage3() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "STATIC###STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS"); - checkConfig.addProperty("specialImportsRegExp", "^org\\..+"); - checkConfig.addProperty("thirdPartyPackageRegExp", "^com\\.google\\..+"); - checkConfig.addProperty("separateLineBetweenGroups", "true"); - - createChecker(checkConfig); final String[] expected = { "17:1: " + getCheckMessage(MSG_LINE_SEPARATOR, "java.util.Map"), @@ -856,16 +640,6 @@ public void testNoPackage3() throws Exception { @Test public void testInputCustomImportOrderSingleLine() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "STATIC###STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS" - + "###SAME_PACKAGE(3)"); - checkConfig.addProperty("specialImportsRegExp", "^org\\..+"); - checkConfig.addProperty("thirdPartyPackageRegExp", "^com\\.google\\..+"); - checkConfig.addProperty("separateLineBetweenGroups", "true"); - - createChecker(checkConfig); final String[] expected = { "14:112: " + getCheckMessage(MSG_LINE_SEPARATOR, "java.util.Map"), @@ -883,13 +657,6 @@ public void testInputCustomImportOrderSingleLine() throws Exception { @Test public void testInputCustomImportOrderSingleLine2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "STATIC###STANDARD_JAVA_PACKAGE"); - checkConfig.addProperty("separateLineBetweenGroups", "true"); - - createChecker(checkConfig); final String[] expected = { "14:118: " + getCheckMessage(MSG_LINE_SEPARATOR, "java.util.Map"), @@ -901,16 +668,6 @@ public void testInputCustomImportOrderSingleLine2() throws Exception { @Test public void testInputCustomImportOrderThirdPartyAndSpecial2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "STATIC###STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS" - + "###SAME_PACKAGE(6)"); - checkConfig.addProperty("thirdPartyPackageRegExp", "^com\\..+"); - checkConfig.addProperty("specialImportsRegExp", "^org\\..+"); - checkConfig.addProperty("separateLineBetweenGroups", "true"); - - createChecker(checkConfig); final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "javax.swing.WindowConstants.*"), @@ -935,14 +692,6 @@ public void testInputCustomImportOrderThirdPartyAndSpecial2() throws Exception { @Test public void testInputCustomImportOrderMultipleViolationsSameLine() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "STATIC###THIRD_PARTY_PACKAGE"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); - checkConfig.addProperty("separateLineBetweenGroups", "true"); - - createChecker(checkConfig); final String[] expected = { "17:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STATIC, "java.util.Collections.*"), @@ -960,15 +709,6 @@ public void testInputCustomImportOrderMultipleViolationsSameLine() throws Except @Test public void testInputCustomImportOrderSpanMultipleLines() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###SAME_PACKAGE(3)"); - - checkConfig.addProperty("specialImportsRegExp", "^org\\..+"); - checkConfig.addProperty("separateLineBetweenGroups", "true"); - - createChecker(checkConfig); final String[] expected = { "30:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.BitSet"), "45:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.HashSet"), @@ -983,19 +723,6 @@ public void testInputCustomImportOrderSpanMultipleLines() throws Exception { @Test public void testInputCustomImportOrderEclipseDefaultPositive() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CustomImportOrderCheck.class); - checkConfig.addProperty("customImportOrderRules", - "STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE" - + "###SAME_PACKAGE(2)###STATIC"); - - checkConfig.addProperty("standardPackageRegExp", "^java\\."); - checkConfig.addProperty("specialImportsRegExp", "^javax\\."); - checkConfig.addProperty("thirdPartyPackageRegExp", "^org\\."); - checkConfig.addProperty("separateLineBetweenGroups", "true"); - checkConfig.addProperty("sortImportsInGroupAlphabetically", "true"); - - createChecker(checkConfig); final String[] expected = { "22:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, "java.awt.Button"), "23:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, "java.awt.Dialog"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/IllegalImportCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/IllegalImportCheckTest.java index 1fbe03da280..d9a33daee75 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/IllegalImportCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/IllegalImportCheckTest.java @@ -25,7 +25,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 IllegalImportCheckTest extends AbstractModuleTestSupport { @@ -46,9 +45,6 @@ public void testGetRequiredTokens() { @Test public void testWithSupplied() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalImportCheck.class); - checkConfig.addProperty("illegalPkgs", "java.io"); final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY, "java.io.*"), "28:1: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), @@ -61,8 +57,6 @@ public void testWithSupplied() @Test public void testWithDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalImportCheck.class); final String[] expected = {}; verifyWithInlineConfigParser( getPath("InputIllegalImportDefault2.java"), expected); @@ -71,10 +65,6 @@ public void testWithDefault() @Test public void testCustomSunPackageWithRegexp() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalImportCheck.class); - checkConfig.addProperty("regexp", "true"); - checkConfig.addProperty("illegalPkgs", "sun.reflect"); final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY, "sun.reflect.*"), }; @@ -95,10 +85,6 @@ public void testGetAcceptableTokens() { @Test public void testIllegalClasses() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalImportCheck.class); - checkConfig.addProperty("illegalClasses", "java.sql.Connection"); - checkConfig.addProperty("illegalPkgs", "org.junit.jupiter.api"); final String[] expected = { "16:1: " + getCheckMessage(MSG_KEY, "java.sql.Connection"), "20:1: " + getCheckMessage(MSG_KEY, "org.junit.jupiter.api.*"), @@ -111,10 +97,6 @@ public void testIllegalClasses() @Test public void testIllegalClassesStarImport() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalImportCheck.class); - checkConfig.addProperty("illegalClasses", "java.io.*"); - checkConfig.addProperty("illegalPkgs", "org.junit.jupiter.api"); final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY, "java.io.*"), "20:1: " + getCheckMessage(MSG_KEY, "org.junit.jupiter.api.*"), @@ -127,10 +109,6 @@ public void testIllegalClassesStarImport() @Test public void testIllegalPackagesRegularExpression() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalImportCheck.class); - checkConfig.addProperty("illegalPkgs", "java\\.util"); - checkConfig.addProperty("regexp", "true"); final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY, "java.util.List"), "18:1: " + getCheckMessage(MSG_KEY, "java.util.List"), @@ -147,11 +125,6 @@ public void testIllegalPackagesRegularExpression() @Test public void testIllegalClassesRegularExpression() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalImportCheck.class); - checkConfig.addProperty("illegalPkgs", ""); - checkConfig.addProperty("illegalClasses", "^java\\.util\\.(List|Arrays)"); - checkConfig.addProperty("regexp", "true"); final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY, "java.util.List"), "18:1: " + getCheckMessage(MSG_KEY, "java.util.List"), @@ -164,12 +137,6 @@ public void testIllegalClassesRegularExpression() @Test public void testIllegalPackagesAndClassesRegularExpression() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalImportCheck.class); - checkConfig.addProperty("illegalPkgs", "java\\.util"); - checkConfig.addProperty("illegalClasses", - "^java\\.awt\\..*"); - checkConfig.addProperty("regexp", "true"); final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY, "java.util.List"), "18:1: " + getCheckMessage(MSG_KEY, "java.util.List"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java index 7af558e915b..b1a8fcd1100 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java @@ -64,8 +64,6 @@ public void testGetRequiredTokens() { @Test public void testOne() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlOne.xml")); final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser( @@ -74,8 +72,6 @@ public void testOne() throws Exception { @Test public void testTwo() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlTwo.xml")); final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), "12:1: " + getCheckMessage(MSG_DISALLOWED, "javax.swing.border.*"), @@ -88,8 +84,6 @@ public void testTwo() throws Exception { @Test public void testWrong() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlWrong.xml")); final String[] expected = {"9:1: " + getCheckMessage(MSG_UNKNOWN_PKG)}; verifyWithInlineConfigParser( getPath("InputImportControl3.java"), expected); @@ -97,7 +91,6 @@ public void testWrong() throws Exception { @Test public void testMissing() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); final String[] expected = {"9:1: " + getCheckMessage(MSG_MISSING_FILE)}; verifyWithInlineConfigParser( getPath("InputImportControl4.java"), expected); @@ -105,8 +98,6 @@ public void testMissing() throws Exception { @Test public void testEmpty() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", " "); final String[] expected = {"9:1: " + getCheckMessage(MSG_MISSING_FILE)}; verifyWithInlineConfigParser( getPath("InputImportControl5.java"), expected); @@ -114,8 +105,6 @@ public void testEmpty() throws Exception { @Test public void testNull() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", null); final String[] expected = {"9:1: " + getCheckMessage(MSG_MISSING_FILE)}; verifyWithInlineConfigParser( getPath("InputImportControl6.java"), expected); @@ -123,8 +112,6 @@ public void testNull() throws Exception { @Test public void testUnknown() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", "unknown-file"); try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -160,8 +147,6 @@ public void testBroken() throws Exception { @Test public void testOneRegExp() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlOneRegExp.xml")); final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser( @@ -170,8 +155,6 @@ public void testOneRegExp() throws Exception { @Test public void testTwoRegExp() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlTwoRegExp.xml")); final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), "12:1: " + getCheckMessage(MSG_DISALLOWED, "javax.swing.border.*"), @@ -184,8 +167,6 @@ public void testTwoRegExp() throws Exception { @Test public void testNotRegExpNoMatch() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlNotRegExpNoMatch.xml")); verifyWithInlineConfigParser( getPath("InputImportControl11.java"), CommonUtil.EMPTY_STRING_ARRAY); @@ -193,8 +174,6 @@ public void testNotRegExpNoMatch() throws Exception { @Test public void testBlacklist() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlBlacklist.xml")); final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.util.stream.Stream"), "12:1: " + getCheckMessage(MSG_DISALLOWED, "java.util.Date"), @@ -208,8 +187,6 @@ public void testBlacklist() throws Exception { @Test public void testStrategyOnMismatchOne() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlStrategyOnMismatchOne.xml")); final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), "12:1: " + getCheckMessage(MSG_DISALLOWED, "javax.swing.border.*"), @@ -222,8 +199,6 @@ public void testStrategyOnMismatchOne() throws Exception { @Test public void testStrategyOnMismatchTwo() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlStrategyOnMismatchTwo.xml")); final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), "14:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Button.ABORT"), @@ -235,8 +210,6 @@ public void testStrategyOnMismatchTwo() throws Exception { @Test public void testStrategyOnMismatchThree() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlStrategyOnMismatchThree.xml")); final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), }; @@ -247,8 +220,6 @@ public void testStrategyOnMismatchThree() throws Exception { @Test public void testStrategyOnMismatchFour() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlStrategyOnMismatchFour.xml")); final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), "12:1: " + getCheckMessage(MSG_DISALLOWED, "javax.swing.border.*"), @@ -260,8 +231,6 @@ public void testStrategyOnMismatchFour() throws Exception { @Test public void testPkgRegExpInParent() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlPkgRegExpInParent.xml")); final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser( @@ -270,8 +239,6 @@ public void testPkgRegExpInParent() throws Exception { @Test public void testPkgRegExpInChild() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlPkgRegExpInChild.xml")); final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser( @@ -280,8 +247,6 @@ public void testPkgRegExpInChild() throws Exception { @Test public void testPkgRegExpInBoth() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getPath("InputImportControlPkgRegExpInBoth.xml")); final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser( @@ -304,8 +269,6 @@ public void testGetAcceptableTokens() { @Test public void testResource() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getResourcePath("InputImportControlOne.xml")); final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser( @@ -333,8 +296,6 @@ public void testResourceUnableToLoad() throws Exception { @Test public void testUrlInFileProperty() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getUriString("InputImportControlOne.xml")); final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser( @@ -343,8 +304,6 @@ public void testUrlInFileProperty() throws Exception { @Test public void testUrlInFilePropertyUnableToLoad() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", "https://UnableToLoadThisURL"); try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -388,9 +347,6 @@ public void testCacheWhenFileExternalResourceContentDoesNotChange() throws Excep @Test public void testPathRegexMatches() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getResourcePath("InputImportControlOne.xml")); - checkConfig.addProperty("path", "^.*[\\\\/]src[\\\\/]test[\\\\/].*$"); final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser( @@ -399,9 +355,6 @@ public void testPathRegexMatches() throws Exception { @Test public void testPathRegexMatchesPartially() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getResourcePath("InputImportControlOne.xml")); - checkConfig.addProperty("path", "[\\\\/]InputImportControl22\\.java"); final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser( @@ -410,9 +363,6 @@ public void testPathRegexMatchesPartially() throws Exception { @Test public void testPathRegexDoesntMatch() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getResourcePath("InputImportControlOne.xml")); - checkConfig.addProperty("path", "^.*[\\\\/]src[\\\\/]main[\\\\/].*$"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -421,9 +371,6 @@ public void testPathRegexDoesntMatch() throws Exception { @Test public void testPathRegexDoesntMatchPartially() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getResourcePath("InputImportControlOne.xml")); - checkConfig.addProperty("path", "[\\\\/]NoMatch\\.java"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -432,9 +379,6 @@ public void testPathRegexDoesntMatchPartially() throws Exception { @Test public void testDisallowClassOfAllowPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", - getPath("InputImportControlDisallowClassOfAllowPackage.xml")); final String[] expected = { "12:1: " + getCheckMessage(MSG_DISALLOWED, "java.util.Date"), }; @@ -446,8 +390,6 @@ public void testDisallowClassOfAllowPackage() throws Exception { @Test public void testFileName() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); - checkConfig.addProperty("file", getResourcePath("InputImportControlFileName.xml")); final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java index 673f32a0db6..645aacd47c2 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java @@ -57,8 +57,6 @@ public void testImportOrderOptionValueOf() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), "25:1: " + getCheckMessage(MSG_ORDERING, "javax.swing.JComponent"), @@ -74,11 +72,6 @@ public void testDefault() throws Exception { @Test public void testWrongSequenceInNonStaticImports() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("useContainerOrderingForStatic", "false"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "false"); - checkConfig.addProperty("option", "bottom"); final String[] expected = { "19:1: " + getCheckMessage(MSG_ORDERING, @@ -91,7 +84,6 @@ public void testWrongSequenceInNonStaticImports() throws Exception { @Test public void testMultilineImport() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -100,10 +92,6 @@ public void testMultilineImport() throws Exception { @Test public void testGroups() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "java.awt"); - checkConfig.addProperty("groups", "javax.swing"); - checkConfig.addProperty("groups", "java.io"); final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), "29:1: " + getCheckMessage(MSG_ORDERING, "java.io.IOException"), @@ -118,9 +106,6 @@ public void testGroups() throws Exception { @Test public void testGroupsRegexp() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "java, /^javax?\\.(awt|swing)\\./"); - checkConfig.addProperty("ordered", "false"); final String[] expected = { "27:1: " + getCheckMessage(MSG_ORDERING, "java.io.File"), "34:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, @@ -133,10 +118,6 @@ public void testGroupsRegexp() throws Exception { @Test public void testSeparated() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "java.awt, javax.swing, java.io, java.util"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("ordered", "false"); final String[] expected = { "25:1: " + getCheckMessage(MSG_SEPARATION, "javax.swing.JComponent"), "27:1: " + getCheckMessage(MSG_SEPARATION, "java.io.File"), @@ -149,11 +130,6 @@ public void testSeparated() throws Exception { @Test public void testStaticImportSeparated() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "java, org"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("option", "top"); final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.cos"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.junit.Assert.assertEquals"), @@ -165,11 +141,6 @@ public void testStaticImportSeparated() throws Exception { @Test public void testNoGapBetweenStaticImports() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "java, javax, org"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("option", "bottom"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -178,12 +149,6 @@ public void testNoGapBetweenStaticImports() throws Exception { @Test public void testSortStaticImportsAlphabeticallyFalse() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "java, javax, org"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -193,12 +158,6 @@ public void testSortStaticImportsAlphabeticallyFalse() throws Exception { @Test public void testSortStaticImportsAlphabeticallyTrue() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "java, javax, org"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = { "20:1: " + getCheckMessage(MSG_ORDERING, "javax.xml.transform.TransformerFactory.newInstance"), @@ -213,8 +172,6 @@ public void testSortStaticImportsAlphabeticallyTrue() throws Exception { @Test public void testCaseInsensitive() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("caseSensitive", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -223,10 +180,6 @@ public void testCaseInsensitive() throws Exception { @Test public void testContainerCaseInsensitive() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("caseSensitive", "false"); - checkConfig.addProperty("useContainerOrderingForStatic", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -236,8 +189,6 @@ public void testContainerCaseInsensitive() throws Exception { @Test public void testSimilarGroupPattern() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "/java.util/, /java.io/"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -247,9 +198,6 @@ public void testSimilarGroupPattern() throws Exception { @Test public void testInvalidOption() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "invalid_option"); try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -270,9 +218,6 @@ public void testInvalidOption() throws Exception { @Test public void testTop() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "top"); final String[] expected = { "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.awt.Button"), "28:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.io.IOException"), @@ -287,9 +232,6 @@ public void testTop() throws Exception { @Test public void testAbove() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "above"); final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Button.ABORT"), "24:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), @@ -304,9 +246,6 @@ public void testAbove() throws Exception { @Test public void testInFlow() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "inflow"); final String[] expected = { "22:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), "25:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "javax.swing.JComponent"), @@ -326,9 +265,6 @@ public void testInFlow() throws Exception { @Test public void testUnder() throws Exception { // is default (testDefault) - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "under"); final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), "27:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Button.ABORT"), @@ -342,9 +278,6 @@ public void testUnder() throws Exception { @Test public void testBottom() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "bottom"); final String[] expected = { "24:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.io.IOException"), "27:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "javax.swing.JComponent"), @@ -361,9 +294,6 @@ public void testBottom() throws Exception { @Test public void testGetGroupNumber() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "/javax/, sun, /^java/, org, /java/"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -372,9 +302,6 @@ public void testGetGroupNumber() throws Exception { @Test public void testHonorsTokenProperty() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("tokens", "IMPORT"); final String[] expected = { "22:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Button"), }; @@ -385,8 +312,6 @@ public void testHonorsTokenProperty() throws Exception { @Test public void testWildcard() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "com, *, java"); final String[] expected = { "25:1: " + getCheckMessage(MSG_ORDERING, "javax.crypto.Cipher"), }; @@ -397,9 +322,6 @@ public void testWildcard() throws Exception { @Test public void testWildcardUnspecified() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - - checkConfig.addProperty("groups", "java, javax, org"); final String[] expected = { "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "com.puppycrawl.tools.checkstyle.checks.imports.importorder.InputImportOrderBug"), @@ -411,8 +333,6 @@ public void testWildcardUnspecified() throws Exception { @Test public void testNoFailureForRedundantImports() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputImportOrder_NoFailureForRedundantImports.java"), @@ -421,11 +341,6 @@ public void testNoFailureForRedundantImports() throws Exception { @Test public void testStaticGroupsAlphabeticalOrder() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("groups", "org, java"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = { "22:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.antlr.v4.runtime.*"), "24:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), @@ -437,10 +352,6 @@ public void testStaticGroupsAlphabeticalOrder() throws Exception { @Test public void testStaticGroupsOrder() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("groups", "org, java"); final String[] expected = { "22:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.antlr.v4.runtime.*"), "24:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), @@ -451,11 +362,6 @@ public void testStaticGroupsOrder() throws Exception { @Test public void testStaticGroupsAlphabeticalOrderBottom() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "bottom"); - checkConfig.addProperty("groups", "org, java"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.PI"), @@ -466,12 +372,6 @@ public void testStaticGroupsAlphabeticalOrderBottom() throws Exception { @Test public void testStaticGroupsAlphabeticalOrderBottomNegative() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "bottom"); - checkConfig.addProperty("groups", "org, java"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = { "24:1: " + getCheckMessage(MSG_ORDERING, "java.util.Set"), }; @@ -486,12 +386,6 @@ public void testStaticGroupsAlphabeticalOrderBottomNegative() throws Exception { */ @Test public void testStaticGroupsAlphabeticalOrderTopNegative() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("groups", "org, java"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.lang.Math.PI"), }; @@ -506,12 +400,6 @@ public void testStaticGroupsAlphabeticalOrderTopNegative() throws Exception { */ @Test public void testStaticGroupsAlphabeticalOrderBottomNegative2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "bottom"); - checkConfig.addProperty("groups", "org, java"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = { "24:1: " + getCheckMessage(MSG_ORDERING, "java.util.Set"), }; @@ -522,10 +410,6 @@ public void testStaticGroupsAlphabeticalOrderBottomNegative2() throws Exception @Test public void testStaticGroupsOrderBottom() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "bottom"); - checkConfig.addProperty("groups", "org, java"); final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.PI"), @@ -536,10 +420,6 @@ public void testStaticGroupsOrderBottom() throws Exception { @Test public void testImportReception() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("groups", "java, javax"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputImportOrderRepetition.java"), expected); @@ -547,12 +427,6 @@ public void testImportReception() throws Exception { @Test public void testStaticImportReceptionTop() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("groups", "java, org"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputImportOrderStaticRepetition1.java"), expected); @@ -560,10 +434,6 @@ public void testStaticImportReceptionTop() throws Exception { @Test public void testStaticImportReception() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("groups", "java, org"); final String[] expected = { "20:1: " + getCheckMessage(MSG_SEPARATION, "org.antlr.v4.runtime.CommonToken.*"), "23:1: " + getCheckMessage(MSG_ORDERING, "java.util.Set"), @@ -574,11 +444,6 @@ public void testStaticImportReception() throws Exception { @Test public void testStaticGroupsOrderAbove() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "above"); - checkConfig.addProperty("groups", "org, java, sun"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.PI"), @@ -591,10 +456,6 @@ public void testStaticGroupsOrderAbove() throws Exception { @Test public void testStaticOnDemandGroupsOrder() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("groups", "org, java"); final String[] expected = { "22:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.antlr.v4.runtime.*"), "24:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), @@ -606,11 +467,6 @@ public void testStaticOnDemandGroupsOrder() throws Exception { @Test public void testStaticOnDemandGroupsAlphabeticalOrder() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("groups", "org, java"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = { "22:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.antlr.v4.runtime.*"), "24:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), @@ -622,10 +478,6 @@ public void testStaticOnDemandGroupsAlphabeticalOrder() throws Exception { @Test public void testStaticOnDemandGroupsOrderBottom() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "bottom"); - checkConfig.addProperty("groups", "org, java"); final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.*"), @@ -637,11 +489,6 @@ public void testStaticOnDemandGroupsOrderBottom() throws Exception { @Test public void testStaticOnDemandGroupsAlphabeticalOrderBottom() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "bottom"); - checkConfig.addProperty("groups", "org, java"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.*"), @@ -653,11 +500,6 @@ public void testStaticOnDemandGroupsAlphabeticalOrderBottom() throws Exception { @Test public void testStaticOnDemandGroupsOrderAbove() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "above"); - checkConfig.addProperty("groups", "org, java"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.*"), @@ -694,8 +536,6 @@ public void testGroupWithSlashes() throws Exception { @Test public void testGroupWithDot() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "javax.swing., java.awt."); final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), "23:1: " + getCheckMessage(MSG_ORDERING, "javax.swing.JComponent"), @@ -707,8 +547,6 @@ public void testGroupWithDot() throws Exception { @Test public void testMultiplePatternMatches() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "/java/,/rga/,/myO/,/org/,/organ./"); final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.*"), }; @@ -770,12 +608,6 @@ private static DetailAstImpl mockAST(final int tokenType, final String tokenText @Test public void testEclipseDefaultPositive() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "java, javax, org, com"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -784,13 +616,6 @@ public void testEclipseDefaultPositive() throws Exception { @Test public void testStaticImportEclipseRepetition() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("groups", "java, org"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); - checkConfig.addProperty("useContainerOrderingForStatic", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputImportOrderEclipseStaticRepetition.java"), expected); @@ -798,12 +623,6 @@ public void testStaticImportEclipseRepetition() throws Exception { @Test public void testEclipseDefaultNegative() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "java, javax, org, com"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); final String[] expected = { "28:1: " + getCheckMessage(MSG_SEPARATION, "javax.swing.JComponent"), "33:1: " + getCheckMessage(MSG_ORDERING, "org.junit.Test"), @@ -815,14 +634,6 @@ public void testEclipseDefaultNegative() throws Exception { @Test public void testUseContainerOrderingForStaticTrue() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "/^javax?\\./,org"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("caseSensitive", "false"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); - checkConfig.addProperty("useContainerOrderingForStatic", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputImportOrderEclipseStatic1.java"), expected); @@ -830,14 +641,6 @@ public void testUseContainerOrderingForStaticTrue() throws Exception { @Test public void testUseContainerOrderingForStaticFalse() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "/^javax?\\./,org"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("caseSensitive", "false"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); - checkConfig.addProperty("useContainerOrderingForStatic", "false"); final String[] expected = { "22:1: " + getCheckMessage(MSG_ORDERING, "io.netty.handler.codec.http.HttpHeaders.Names.addDate"), @@ -848,13 +651,6 @@ public void testUseContainerOrderingForStaticFalse() throws Exception { @Test public void testUseContainerOrderingForStaticTrueCaseSensitive() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "/^javax?\\./,org"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); - checkConfig.addProperty("useContainerOrderingForStatic", "true"); final String[] expected = { "23:1: " + getCheckMessage(MSG_ORDERING, "io.netty.handler.codec.http.HttpHeaders.Names.DATE"), @@ -865,10 +661,6 @@ public void testUseContainerOrderingForStaticTrueCaseSensitive() throws Exceptio @Test public void testUseContainerOrderingForStatic() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); - checkConfig.addProperty("useContainerOrderingForStatic", "true"); final String[] expected = { "22:1: " + getCheckMessage(MSG_ORDERING, "io.netty.handler.Codec.HTTP.HttpHeaders.tmp.same"), @@ -882,11 +674,6 @@ public void testUseContainerOrderingForStatic() throws Exception { @Test public void testImportGroupsRedundantSeparatedInternally() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "/^javax\\./, com"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("option", "bottom"); final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.*"), }; @@ -897,10 +684,6 @@ public void testImportGroupsRedundantSeparatedInternally() throws Exception { @Test public void testStaticGroupsAbove() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", ""); - checkConfig.addProperty("staticGroups", ""); - checkConfig.addProperty("option", "above"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -910,14 +693,6 @@ public void testStaticGroupsAbove() throws Exception { @Test public void testStaticGroupsBottom() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "org, java"); - checkConfig.addProperty("staticGroups", "java, org"); - checkConfig.addProperty("option", "bottom"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); - checkConfig.addProperty("useContainerOrderingForStatic", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -927,15 +702,6 @@ public void testStaticGroupsBottom() throws Exception { @Test public void testStaticGroupsBottomSeparated() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "android, com, net, junit, org, java, javax"); - checkConfig.addProperty("staticGroups", "android, com, net, junit, org, java, javax"); - checkConfig.addProperty("option", "bottom"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("separatedStaticGroups", "true"); - checkConfig.addProperty("useContainerOrderingForStatic", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -944,10 +710,6 @@ public void testStaticGroupsBottomSeparated() throws Exception { @Test public void testStaticGroupsInflow() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", ""); - checkConfig.addProperty("staticGroups", ""); - checkConfig.addProperty("option", "inflow"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -957,13 +719,6 @@ public void testStaticGroupsInflow() throws Exception { @Test public void testStaticGroupsNegative() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("staticGroups", "org, java"); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); - checkConfig.addProperty("useContainerOrderingForStatic", "false"); final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "org.junit.Assert.fail"), "23:1: " + getCheckMessage(MSG_ORDERING, "org.infinispan.test.TestingUtil.extract"), @@ -976,14 +731,6 @@ public void testStaticGroupsNegative() throws Exception { @Test public void testStaticGroupsTop() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "org, com, java, javax"); - checkConfig.addProperty("staticGroups", "org, com, java, javax"); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("separated", "true"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); - checkConfig.addProperty("useContainerOrderingForStatic", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -993,15 +740,6 @@ public void testStaticGroupsTop() throws Exception { @Test public void testStaticGroupsTopSeparated() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "android, androidx, java"); - checkConfig.addProperty("staticGroups", "android, androidx, java"); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "true"); - checkConfig.addProperty("separated", "false"); - checkConfig.addProperty("separatedStaticGroups", "true"); - checkConfig.addProperty("useContainerOrderingForStatic", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -1011,13 +749,6 @@ public void testStaticGroupsTopSeparated() throws Exception { @Test public void testStaticGroupsUnordered() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); - checkConfig.addProperty("groups", "org, com, java"); - checkConfig.addProperty("staticGroups", ""); - checkConfig.addProperty("option", "top"); - checkConfig.addProperty("ordered", "true"); - checkConfig.addProperty("separated", "false"); - checkConfig.addProperty("sortStaticImportsAlphabetically", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckTest.java index 970218a90e3..7f95b526159 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckTest.java @@ -77,8 +77,6 @@ public void testStateIsClearedOnBeginTree1() @Test public void testWithChecker() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantImportCheck.class); final String[] expected = { "9:1: " + getCheckMessage(MSG_SAME, "com.puppycrawl.tools.checkstyle.checks.imports.redundantimport.*"), @@ -97,8 +95,6 @@ public void testWithChecker() @Test public void testUnnamedPackage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantImportCheck.class); final String[] expected = { "10:1: " + getCheckMessage(MSG_DUPLICATE, 9, "java.util.List"), "12:1: " + getCheckMessage(MSG_LANG, "java.lang.String"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java index 8ae7771b495..d90096a3070 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java @@ -67,8 +67,6 @@ public void testReferencedStateIsCleared() throws Exception { @Test public void testWithoutProcessJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); - checkConfig.addProperty("processJavadoc", "false"); final String[] expected = { "11:16: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks." @@ -107,7 +105,6 @@ public void testWithoutProcessJavadoc() throws Exception { @Test public void testProcessJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = { "11:16: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks." @@ -129,7 +126,6 @@ public void testProcessJavadoc() throws Exception { @Test public void testProcessJavadocWithLinkTag() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputUnusedImportsWithValueTag.java"), expected); @@ -137,7 +133,6 @@ public void testProcessJavadocWithLinkTag() throws Exception { @Test public void testProcessJavadocWithBlockTagContainingMethodParameters() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputUnusedImportsWithBlockMethodParameters.java"), expected); @@ -145,7 +140,6 @@ public void testProcessJavadocWithBlockTagContainingMethodParameters() throws Ex @Test public void testAnnotations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputUnusedImportsAnnotations.java"), expected); @@ -153,7 +147,6 @@ public void testAnnotations() throws Exception { @Test public void testBug() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputUnusedImportsBug.java"), expected); @@ -161,7 +154,6 @@ public void testBug() throws Exception { @Test public void testNewlinesInsideTags() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputUnusedImportsWithNewlinesInsideTags.java"), expected); @@ -227,7 +219,6 @@ public void testGetAcceptableTokens() { @Test public void testFileInUnnamedPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = { "12:8: " + getCheckMessage(MSG_KEY, "java.util.Arrays"), "13:8: " + getCheckMessage(MSG_KEY, "java.lang.String"), @@ -239,7 +230,6 @@ public void testFileInUnnamedPackage() throws Exception { @Test public void testImportsFromJavaLang() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = { "10:8: " + getCheckMessage(MSG_KEY, "java.lang.String"), "11:8: " + getCheckMessage(MSG_KEY, "java.lang.Math"), @@ -259,7 +249,6 @@ public void testImportsFromJavaLang() throws Exception { @Test public void testImportsJavadocQualifiedName() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = { "11:8: " + getCheckMessage(MSG_KEY, "java.util.List"), }; @@ -269,7 +258,6 @@ public void testImportsJavadocQualifiedName() throws Exception { @Test public void testSingleWordPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = { "10:8: " + getCheckMessage(MSG_KEY, "module"), }; @@ -280,7 +268,6 @@ public void testSingleWordPackage() throws Exception { @Test public void testRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = { "19:8: " + getCheckMessage(MSG_KEY, "javax.swing.JToolBar"), "20:8: " + getCheckMessage(MSG_KEY, "javax.swing.JToggleButton"), @@ -292,7 +279,6 @@ public void testRecordsAndCompactCtors() throws Exception { @Test public void testShadowedImports() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String[] expected = { "12:8: " + getCheckMessage(MSG_KEY, "java.util.Map"), "13:8: " + getCheckMessage(MSG_KEY, "java.util.Set"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheckTest.java index 8e3d1bba311..d27bcb270fc 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheckTest.java @@ -49,7 +49,6 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.TreeWalker; import com.puppycrawl.tools.checkstyle.api.DetailNode; import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -138,12 +137,6 @@ public void testParsingErrors(@SysErr Capturable systemErr) throws Exception { @Test public void testWithMultipleChecks() throws Exception { - final DefaultConfiguration checksConfig = createModuleConfig(TreeWalker.class); - checksConfig.addChild(createModuleConfig(AtclauseOrderCheck.class)); - checksConfig.addChild(createModuleConfig(JavadocParagraphCheck.class)); - - final DefaultConfiguration checkerConfig = createRootConfig(checksConfig); - verifyWithInlineConfigParser( getPath("InputAbstractJavadocCorrectParagraph.java"), CommonUtil.EMPTY_STRING_ARRAY); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckTest.java index 32701db4a2e..bef40c8334c 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -56,7 +55,6 @@ public void testGetRequiredTokens() { @Test public void testCorrect() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AtclauseOrderCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -67,7 +65,6 @@ public void testCorrect() throws Exception { public void testIncorrect() throws Exception { final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]"; - final DefaultConfiguration checkConfig = createModuleConfig(AtclauseOrderCheck.class); final String[] expected = { "20: " + getCheckMessage(MSG_KEY, tagOrder), "22: " + getCheckMessage(MSG_KEY, tagOrder), @@ -116,11 +113,6 @@ public void testIncorrect() throws Exception { @Test public void testIncorrectCustom() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AtclauseOrderCheck.class); - checkConfig.addProperty("target", "CLASS_DEF"); - checkConfig.addProperty("tagOrder", "@since, @version, @param, @return, @throws, " - + "@exception, @deprecated, @see, @serial, @serialField, @serialData, @author"); - final String tagOrder = "[@since, @version, @param, @return, @throws, @exception," + " @deprecated, @see, @serial, @serialField, @serialData, @author]"; final String[] expected = { @@ -132,7 +124,6 @@ public void testIncorrectCustom() throws Exception { @Test public void testPackageInfo() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AtclauseOrderCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -141,13 +132,6 @@ public void testPackageInfo() throws Exception { @Test public void testAtclauseOrderRecords() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AtclauseOrderCheck.class); - checkConfig.addProperty("target", "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF," - + " CTOR_DEF, VARIABLE_DEF, RECORD_DEF, COMPACT_CTOR_DEF"); - - checkConfig.addProperty("tagOrder", "@author, @version, @param, @return, @throws," - + " @exception, @see, @since, @serial, @serialField, @serialData, @deprecated"); - final String tagOrder = "[@author, @version, @param, @return, @throws, @exception," + " @see, @since, @serial, @serialField, @serialData, @deprecated]"; @@ -167,7 +151,6 @@ public void testAtclauseOrderRecords() throws Exception { @Test public void testMethodReturningArrayType() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AtclauseOrderCheck.class); final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]"; final String[] expected = { @@ -181,13 +164,6 @@ public void testMethodReturningArrayType() throws Exception { @Test public void testAtclauseOrderLotsOfRecords() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AtclauseOrderCheck.class); - checkConfig.addProperty("target", "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF," - + " CTOR_DEF, VARIABLE_DEF, RECORD_DEF, COMPACT_CTOR_DEF"); - - checkConfig.addProperty("tagOrder", "@author, @version, @param, @return, @throws," - + " @exception, @see, @since, @serial, @serialField, @serialData, @deprecated"); - final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -198,7 +174,6 @@ public void testAtclauseOrderLotsOfRecords() throws Exception { public void testAtclause() throws Exception { final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]"; - final DefaultConfiguration checkConfig = createModuleConfig(AtclauseOrderCheck.class); final String[] expected = { "20: " + getCheckMessage(MSG_KEY, tagOrder), "21: " + getCheckMessage(MSG_KEY, tagOrder), @@ -229,7 +204,6 @@ public void testAtclause() throws Exception { @Test public void testNewArrayDeclaratorStructure() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AtclauseOrderCheck.class); final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]"; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckTest.java index ef711bfd216..86b47348e17 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.api.TokenTypes; public class InvalidJavadocPositionCheckTest extends AbstractModuleTestSupport { @@ -59,7 +58,6 @@ public void testGetRequiredTokens() { @Test public void testDefault() throws Exception { - final Configuration checkConfig = createModuleConfig(InvalidJavadocPositionCheck.class); final String[] expected = { "7:9: " + getCheckMessage(MSG_KEY), "10:1: " + getCheckMessage(MSG_KEY), @@ -90,7 +88,6 @@ public void testDefault() throws Exception { @Test public void testPackageInfo() throws Exception { - final Configuration checkConfig = createModuleConfig(InvalidJavadocPositionCheck.class); final String[] expected = { "7:1: " + getCheckMessage(MSG_KEY), }; @@ -100,7 +97,6 @@ public void testPackageInfo() throws Exception { @Test public void testPackageInfoComment() throws Exception { - final Configuration checkConfig = createModuleConfig(InvalidJavadocPositionCheck.class); final String[] expected = { "7:1: " + getCheckMessage(MSG_KEY), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheckTest.java index fc09fdb07e7..ecd6a6d0afc 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheckTest.java @@ -25,7 +25,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.JavadocTokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -48,8 +47,6 @@ public void testGetAcceptableTokens() { @Test public void testCorrect() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocBlockTagLocationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -67,8 +64,6 @@ public void testCorrect() throws Exception { */ @Test public void testMultilineCodeBlock() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocBlockTagLocationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -77,8 +72,6 @@ public void testMultilineCodeBlock() throws Exception { @Test public void testIncorrect() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocBlockTagLocationCheck.class); final String[] expected = { "15: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "author"), "16: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "since"), @@ -94,10 +87,6 @@ public void testIncorrect() throws Exception { @Test public void testCustomTags() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocBlockTagLocationCheck.class); - checkConfig.addProperty("tags", "apiNote"); - checkConfig.addProperty("tags", "implSpec, implNote"); final String[] expected = { "14: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "apiNote"), "14: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "implNote"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheckTest.java index bb5d5727bee..22a464ee552 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheckTest.java @@ -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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -54,8 +53,6 @@ public void testGetDefaultTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocContentLocationCheck.class); final String[] expected = { "17:5: " + getCheckMessage(MSG_JAVADOC_CONTENT_SECOND_LINE), "21:5: " + getCheckMessage(MSG_JAVADOC_CONTENT_SECOND_LINE), @@ -66,9 +63,6 @@ public void testDefault() throws Exception { @Test public void testFirstLine() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocContentLocationCheck.class); - checkConfig.addProperty("location", "FIRST_LINE"); final String[] expected = { "12:5: " + getCheckMessage(MSG_JAVADOC_CONTENT_FIRST_LINE), "21:5: " + getCheckMessage(MSG_JAVADOC_CONTENT_FIRST_LINE), @@ -79,9 +73,6 @@ public void testFirstLine() throws Exception { @Test public void testPackage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocContentLocationCheck.class); - checkConfig.addProperty("location", "SECOND_LINE"); final String[] expected = { "8:1: " + getCheckMessage(MSG_JAVADOC_CONTENT_SECOND_LINE), }; @@ -91,9 +82,6 @@ public void testPackage() throws Exception { @Test public void testInterface() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocContentLocationCheck.class); - checkConfig.addProperty("location", "FIRST_LINE"); final String[] expected = { "10:1: " + getCheckMessage(MSG_JAVADOC_CONTENT_FIRST_LINE), }; @@ -103,8 +91,6 @@ public void testInterface() throws Exception { @Test public void testOptionalSpacesAndAsterisks() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocContentLocationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocContentLocationTrailingSpace.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheckTest.java index 12edeec8802..e6e8338ecf3 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheckTest.java @@ -34,7 +34,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -66,8 +65,6 @@ public void testGetAcceptableTokens() { @Test public void extendAnnotationTest() throws Exception { - final DefaultConfiguration config = createModuleConfig(JavadocMethodCheck.class); - config.addProperty("allowedAnnotations", "MyAnnotation, Override"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodExtendAnnotation.java"), expected); @@ -75,8 +72,6 @@ public void extendAnnotationTest() throws Exception { @Test public void allowedAnnotationsTest() throws Exception { - final DefaultConfiguration config = createModuleConfig(JavadocMethodCheck.class); - config.addProperty("allowedAnnotations", "Override,ThisIsOk, \t\n\t ThisIsOkToo"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodAllowedAnnotations.java"), expected); @@ -84,8 +79,6 @@ public void allowedAnnotationsTest() throws Exception { @Test public void testThrowsDetection() throws Exception { - final DefaultConfiguration config = createModuleConfig(JavadocMethodCheck.class); - config.addProperty("validateThrows", "true"); final String[] expected = { "24:19: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "UnsupportedOperationException"), @@ -122,8 +115,6 @@ public void testThrowsDetection() throws Exception { @Test public void testExtraThrows() throws Exception { - final DefaultConfiguration config = createModuleConfig(JavadocMethodCheck.class); - config.addProperty("validateThrows", "true"); final String[] expected = { "53:56: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalStateException"), "68:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"), @@ -138,8 +129,6 @@ public void testExtraThrows() throws Exception { @Test public void testIgnoreThrows() throws Exception { - final DefaultConfiguration config = createModuleConfig(JavadocMethodCheck.class); - config.addProperty("validateThrows", "true"); final String[] expected = { "39:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"), "41:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalStateException"), @@ -153,8 +142,6 @@ public void testIgnoreThrows() throws Exception { @Test public void testTags() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("validateThrows", "true"); final String[] expected = { "30:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unused"), "36: " + getCheckMessage(MSG_RETURN_EXPECTED), @@ -185,7 +172,6 @@ public void testTags() throws Exception { @Test public void testStrictJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = { "77:29: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"), "82:22: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"), @@ -199,8 +185,6 @@ public void testStrictJavadoc() throws Exception { @Test public void testNoJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("accessModifiers", ""); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodPublicOnly1.java"), expected); @@ -209,8 +193,6 @@ public void testNoJavadoc() throws Exception { // pre 1.4 relaxed mode is roughly equivalent with check=protected @Test public void testRelaxedJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("accessModifiers", "public, protected"); final String[] expected = { "87:41: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"), "92:37: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"), @@ -221,8 +203,6 @@ public void testRelaxedJavadoc() throws Exception { @Test public void testScopeInnerInterfacesPublic() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("accessModifiers", "public"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodScopeInnerInterfaces.java"), expected); @@ -230,8 +210,6 @@ public void testScopeInnerInterfacesPublic() throws Exception { @Test public void testScopeAnonInnerPrivate() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("accessModifiers", "public, protected, package, private"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodScopeAnonInner.java"), expected); @@ -239,7 +217,6 @@ public void testScopeAnonInnerPrivate() throws Exception { @Test public void testScopes() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = { "27: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), "29: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), @@ -252,8 +229,6 @@ public void testScopes() throws Exception { @Test public void testScopes2() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("accessModifiers", "public, protected"); final String[] expected = { "27: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), "29: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), @@ -264,8 +239,6 @@ public void testScopes2() throws Exception { @Test public void testExcludeScope() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("accessModifiers", "private, package, public"); final String[] expected = { "27: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), "31: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), @@ -277,9 +250,6 @@ public void testExcludeScope() throws Exception { @Test public void testAllowMissingJavadocTags() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("allowMissingParamTags", "true"); - checkConfig.addProperty("allowMissingReturnTag", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodMissingJavadocNoMissingTags.java"), @@ -288,8 +258,6 @@ public void testAllowMissingJavadocTags() throws Exception { @Test public void testSurroundingAccessModifier() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("accessModifiers", "private"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodSurroundingAccessModifier.java"), expected); @@ -297,7 +265,6 @@ public void testSurroundingAccessModifier() throws Exception { @Test public void testDoAllowMissingJavadocTagsByDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = { "22: " + getCheckMessage(MSG_RETURN_EXPECTED), "32:26: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "number"), @@ -311,7 +278,6 @@ public void testDoAllowMissingJavadocTagsByDefault() throws Exception { @Test public void testSetterGetter() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodSetterGetter.java"), expected); @@ -319,7 +285,6 @@ public void testSetterGetter() throws Exception { @Test public void testTypeParamsTags() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = { "37:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), "39:13: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", ""), @@ -332,7 +297,6 @@ public void testTypeParamsTags() throws Exception { @Test public void testAllowUndocumentedParamsTags() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = { "29:6: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unexpectedParam"), "30:6: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unexpectedParam2"), @@ -349,7 +313,6 @@ public void testAllowUndocumentedParamsTags() throws Exception { @Test public void test11684081() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethod_01.java"), expected); @@ -357,7 +320,6 @@ public void test11684081() throws Exception { @Test public void test11684082() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethod_02.java"), expected); @@ -365,7 +327,6 @@ public void test11684082() throws Exception { @Test public void test11684083() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethod_03.java"), expected); @@ -373,8 +334,6 @@ public void test11684083() throws Exception { @Test public void testGenerics() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("validateThrows", "true"); final String[] expected = { "29:34: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "RE"), "45:13: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", ""), @@ -387,7 +346,6 @@ public void testGenerics() throws Exception { @Test public void test1379666() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethod_1379666.java"), expected); @@ -395,7 +353,6 @@ public void test1379666() throws Exception { @Test public void testInheritDoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = { "18:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC), "23:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC), @@ -410,8 +367,6 @@ public void testInheritDoc() throws Exception { @Test public void testAllowToSkipOverridden() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("allowedAnnotations", "MyAnnotation"); final String[] expected = { "19:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "BAD"), "29:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "BAD"), @@ -422,7 +377,6 @@ public void testAllowToSkipOverridden() throws Exception { @Test public void testJava8ReceiverParameter() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodReceiverParameter.java"), expected); @@ -430,7 +384,6 @@ public void testJava8ReceiverParameter() throws Exception { @Test public void testJavadocInMethod() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodJavadocInMethod.java"), expected); @@ -438,7 +391,6 @@ public void testJavadocInMethod() throws Exception { @Test public void testConstructor() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); final String[] expected = { "20:49: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"), "22:50: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"), @@ -449,11 +401,6 @@ public void testConstructor() throws Exception { @Test public void testJavadocMethodRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocMethodCheck.class); - checkConfig.addProperty("validateThrows", "true"); - checkConfig.addProperty("tokens", "METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF," - + " COMPACT_CTOR_DEF, RECORD_DEF, CLASS_DEF"); - final String[] expected = { "28:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"), "41:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", @@ -497,7 +444,6 @@ public void testTokenToString() throws Exception { @Test public void testWithoutLogErrors() throws Exception { - final DefaultConfiguration config = createModuleConfig(JavadocMethodCheck.class); verifyWithInlineConfigParser( getPath("InputJavadocMethodLoadErrors.java"), CommonUtil.EMPTY_STRING_ARRAY); @@ -505,8 +451,6 @@ public void testWithoutLogErrors() throws Exception { @Test public void testCompilationUnit() throws Exception { - final DefaultConfiguration config = createModuleConfig(JavadocMethodCheck.class); - config.addProperty("validateThrows", "true"); verifyWithInlineConfigParser( getNonCompilablePath("InputJavadocMethodCompilationUnit.java"), CommonUtil.EMPTY_STRING_ARRAY); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingLeadingAsteriskCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingLeadingAsteriskCheckTest.java index be4de3fc72a..0760efc7338 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingLeadingAsteriskCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingLeadingAsteriskCheckTest.java @@ -25,7 +25,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.JavadocTokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -49,8 +48,6 @@ public void testGetAcceptableTokens() { @Test public void testCorrect() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocMissingLeadingAsteriskCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMissingLeadingAsteriskCorrect.java"), expected); @@ -58,8 +55,6 @@ public void testCorrect() throws Exception { @Test public void testIncorrect() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocMissingLeadingAsteriskCheck.class); final String[] expected = { "13: " + getCheckMessage(MSG_MISSING_ASTERISK), "18: " + getCheckMessage(MSG_MISSING_ASTERISK), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheckTest.java index f66d0598ec4..7a243164d69 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheckTest.java @@ -25,7 +25,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.JavadocTokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -64,8 +63,6 @@ public void testGetRequiredJavadocTokens() { @Test public void testValid() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocMissingWhitespaceAfterAsteriskCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -74,8 +71,6 @@ public void testValid() throws Exception { @Test public void testValidWithTabCharacter() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocMissingWhitespaceAfterAsteriskCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -84,8 +79,6 @@ public void testValidWithTabCharacter() throws Exception { @Test public void testInvalid() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocMissingWhitespaceAfterAsteriskCheck.class); final String[] expected = { "10:4: " + getCheckMessage(MSG_KEY), "16:7: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheckTest.java index ab195d60e80..7c7442586c5 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheckTest.java @@ -28,7 +28,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -49,7 +48,6 @@ public void testGetRequiredTokens() { @Test public void testCorrect() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocParagraphCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -58,7 +56,6 @@ public void testCorrect() throws Exception { @Test public void testIncorrect() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocParagraphCheck.class); final String[] expected = { "13: " + getCheckMessage(MSG_MISPLACED_TAG), "13: " + getCheckMessage(MSG_LINE_BEFORE), @@ -103,8 +100,6 @@ public void testIncorrect() throws Exception { @Test public void testAllowNewlineParagraph() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocParagraphCheck.class); - checkConfig.addProperty("allowNewlineParagraph", "false"); final String[] expected = { "13: " + getCheckMessage(MSG_LINE_BEFORE), "14: " + getCheckMessage(MSG_LINE_BEFORE), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java index 0a39439dbcb..3a85ef07c46 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java @@ -33,8 +33,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.Scope; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -72,8 +70,6 @@ public void testGetAcceptableTokens() { @Test public void testDefaultSettings() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); final String[] expected = { "23: " + getCheckMessage(MSG_NO_PERIOD), "48: " + getCheckMessage(MSG_NO_PERIOD), @@ -112,10 +108,6 @@ public void testDefaultSettings() @Test public void testFirstSentence() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("checkFirstSentence", "true"); - checkConfig.addProperty("checkHtml", "false"); final String[] expected = { "23: " + getCheckMessage(MSG_NO_PERIOD), "48: " + getCheckMessage(MSG_NO_PERIOD), @@ -138,12 +130,6 @@ public void testFirstSentence() throws Exception { @Test public void testFirstSentenceFormat() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("checkFirstSentence", "true"); - checkConfig.addProperty("checkHtml", "false"); - checkConfig.addProperty("endOfSentenceFormat", - "([.][ \t\n\r\f<])|([.]$)"); final String[] expected = { "23: " + getCheckMessage(MSG_NO_PERIOD), "33: " + getCheckMessage(MSG_NO_PERIOD), @@ -168,9 +154,6 @@ public void testFirstSentenceFormat() throws Exception { @Test public void testHtml() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("checkFirstSentence", "false"); - checkConfig.addProperty("checkHtml", "true"); final String[] expected = { "56:11: " + getCheckMessage(MSG_UNCLOSED_HTML, "This guy is missing end of bold tag // violation"), @@ -196,9 +179,6 @@ public void testHtml() throws Exception { @Test public void testHtmlComment() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("checkFirstSentence", "false"); - checkConfig.addProperty("checkHtml", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -207,7 +187,6 @@ public void testHtmlComment() throws Exception { @Test public void testOnInputWithNoJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocStyleCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -217,12 +196,6 @@ public void testOnInputWithNoJavadoc() throws Exception { @Test public void testScopePublic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("checkFirstSentence", "true"); - checkConfig.addProperty("checkHtml", "true"); - checkConfig.addProperty("checkEmptyJavadoc", "true"); - checkConfig.addProperty("scope", "public"); final String[] expected = { "75: " + getCheckMessage(MSG_NO_PERIOD), "76:31: " + getCheckMessage(MSG_EXTRA_HTML, " // violation"), @@ -243,12 +216,6 @@ public void testScopePublic() @Test public void testScopeProtected() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("checkFirstSentence", "true"); - checkConfig.addProperty("checkHtml", "true"); - checkConfig.addProperty("checkEmptyJavadoc", "true"); - checkConfig.addProperty("scope", "protected"); final String[] expected = { "65: " + getCheckMessage(MSG_NO_PERIOD), "66:23: " + getCheckMessage(MSG_UNCLOSED_HTML, "should fail // violation"), @@ -272,12 +239,6 @@ public void testScopeProtected() @Test public void testScopePackage() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("checkFirstSentence", "true"); - checkConfig.addProperty("checkHtml", "true"); - checkConfig.addProperty("checkEmptyJavadoc", "true"); - checkConfig.addProperty("scope", "package"); final String[] expected = { "65: " + getCheckMessage(MSG_NO_PERIOD), "66:24: " + getCheckMessage(MSG_UNCLOSED_HTML, "should fail // violation"), @@ -305,10 +266,6 @@ public void testScopePackage() @Test public void testEmptyJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("checkFirstSentence", "false"); - checkConfig.addProperty("checkHtml", "false"); - checkConfig.addProperty("checkEmptyJavadoc", "true"); final String[] expected = { "175: " + getCheckMessage(MSG_EMPTY), "179: " + getCheckMessage(MSG_EMPTY), @@ -324,10 +281,6 @@ public void testEmptyJavadoc() throws Exception { @Test public void testExcludeScope() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("scope", "private"); - checkConfig.addProperty("excludeScope", "protected"); final String[] expected = { "23: " + getCheckMessage(MSG_NO_PERIOD), "48: " + getCheckMessage(MSG_NO_PERIOD), @@ -356,8 +309,6 @@ public void testExcludeScope() @Test public void packageInfoInheritDoc() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); final String[] expected = { "16: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -370,8 +321,6 @@ public void packageInfoInheritDoc() throws Exception { @Test public void packageInfoInvalid() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); final String[] expected = { "16: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -384,8 +333,6 @@ public void packageInfoInvalid() throws Exception { @Test public void packageInfoAnnotation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -396,8 +343,6 @@ public void packageInfoAnnotation() throws Exception { @Test public void packageInfoMissing() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); final String[] expected = { "16:1: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -409,8 +354,6 @@ public void packageInfoMissing() throws Exception { @Test public void packageInfoValid() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -422,12 +365,6 @@ public void packageInfoValid() throws Exception { @Test public void testRestrictedTokenSet() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("tokens", "METHOD_DEF"); - checkConfig.addProperty("scope", "public"); - checkConfig.addProperty("checkFirstSentence", "true"); - checkConfig.addProperty("checkEmptyJavadoc", "false"); - checkConfig.addProperty("checkHtml", "false"); final String[] expected = { "73: " + getCheckMessage(MSG_NO_PERIOD), "336: " + getCheckMessage(MSG_NO_PERIOD), @@ -439,8 +376,6 @@ public void testRestrictedTokenSet() @Test public void testJavadocStyleRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); final String[] expected = { "23: " + getCheckMessage(MSG_NO_PERIOD), "43: " + getCheckMessage(MSG_NO_PERIOD), @@ -472,7 +407,6 @@ public void testHtmlTagToString() { @Test public void testNeverEndingXmlCommentInsideJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocStyleCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -482,10 +416,6 @@ public void testNeverEndingXmlCommentInsideJavadoc() throws Exception { @Test public void testInterfaceMemberScopeIsPublic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("scope", Scope.PUBLIC.getName()); - checkConfig.addProperty("checkEmptyJavadoc", "true"); final String[] expected = { "20: " + getCheckMessage(MSG_EMPTY), "23: " + getCheckMessage(MSG_EMPTY), @@ -499,10 +429,6 @@ public void testInterfaceMemberScopeIsPublic() @Test public void testEnumCtorScopeIsPrivate() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocStyleCheck.class); - checkConfig.addProperty("scope", Scope.PACKAGE.getName()); - checkConfig.addProperty("checkEmptyJavadoc", "true"); final String[] expected = { "20: " + getCheckMessage(MSG_EMPTY), "23: " + getCheckMessage(MSG_EMPTY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java index e48e722c28e..5f0101fe23d 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -48,8 +47,6 @@ public void testGetRequiredTokens() { @Test public void testFp() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTagContinuationIndentationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTagContinuationIndentationGuavaFalsePositive.java"), @@ -58,8 +55,6 @@ public void testFp() throws Exception { @Test public void testCheck() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTagContinuationIndentationCheck.class); final String[] expected = { "55: " + getCheckMessage(MSG_KEY, 4), "117: " + getCheckMessage(MSG_KEY, 4), @@ -83,9 +78,6 @@ public void testCheck() throws Exception { @Test public void testCheckWithOffset3() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTagContinuationIndentationCheck.class); - checkConfig.addProperty("offset", "3"); final String[] expected = { "15: " + getCheckMessage(MSG_KEY, 3), "27: " + getCheckMessage(MSG_KEY, 3), @@ -97,8 +89,6 @@ public void testCheckWithOffset3() throws Exception { @Test public void testCheckWithDescription() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTagContinuationIndentationCheck.class); final String[] expected = { "16: " + getCheckMessage(MSG_KEY, 4), "17: " + getCheckMessage(MSG_KEY, 4), @@ -114,9 +104,6 @@ public void testCheckWithDescription() throws Exception { @Test public void testBlockTag() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTagContinuationIndentationCheck.class); - checkConfig.addProperty("offset", "4"); final String[] expected = { "21: " + getCheckMessage(MSG_KEY, 4), "32: " + getCheckMessage(MSG_KEY, 4), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckTest.java index f669383ce90..1672e53d9bd 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckTest.java @@ -28,8 +28,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.Scope; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -65,8 +63,6 @@ public void testGetAcceptableTokens() { @Test public void testTags() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTypeTags.java"), expected); @@ -74,8 +70,6 @@ public void testTags() throws Exception { @Test public void testInner() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTypeInner.java"), expected); @@ -83,8 +77,6 @@ public void testInner() throws Exception { @Test public void testStrict() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTypePublicOnly.java"), expected); @@ -92,9 +84,6 @@ public void testStrict() throws Exception { @Test public void testProtected() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PROTECTED.getName()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTypePublicOnly1.java"), expected); @@ -102,9 +91,6 @@ public void testProtected() throws Exception { @Test public void testPublic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PUBLIC.getName()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTypeScopeInnerInterfaces.java"), @@ -113,9 +99,6 @@ public void testPublic() throws Exception { @Test public void testProtest() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PROTECTED.getName()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTypeScopeInnerInterfaces1.java"), @@ -124,11 +107,6 @@ public void testProtest() throws Exception { @Test public void testPkg() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty( - "scope", - Scope.PACKAGE.getName()); final String[] expected = { "53:5: " + getCheckMessage(MSG_MISSING_TAG, "@param "), }; @@ -138,11 +116,6 @@ public void testPkg() throws Exception { @Test public void testEclipse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty( - "scope", - Scope.PUBLIC.getName()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTypeScopeInnerClasses1.java"), expected); @@ -150,9 +123,6 @@ public void testEclipse() throws Exception { @Test public void testAuthorRequired() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("authorFormat", "\\S"); final String[] expected = { "23:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), }; @@ -163,9 +133,6 @@ public void testAuthorRequired() throws Exception { @Test public void testAuthorRegularEx() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("authorFormat", "0*"); final String[] expected = { "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), "67:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), @@ -178,9 +145,6 @@ public void testAuthorRegularEx() @Test public void testAuthorRegularExError() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("authorFormat", "ABC"); final String[] expected = { "22:1: " + getCheckMessage(MSG_TAG_FORMAT, "@author", "ABC"), "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), @@ -199,9 +163,6 @@ public void testAuthorRegularExError() @Test public void testVersionRequired() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("versionFormat", "\\S"); final String[] expected = { "23:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"), }; @@ -212,9 +173,6 @@ public void testVersionRequired() @Test public void testVersionRegularEx() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("versionFormat", "^\\p{Digit}+\\.\\p{Digit}+$"); final String[] expected = { "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"), "67:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"), @@ -227,9 +185,6 @@ public void testVersionRegularEx() @Test public void testVersionRegularExError() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("versionFormat", "\\$Revision.*\\$"); final String[] expected = { "22:1: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"), "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"), @@ -250,8 +205,6 @@ public void testVersionRegularExError() @Test public void testScopes() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); final String[] expected = { "18:1: " + getCheckMessage(MSG_MISSING_TAG, "@param "), "137:5: " + getCheckMessage(MSG_MISSING_TAG, "@param "), @@ -263,9 +216,6 @@ public void testScopes() throws Exception { @Test public void testLimitViolationsBySpecifyingTokens() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("tokens", "INTERFACE_DEF"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTypeNoJavadocOnInterface.java"), @@ -274,9 +224,6 @@ public void testLimitViolationsBySpecifyingTokens() throws Exception { @Test public void testScopes2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PROTECTED.getName()); final String[] expected = { "18:1: " + getCheckMessage(MSG_MISSING_TAG, "@param "), }; @@ -287,10 +234,6 @@ public void testScopes2() throws Exception { @Test public void testExcludeScope() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PRIVATE.getName()); - checkConfig.addProperty("excludeScope", Scope.PROTECTED.getName()); final String[] expected = { "137:5: " + getCheckMessage(MSG_MISSING_TAG, "@param "), }; @@ -301,8 +244,6 @@ public void testExcludeScope() throws Exception { @Test public void testTypeParameters() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); final String[] expected = { "21:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), "25:1: " + getCheckMessage(MSG_MISSING_TAG, "@param "), @@ -316,9 +257,6 @@ public void testTypeParameters() throws Exception { @Test public void testAllowMissingTypeParameters() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("allowMissingParamTags", "true"); final String[] expected = { "21:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), "58:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), @@ -330,8 +268,6 @@ public void testAllowMissingTypeParameters() throws Exception { @Test public void testDontAllowUnusedParameterTag() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); final String[] expected = { "20:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "BAD"), "21:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), @@ -343,8 +279,6 @@ public void testDontAllowUnusedParameterTag() throws Exception { @Test public void testBadTag() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); final String[] expected = { "19:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "mytag"), }; @@ -355,9 +289,6 @@ public void testBadTag() throws Exception { @Test public void testBadTagSuppress() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("allowUnknownTags", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTypeBadTag_1.java"), @@ -366,8 +297,6 @@ public void testBadTagSuppress() throws Exception { @Test public void testAllowedAnnotationsDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -377,12 +306,6 @@ public void testAllowedAnnotationsDefault() throws Exception { @Test public void testAllowedAnnotationsWithFullyQualifiedName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty( - "allowedAnnotations", - "com.puppycrawl.tools.checkstyle.checks.javadoc.javadoctype.ThisIsOk_1"); - final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTypeAllowedAnnotations_1.java"), @@ -391,9 +314,6 @@ public void testAllowedAnnotationsWithFullyQualifiedName() throws Exception { @Test public void testAllowedAnnotationsAllowed() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("allowedAnnotations", "SuppressWarnings, ThisIsOk_2"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -403,9 +323,6 @@ public void testAllowedAnnotationsAllowed() throws Exception { @Test public void testAllowedAnnotationsNotAllowed() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("allowedAnnotations", "Override"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -415,9 +332,6 @@ public void testAllowedAnnotationsNotAllowed() throws Exception { @Test public void testJavadocTypeRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("authorFormat", "ABC"); final String[] expected = { "24:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), "33:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), @@ -431,11 +345,6 @@ public void testJavadocTypeRecords() throws Exception { @Test public void testJavadocTypeRecordComponents() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("scope", "protected"); - checkConfig.addProperty("allowMissingParamTags", "false"); - checkConfig.addProperty("allowUnknownTags", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -445,11 +354,6 @@ public void testJavadocTypeRecordComponents() throws Exception { @Test public void testJavadocTypeRecordComponents2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("scope", "private"); - checkConfig.addProperty("allowMissingParamTags", "false"); - checkConfig.addProperty("allowUnknownTags", "false"); final String[] expected = { "44:1: " + getCheckMessage(MSG_MISSING_TAG, "@param "), @@ -471,9 +375,6 @@ public void testJavadocTypeRecordComponents2() throws Exception { @Test public void testJavadocTypeInterfaceMemberScopeIsPublic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PUBLIC.getName()); final String[] expected = { "19:5: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckTest.java index 58138cc1a67..e7295c93eba 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckTest.java @@ -25,8 +25,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.Scope; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -64,8 +62,6 @@ public void testGetAcceptableTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocVariableCheck.class); final String[] expected = { "18:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "311:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -79,8 +75,6 @@ public void testDefault() @Test public void testAnother() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocVariableCheck.class); final String[] expected = { "23:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "30:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -93,9 +87,6 @@ public void testAnother() @Test public void testAnother2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocVariableCheck.class); - checkConfig.addProperty("scope", Scope.PUBLIC.getName()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocVariableInner2.java"), expected); @@ -104,8 +95,6 @@ public void testAnother2() @Test public void testAnother3() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocVariableCheck.class); final String[] expected = { "17:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "22:13: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -122,9 +111,6 @@ public void testAnother3() @Test public void testAnother4() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocVariableCheck.class); - checkConfig.addProperty("scope", Scope.PUBLIC.getName()); final String[] expected = { "52:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -134,8 +120,6 @@ public void testAnother4() @Test public void testScopes() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocVariableCheck.class); final String[] expected = { "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -182,9 +166,6 @@ public void testScopes() throws Exception { @Test public void testScopes2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocVariableCheck.class); - checkConfig.addProperty("scope", Scope.PROTECTED.getName()); final String[] expected = { "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -198,10 +179,6 @@ public void testScopes2() throws Exception { @Test public void testExcludeScope() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocVariableCheck.class); - checkConfig.addProperty("scope", Scope.PRIVATE.getName()); - checkConfig.addProperty("excludeScope", Scope.PROTECTED.getName()); final String[] expected = { "17:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "18:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -245,9 +222,6 @@ public void testExcludeScope() throws Exception { @Test public void testIgnoredVariableNames() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocVariableCheck.class); - checkConfig.addProperty("ignoreNamePattern", "log|logger"); final String[] expected = { "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -294,9 +268,6 @@ public void testIgnoredVariableNames() @Test public void testDoNotIgnoreAnythingWhenIgnoreNamePatternIsEmpty() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(JavadocVariableCheck.class); - checkConfig.addProperty("ignoreNamePattern", ""); final String[] expected = { "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -343,7 +314,6 @@ public void testDoNotIgnoreAnythingWhenIgnoreNamePatternIsEmpty() @Test public void testLambdaLocalVariablesDoNotNeedJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocVariableCheck.class); final String[] expected = { "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -354,9 +324,6 @@ public void testLambdaLocalVariablesDoNotNeedJavadoc() throws Exception { @Test public void testInterfaceMemberScopeIsPublic() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavadocVariableCheck.class); - checkConfig.addProperty("scope", Scope.PUBLIC.getName()); - checkConfig.addProperty("tokens", "ENUM_CONSTANT_DEF, VARIABLE_DEF"); final String[] expected = { "18:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "20:5: " + getCheckMessage(MSG_JAVADOC_MISSING), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckTest.java index d2d58bdf682..8e3d3b95609 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckTest.java @@ -25,8 +25,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.Scope; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -62,10 +60,6 @@ public void testGetRequiredTokens() { @Test public void extendAnnotationTest() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocMethodCheck.class); - config.addProperty("allowedAnnotations", "MyAnnotation, Override"); - config.addProperty("scope", "private"); - config.addProperty("minLineCount", "2"); final String[] expected = { "60:1: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -75,10 +69,6 @@ public void extendAnnotationTest() throws Exception { @Test public void newTest() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocMethodCheck.class); - config.addProperty("allowedAnnotations", "MyAnnotation, Override"); - config.addProperty("scope", "private"); - config.addProperty("minLineCount", "2"); final String[] expected = { "70:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -88,9 +78,6 @@ public void newTest() throws Exception { @Test public void allowedAnnotationsTest() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocMethodCheck.class); - config.addProperty("allowedAnnotations", "Override,ThisIsOk, \t\n\t ThisIsOkToo"); - config.addProperty("scope", "private"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodAllowedAnnotations.java"), expected); @@ -98,9 +85,6 @@ public void allowedAnnotationsTest() throws Exception { @Test public void testTags() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); final String[] expected = { "23:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "337:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -113,9 +97,6 @@ public void testTags() throws Exception { @Test public void testStrictJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); final String[] expected = { "24:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "30:13: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -136,9 +117,6 @@ public void testStrictJavadoc() throws Exception { @Test public void testNoJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", Scope.NOTHING.getName()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodPublicOnly2.java"), expected); @@ -147,9 +125,6 @@ public void testNoJavadoc() throws Exception { // pre 1.4 relaxed mode is roughly equivalent with check=protected @Test public void testRelaxedJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", Scope.PROTECTED.getName()); final String[] expected = { "65:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "69:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -162,9 +137,6 @@ public void testRelaxedJavadoc() throws Exception { @Test public void testScopeInnerInterfacesPublic() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", Scope.PUBLIC.getName()); final String[] expected = { "52:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "53:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -176,9 +148,6 @@ public void testScopeInnerInterfacesPublic() throws Exception { @Test public void testInterfaceMemberScopeIsPublic() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", Scope.PUBLIC.getName()); final String[] expected = { "22:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "30:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -190,9 +159,6 @@ public void testInterfaceMemberScopeIsPublic() throws Exception { @Test public void testEnumCtorScopeIsPrivate() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", Scope.PACKAGE.getName()); final String[] expected = { "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -203,9 +169,6 @@ public void testEnumCtorScopeIsPrivate() throws Exception { @Test public void testScopeAnonInnerPrivate() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", Scope.PRIVATE.getName()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodScopeAnonInner.java"), expected); @@ -213,9 +176,6 @@ public void testScopeAnonInnerPrivate() throws Exception { @Test public void testScopeAnonInnerAnonInner() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", Scope.ANONINNER.getName()); final String[] expected = { "34:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "47:13: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -226,9 +186,6 @@ public void testScopeAnonInnerAnonInner() throws Exception { @Test public void testScopes() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); final String[] expected = { "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -274,9 +231,6 @@ public void testScopes() throws Exception { @Test public void testScopes2() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", Scope.PROTECTED.getName()); final String[] expected = { "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -289,10 +243,6 @@ public void testScopes2() throws Exception { @Test public void testExcludeScope() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", Scope.PRIVATE.getName()); - checkConfig.addProperty("excludeScope", Scope.PROTECTED.getName()); final String[] expected = { "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "29:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -326,9 +276,6 @@ public void testExcludeScope() throws Exception { @Test public void testDoAllowMissingJavadocTagsByDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodMissingJavadocTags.java"), expected); @@ -336,9 +283,6 @@ public void testDoAllowMissingJavadocTagsByDefault() throws Exception { @Test public void testSetterGetterOff() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); final String[] expected = { "20:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -364,10 +308,6 @@ public void testSetterGetterOff() throws Exception { @Test public void testSetterGetterOn() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); - checkConfig.addProperty("allowMissingPropertyJavadoc", "true"); final String[] expected = { "30:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "35:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -390,9 +330,6 @@ public void testSetterGetterOn() throws Exception { @Test public void test11684081() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethod_01.java"), expected); @@ -400,9 +337,6 @@ public void test11684081() throws Exception { @Test public void test11684082() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethod_02.java"), expected); @@ -410,10 +344,6 @@ public void test11684082() throws Exception { @Test public void testSkipCertainMethods() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); - checkConfig.addProperty("ignoreMethodNamesRegex", "^foo.*$"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodIgnoreNameRegex.java"), expected); @@ -421,10 +351,6 @@ public void testSkipCertainMethods() throws Exception { @Test public void testNotSkipAnythingWhenSkipRegexDoesNotMatch() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); - checkConfig.addProperty("ignoreMethodNamesRegex", "regexThatDoesNotMatch"); final String[] expected = { "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -436,10 +362,6 @@ public void testNotSkipAnythingWhenSkipRegexDoesNotMatch() throws Exception { @Test public void testAllowToSkipOverridden() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); - checkConfig.addProperty("allowedAnnotations", "MyAnnotation"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodsNotSkipWritten.java"), expected); @@ -447,9 +369,6 @@ public void testAllowToSkipOverridden() throws Exception { @Test public void testJava8ReceiverParameter() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodReceiverParameter.java"), expected); @@ -457,9 +376,6 @@ public void testJava8ReceiverParameter() throws Exception { @Test public void testJavadocInMethod() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); final String[] expected = { "20:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -472,9 +388,6 @@ public void testJavadocInMethod() throws Exception { @Test public void testConstructor() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "private"); final String[] expected = { "21:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -484,9 +397,6 @@ public void testConstructor() throws Exception { @Test public void testNotPublicInterfaceMethods() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("scope", "public"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath( @@ -495,8 +405,6 @@ public void testNotPublicInterfaceMethods() throws Exception { @Test public void testPublicMethods() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); final String[] expected = { "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "24:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -511,8 +419,6 @@ public void testPublicMethods() throws Exception { @Test public void testMissingJavadocMethodRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); final String[] expected = { "22:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "27:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -520,16 +426,13 @@ public void testMissingJavadocMethodRecordsAndCompactCtors() throws Exception { "38:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "44:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "48:5: " + getCheckMessage(MSG_JAVADOC_MISSING), - }; + }; verifyWithInlineConfigParser( getNonCompilablePath("InputMissingJavadocMethodRecordsAndCtors.java"), expected); } @Test public void testMissingJavadocMethodRecordsAndCompactCtorsMinLineCount() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( - MissingJavadocMethodCheck.class); - checkConfig.addProperty("minLineCount", "2"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheckTest.java index e8b6d37771a..df065c54d30 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -38,35 +37,30 @@ protected String getPackageLocation() { @Test public void testPackageJavadocPresent() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("package-info.java"), expected); } @Test public void testPackageSingleLineJavadocPresent() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("singleline/package-info.java"), expected); } @Test public void testPackageJavadocPresentWithAnnotation() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("annotation/package-info.java"), expected); } @Test public void testPackageJavadocPresentWithBlankLines() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("blank/package-info.java"), expected); } @Test public void testPackageJavadocMissing() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = { "7:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -75,7 +69,6 @@ public void testPackageJavadocMissing() throws Exception { @Test public void testBlockCommentInsteadOfJavadoc() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = { "10:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -85,7 +78,6 @@ public void testBlockCommentInsteadOfJavadoc() throws Exception { @Test public void testSinglelineCommentInsteadOfJavadoc() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = { "8:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -95,7 +87,6 @@ public void testSinglelineCommentInsteadOfJavadoc() throws Exception { @Test public void testSinglelineCommentInsteadOfJavadoc2() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = { "8:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -105,7 +96,6 @@ public void testSinglelineCommentInsteadOfJavadoc2() throws Exception { @Test public void testPackageJavadocMissingWithAnnotation() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = { "8:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -115,7 +105,6 @@ public void testPackageJavadocMissingWithAnnotation() throws Exception { @Test public void testPackageJavadocMissingWithAnnotationAndBlockComment() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = { "12:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -125,7 +114,6 @@ public void testPackageJavadocMissingWithAnnotationAndBlockComment() throws Exce @Test public void testPackageJavadocMissingDetachedJavadoc() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = { "11:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -135,14 +123,12 @@ public void testPackageJavadocMissingDetachedJavadoc() throws Exception { @Test public void testPackageJavadocPresentWithHeader() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("header/package-info.java"), expected); } @Test public void testPackageJavadocMissingWithBlankLines() throws Exception { - final DefaultConfiguration config = createModuleConfig(MissingJavadocPackageCheck.class); final String[] expected = { "8:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheckTest.java index c351e06a0c2..db7a506e059 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheckTest.java @@ -25,8 +25,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.Scope; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -62,9 +60,6 @@ public void testGetAcceptableTokens() { @Test public void testTags() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", "PRIVATE"); final String[] expected = { "14:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "308:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -76,9 +71,6 @@ public void testTags() throws Exception { @Test public void testInner() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", "PRIVATE"); final String[] expected = { "19:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -90,9 +82,6 @@ public void testInner() throws Exception { @Test public void testStrict() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", "PRIVATE"); final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -105,9 +94,6 @@ public void testStrict() throws Exception { @Test public void testProtected() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PROTECTED.getName()); final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -117,9 +103,6 @@ public void testProtected() throws Exception { @Test public void testPublic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PUBLIC.getName()); final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "44:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -131,9 +114,6 @@ public void testPublic() throws Exception { @Test public void testProtest() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PROTECTED.getName()); final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "35:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -147,11 +127,6 @@ public void testProtest() throws Exception { @Test public void testPkg() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty( - "scope", - Scope.PACKAGE.getName()); final String[] expected = { "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "24:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -163,11 +138,6 @@ public void testPkg() throws Exception { @Test public void testEclipse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty( - "scope", - Scope.PUBLIC.getName()); final String[] expected = { "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -177,9 +147,6 @@ public void testEclipse() throws Exception { @Test public void testScopes() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", "PRIVATE"); final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -199,10 +166,6 @@ public void testScopes() throws Exception { @Test public void testLimitViolationsBySpecifyingTokens() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", "PRIVATE"); - checkConfig.addProperty("tokens", "INTERFACE_DEF"); final String[] expected = { "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -213,9 +176,6 @@ public void testLimitViolationsBySpecifyingTokens() throws Exception { @Test public void testScopes2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PROTECTED.getName()); final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -227,10 +187,6 @@ public void testScopes2() throws Exception { @Test public void testExcludeScope() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PRIVATE.getName()); - checkConfig.addProperty("excludeScope", Scope.PROTECTED.getName()); final String[] expected = { "37:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "49:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -248,8 +204,6 @@ public void testExcludeScope() throws Exception { @Test public void testDontAllowUnusedParameterTag() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocTypeUnusedParamInJavadocForClass.java"), @@ -258,9 +212,6 @@ public void testDontAllowUnusedParameterTag() throws Exception { @Test public void testSkipAnnotationsDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", "PRIVATE"); final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -274,13 +225,6 @@ public void testSkipAnnotationsDefault() throws Exception { @Test public void testSkipAnnotationsWithFullyQualifiedName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", "PRIVATE"); - checkConfig.addProperty( - "skipAnnotations", - "com.puppycrawl.tools.checkstyle.checks.javadoc.javadoctype.ThisIsOk2"); - final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "17:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -293,9 +237,6 @@ public void testSkipAnnotationsWithFullyQualifiedName() throws Exception { @Test public void testSkipAnnotationsAllowed() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("skipAnnotations", "Generated3, ThisIsOk3"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -305,10 +246,6 @@ public void testSkipAnnotationsAllowed() throws Exception { @Test public void testSkipAnnotationsNotAllowed() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", "PRIVATE"); - checkConfig.addProperty("skipAnnotations", "Override"); final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -322,10 +259,6 @@ public void testSkipAnnotationsNotAllowed() throws Exception { @Test public void testMissingJavadocTypeCheckRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", "PRIVATE"); - checkConfig.addProperty("skipAnnotations", "NonNull1"); final String[] expected = { "14:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -343,9 +276,6 @@ public void testMissingJavadocTypeCheckRecords() throws Exception { @Test public void testInterfaceMemberScopeIsPublic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MissingJavadocTypeCheck.class); - checkConfig.addProperty("scope", Scope.PUBLIC.getName()); final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/RequireEmptyLineBeforeBlockTagGroupCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/RequireEmptyLineBeforeBlockTagGroupCheckTest.java index 36b89875c21..23444d71cfd 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/RequireEmptyLineBeforeBlockTagGroupCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/RequireEmptyLineBeforeBlockTagGroupCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -48,7 +47,7 @@ public void testGetRequiredTokens() { @Test public void testCorrect() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( + createModuleConfig( RequireEmptyLineBeforeBlockTagGroupCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -59,8 +58,6 @@ public void testCorrect() throws Exception { @Test public void testIncorrect() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RequireEmptyLineBeforeBlockTagGroupCheck.class); final String[] expected = { "14: " + getCheckMessage(MSG_JAVADOC_TAG_LINE_BEFORE, "@since"), "20: " + getCheckMessage(MSG_JAVADOC_TAG_LINE_BEFORE, "@param"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckTest.java index 662eb0eefe3..8838bc603ff 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckTest.java @@ -25,7 +25,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 SingleLineJavadocCheckTest extends AbstractModuleTestSupport { @@ -53,8 +52,6 @@ public void testGetRequiredTokens() { @Test public void simpleTest() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SingleLineJavadocCheck.class); final String[] expected = { "22: " + getCheckMessage(MSG_KEY), "38: " + getCheckMessage(MSG_KEY), @@ -68,12 +65,6 @@ public void simpleTest() throws Exception { @Test public void testIgnoredTags() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SingleLineJavadocCheck.class); - checkConfig.addProperty("ignoredTags", "@inheritDoc, @throws, " - + "@ignoredCustomTag"); - checkConfig.addProperty("ignoreInlineTags", "false"); - final String[] expected = { "14: " + getCheckMessage(MSG_KEY), "44: " + getCheckMessage(MSG_KEY), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckTest.java index f7ef450b7c1..964d9e19fb6 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckTest.java @@ -28,7 +28,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -49,9 +48,6 @@ public void testGetRequiredTokens() { @Test public void testCorrect() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); - checkConfig.addProperty("forbiddenSummaryFragments", - "^@return the *|^This method returns *|^A [{]@code [a-zA-Z0-9]+[}]( is a )"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -60,7 +56,6 @@ public void testCorrect() throws Exception { @Test public void testInlineCorrect() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -69,9 +64,6 @@ public void testInlineCorrect() throws Exception { @Test public void testIncorrect() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); - checkConfig.addProperty("forbiddenSummaryFragments", - "^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"); final String[] expected = { "24: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), "42: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), @@ -95,9 +87,6 @@ public void testIncorrect() throws Exception { @Test public void testInlineForbidden() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); - checkConfig.addProperty("forbiddenSummaryFragments", - "@return the *|This method returns"); final String[] expected = { "26: " + getCheckMessage(MSG_SUMMARY_MISSING_PERIOD), "32: " + getCheckMessage(MSG_SUMMARY_MISSING_PERIOD), @@ -117,8 +106,6 @@ public void testInlineForbidden() throws Exception { @Test public void testPeriod() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); - checkConfig.addProperty("period", "_"); final String[] expected = { "14: " + getCheckMessage(MSG_SUMMARY_FIRST_SENTENCE), "19: " + getCheckMessage(MSG_SUMMARY_FIRST_SENTENCE), @@ -131,8 +118,6 @@ public void testPeriod() throws Exception { @Test public void testNoPeriod() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); - checkConfig.addProperty("period", ""); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -141,7 +126,6 @@ public void testNoPeriod() throws Exception { @Test public void testDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); final String[] expected = { "23: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), "41: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), @@ -158,15 +142,12 @@ public void testDefaultConfiguration() throws Exception { "149: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), }; - createChecker(checkConfig); verifyWithInlineConfigParser( getPath("InputSummaryJavadocIncorrect2.java"), expected); } @Test public void testInlineDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); - createChecker(checkConfig); final String[] expected = { "22: " + getCheckMessage(MSG_SUMMARY_MISSING_PERIOD), "27: " + getCheckMessage(MSG_SUMMARY_MISSING_PERIOD), @@ -190,8 +171,6 @@ public void testInlineDefaultConfiguration() throws Exception { @Test public void testPeriodAtEnd() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); - checkConfig.addProperty("period", "."); final String[] expected = { "19: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), "26: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), @@ -206,7 +185,6 @@ public void testPeriodAtEnd() throws Exception { @Test public void testHtmlFormatSummary() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); final String[] expected = { "22: " + getCheckMessage(MSG_SUMMARY_MISSING_PERIOD), "37: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), @@ -219,7 +197,6 @@ public void testHtmlFormatSummary() throws Exception { @Test public void testPackageInfo() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); final String[] expected = { "10: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), }; @@ -230,7 +207,6 @@ public void testPackageInfo() throws Exception { @Test public void testPackageInfoWithAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SummaryJavadocCheck.class); final String[] expected = { "10: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckTest.java index 506359f5801..86b1deca618 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckTest.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -41,8 +40,6 @@ protected String getPackageLocation() { @Test public void test() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(BooleanExpressionComplexityCheck.class); final String[] expected = { "21:9: " + getCheckMessage(MSG_KEY, 4, 3), @@ -58,10 +55,6 @@ public void test() throws Exception { @Test public void testNoBitwise() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(BooleanExpressionComplexityCheck.class); - checkConfig.addProperty("max", "5"); - checkConfig.addProperty("tokens", "BXOR,LAND,LOR"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -71,8 +64,6 @@ public void testNoBitwise() throws Exception { @Test public void testNullPointerException() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(BooleanExpressionComplexityCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -98,9 +89,6 @@ public void testWrongToken() { @Test public void testSmall() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(BooleanExpressionComplexityCheck.class); - checkConfig.addProperty("max", "1"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -110,9 +98,6 @@ public void testSmall() throws Exception { @Test public void testBooleanExpressionComplexityRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(BooleanExpressionComplexityCheck.class); - checkConfig.addProperty("max", "3"); final int max = 3; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckTest.java index ad0dc6a4964..565c9ac27e8 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckTest.java @@ -55,11 +55,6 @@ public void testTokens() { @Test public void test() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassDataAbstractionCouplingCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("excludedClasses", "InnerClass"); final String[] expected = { "16:1: " + getCheckMessage(MSG_KEY, 4, 0, "[AnotherInnerClass, HashMap, HashSet, int]"), @@ -73,15 +68,6 @@ public void test() throws Exception { @Test public void testExcludedPackageDirectPackages() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassDataAbstractionCouplingCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("excludedPackages", - "com.puppycrawl.tools.checkstyle.checks.metrics.classdataabstractioncoupling.inputs.c," - + " com.puppycrawl.tools.checkstyle.checks.metrics.classdataabstractioncoupling." - + "inputs.b"); - final String[] expected = { "30:1: " + getCheckMessage(MSG_KEY, 2, 0, "[AAClass, ABClass]"), }; @@ -93,13 +79,6 @@ public void testExcludedPackageDirectPackages() throws Exception { @Test public void testExcludedPackageCommonPackages() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassDataAbstractionCouplingCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("excludedPackages", - "com.puppycrawl.tools.checkstyle.checks.metrics.inputs.a"); - final String[] expected = { "28:1: " + getCheckMessage(MSG_KEY, 2, 0, "[AAClass, ABClass]"), "32:5: " + getCheckMessage(MSG_KEY, 2, 0, "[BClass, CClass]"), @@ -139,20 +118,6 @@ public void testExcludedPackageWithEndingDot() throws Exception { @Test public void testExcludedPackageCommonPackagesAllIgnored() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassDataAbstractionCouplingCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("excludedPackages", - "com.puppycrawl.tools.checkstyle.checks.metrics.classdataabstractioncoupling.inputs." - + "a.aa, " - + "com.puppycrawl.tools.checkstyle.checks.metrics.classdataabstractioncoupling." - + "inputs.a.ab, " - + "com.puppycrawl.tools.checkstyle.checks.metrics.classdataabstractioncoupling." - + "inputs.b, " - + "com.puppycrawl.tools.checkstyle.checks.metrics.classdataabstractioncoupling." - + "inputs.c"); - final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassDataAbstractionCouplingExcludedPackagesAllIgnored.java"), @@ -161,10 +126,6 @@ public void testExcludedPackageCommonPackagesAllIgnored() throws Exception { @Test public void testDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassDataAbstractionCouplingCheck.class); - - createChecker(checkConfig); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassDataAbstractionCoupling2.java"), expected); @@ -187,12 +148,6 @@ public void testWrongToken() { @Test public void testRegularExpression() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassDataAbstractionCouplingCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("excludedClasses", "InnerClass"); - checkConfig.addProperty("excludeClassesRegexps", "^Hash.*"); final String[] expected = { "22:1: " + getCheckMessage(MSG_KEY, 2, 0, "[AnotherInnerClass, int]"), @@ -205,12 +160,6 @@ public void testRegularExpression() throws Exception { @Test public void testEmptyRegularExpression() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassDataAbstractionCouplingCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("excludedClasses", "InnerClass"); - checkConfig.addProperty("excludeClassesRegexps", ""); final String[] expected = { "22:1: " + getCheckMessage(MSG_KEY, 4, 0, "[AnotherInnerClass, HashMap, HashSet, int]"), @@ -224,10 +173,6 @@ public void testEmptyRegularExpression() throws Exception { @Test public void testClassDataAbstractionCouplingRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassDataAbstractionCouplingCheck.class); - - checkConfig.addProperty("max", "1"); final int maxAbstraction = 1; final String[] expected = { diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheckTest.java index 52ac5dda461..37ea8dfc445 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheckTest.java @@ -51,10 +51,6 @@ protected String getPackageLocation() { @Test public void test() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - - checkConfig.addProperty("max", "0"); final String[] expected = { "27:1: " + getCheckMessage(MSG_KEY, 3, 0), @@ -67,14 +63,6 @@ public void test() throws Exception { @Test public void testExcludedPackagesDirectPackages() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("excludedPackages", - "com.puppycrawl.tools.checkstyle.checks.metrics.classfanoutcomplexity.inputs.c, " - + "com.puppycrawl.tools.checkstyle.checks.metrics.classfanoutcomplexity.inputs.b"); - final String[] expected = { "29:1: " + getCheckMessage(MSG_KEY, 2, 0), }; @@ -85,13 +73,6 @@ public void testExcludedPackagesDirectPackages() throws Exception { @Test public void testExcludedPackagesCommonPackages() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("excludedPackages", - "com.puppycrawl.tools.checkstyle.checks.metrics.inputs.a"); - final String[] expected = { "28:1: " + getCheckMessage(MSG_KEY, 2, 0), "32:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -130,17 +111,6 @@ public void testExcludedPackagesCommonPackagesWithEndingDot() throws Exception { @Test public void testExcludedPackagesAllIgnored() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("excludedPackages", - "com.puppycrawl.tools.checkstyle.checks.metrics.classfanoutcomplexity.inputs.a.aa, " - + "com.puppycrawl.tools.checkstyle.checks.metrics.classfanoutcomplexity." - + "inputs.a.ab, " - + "com.puppycrawl.tools.checkstyle.checks.metrics.classfanoutcomplexity.inputs.b, " - + "com.puppycrawl.tools.checkstyle.checks.metrics.classfanoutcomplexity.inputs.c"); - final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassFanOutComplexityExcludedPackagesAllIgnored.java"), expected); @@ -148,10 +118,6 @@ public void testExcludedPackagesAllIgnored() throws Exception { @Test public void test15() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - - checkConfig.addProperty("max", "0"); final String[] expected = { "29:1: " + getCheckMessage(MSG_KEY, 1, 0), @@ -163,10 +129,6 @@ public void test15() throws Exception { @Test public void testDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - - createChecker(checkConfig); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassFanOutComplexity2.java"), expected); @@ -198,11 +160,6 @@ public void testGetAcceptableTokens() { @Test public void testRegularExpression() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("excludeClassesRegexps", "^Inner.*"); final String[] expected = { "44:1: " + getCheckMessage(MSG_KEY, 2, 0), @@ -215,11 +172,6 @@ public void testRegularExpression() throws Exception { @Test public void testEmptyRegularExpression() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("excludeClassesRegexps", ""); final String[] expected = { "44:1: " + getCheckMessage(MSG_KEY, 3, 0), @@ -232,9 +184,6 @@ public void testEmptyRegularExpression() throws Exception { @Test public void testWithMultiDimensionalArray() throws Exception { - final DefaultConfiguration moduleConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - moduleConfig.addProperty("max", "0"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -243,9 +192,6 @@ public void testWithMultiDimensionalArray() throws Exception { @Test public void testPackageName() throws Exception { - final DefaultConfiguration moduleConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - moduleConfig.addProperty("max", "0"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -254,9 +200,6 @@ public void testPackageName() throws Exception { @Test public void testExtends() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - checkConfig.addProperty("max", "0"); final String[] expected = { "23:1: " + getCheckMessage(MSG_KEY, 1, 0), }; @@ -266,9 +209,6 @@ public void testExtends() throws Exception { @Test public void testImplements() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - checkConfig.addProperty("max", "0"); final String[] expected = { "23:1: " + getCheckMessage(MSG_KEY, 1, 0), }; @@ -278,9 +218,6 @@ public void testImplements() throws Exception { @Test public void testAnnotation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - checkConfig.addProperty("max", "0"); final String[] expected = { "29:1: " + getCheckMessage(MSG_KEY, 2, 0), "45:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -296,9 +233,6 @@ public void testAnnotation() throws Exception { @Test public void testClassFanOutComplexityRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - checkConfig.addProperty("max", "2"); final String[] expected = { "32:1: " + getCheckMessage(MSG_KEY, 4, 2), "53:1: " + getCheckMessage(MSG_KEY, 4, 2), @@ -309,9 +243,6 @@ public void testClassFanOutComplexityRecords() throws Exception { @Test public void testClassFanOutComplexityIgnoreVar() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - checkConfig.addProperty("max", "0"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputClassFanOutComplexityVar.java"), expected); @@ -319,9 +250,6 @@ public void testClassFanOutComplexityIgnoreVar() throws Exception { @Test public void testClassFanOutComplexityRemoveIncorrectAnnotationToken() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - checkConfig.addProperty("max", "24"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassFanOutComplexityRemoveIncorrectAnnotationToken.java"), expected); @@ -329,9 +257,6 @@ public void testClassFanOutComplexityRemoveIncorrectAnnotationToken() throws Exc @Test public void testClassFanOutComplexityRemoveIncorrectTypeParameter() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - checkConfig.addProperty("max", "1"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassFanOutComplexityRemoveIncorrectTypeParameter.java"), expected); @@ -339,9 +264,6 @@ public void testClassFanOutComplexityRemoveIncorrectTypeParameter() throws Excep @Test public void testClassFanOutComplexityRemoveMultiCatchBitwiseOr() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassFanOutComplexityCheck.class); - checkConfig.addProperty("max", "4"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassFanOutComplexityRemoveMultiCatchBitwiseOr.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheckTest.java index 541cb9cb34d..95a90b2a1f9 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -39,10 +38,6 @@ protected String getPackageLocation() { @Test public void testSwitchBlockAsSingleDecisionPointSetToTrue() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CyclomaticComplexityCheck.class); - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("switchBlockAsSingleDecisionPoint", "true"); final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -54,10 +49,6 @@ public void testSwitchBlockAsSingleDecisionPointSetToTrue() throws Exception { @Test public void testSwitchBlockAsSingleDecisionPointSetToFalse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CyclomaticComplexityCheck.class); - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("switchBlockAsSingleDecisionPoint", "false"); final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY, 5, 0), @@ -69,9 +60,6 @@ public void testSwitchBlockAsSingleDecisionPointSetToFalse() throws Exception { @Test public void testEqualsMaxComplexity() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CyclomaticComplexityCheck.class); - checkConfig.addProperty("max", "5"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -81,10 +69,6 @@ public void testEqualsMaxComplexity() throws Exception { @Test public void test() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CyclomaticComplexityCheck.class); - - checkConfig.addProperty("max", "0"); final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -105,10 +89,6 @@ public void test() throws Exception { @Test public void testCyclomaticComplexityRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CyclomaticComplexityCheck.class); - - checkConfig.addProperty("max", "0"); final int max = 0; @@ -166,9 +146,6 @@ public void testGetRequiredTokens() { @Test public void testHighMax() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(CyclomaticComplexityCheck.class); - checkConfig.addProperty("max", "100"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckTest.java index e1a419450fa..c050aedfe8c 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckTest.java @@ -29,7 +29,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -47,11 +46,6 @@ protected String getPackageLocation() { @Test public void test() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavaNCSSCheck.class); - - checkConfig.addProperty("methodMaximum", "0"); - checkConfig.addProperty("classMaximum", "1"); - checkConfig.addProperty("fileMaximum", "2"); final String[] expected = { "12:1: " + getCheckMessage(MSG_FILE, 39, 2), @@ -75,11 +69,6 @@ public void test() throws Exception { @Test public void testEqualToMax() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavaNCSSCheck.class); - - checkConfig.addProperty("methodMaximum", "12"); - checkConfig.addProperty("classMaximum", "22"); - checkConfig.addProperty("fileMaximum", "39"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -89,9 +78,6 @@ public void testEqualToMax() throws Exception { @Test public void testDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavaNCSSCheck.class); - - createChecker(checkConfig); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavaNCSS3.java"), expected); @@ -99,12 +85,6 @@ public void testDefaultConfiguration() throws Exception { @Test public void testRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(JavaNCSSCheck.class); - - checkConfig.addProperty("methodMaximum", "7"); - checkConfig.addProperty("classMaximum", "3"); - checkConfig.addProperty("fileMaximum", "2"); - checkConfig.addProperty("recordMaximum", "4"); final String[] expected = { "12:1: " + getCheckMessage(MSG_FILE, 89, 2), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckTest.java index 9dd122259c9..66d12289734 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckTest.java @@ -34,7 +34,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.JavaParser; import com.puppycrawl.tools.checkstyle.api.Context; @@ -54,10 +53,6 @@ protected String getPackageLocation() { @Test public void testCalculation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NPathComplexityCheck.class); - - checkConfig.addProperty("max", "0"); final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, 2, 0), "17:17: " + getCheckMessage(MSG_KEY, 2, 0), @@ -81,10 +76,6 @@ public void testCalculation() throws Exception { @Test public void testCalculation2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NPathComplexityCheck.class); - - checkConfig.addProperty("max", "0"); final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, 5, 0), "18:5: " + getCheckMessage(MSG_KEY, 5, 0), @@ -108,10 +99,6 @@ public void testCalculation2() throws Exception { @Test public void testCalculation3() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NPathComplexityCheck.class); - - checkConfig.addProperty("max", "0"); final String[] expected = { "11:5: " + getCheckMessage(MSG_KEY, 64, 0), }; @@ -122,10 +109,6 @@ public void testCalculation3() throws Exception { @Test public void testIntegerOverflow() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NPathComplexityCheck.class); - - checkConfig.addProperty("max", "0"); final long largerThanMaxInt = 3_486_784_401L; @@ -199,10 +182,6 @@ public void testStatefulFieldsClearedOnBeginTree3() throws Exception { @Test public void testDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(NPathComplexityCheck.class); - - createChecker(checkConfig); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNPathComplexityDefault2.java"), expected); @@ -210,9 +189,6 @@ public void testDefaultConfiguration() throws Exception { @Test public void testNpathComplexityRecords() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NPathComplexityCheck.class); - checkConfig.addProperty("max", "1"); - final int max = 1; final String[] expected = { @@ -228,8 +204,6 @@ public void testNpathComplexityRecords() throws Exception { @Test public void testNpathComplexitySwitchExpression() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NPathComplexityCheck.class); - checkConfig.addProperty("max", "1"); final int max = 1; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ClassMemberImpliedModifierCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ClassMemberImpliedModifierCheckTest.java index 681ac8902db..838577e147d 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ClassMemberImpliedModifierCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ClassMemberImpliedModifierCheckTest.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -42,8 +41,6 @@ protected String getPackageLocation() { @Test public void testMethodsOnClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassMemberImpliedModifierCheck.class); final String[] expected = { "51:9: " + getCheckMessage(MSG_KEY, "static"), "58:9: " + getCheckMessage(MSG_KEY, "static"), @@ -71,9 +68,6 @@ public void testGetRequiredTokens() { @Test public void testMethodsOnClassNoImpliedStaticEnum() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedStaticOnNestedEnum", "false"); final String[] expected = { "59:9: " + getCheckMessage(MSG_KEY, "static"), "77:9: " + getCheckMessage(MSG_KEY, "static"), @@ -86,9 +80,6 @@ public void testMethodsOnClassNoImpliedStaticEnum() throws Exception { @Test public void testMethodsOnClassNoImpliedStaticInterface() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedStaticOnNestedInterface", "false"); final String[] expected = { "52:9: " + getCheckMessage(MSG_KEY, "static"), "63:5: " + getCheckMessage(MSG_KEY, "static"), @@ -101,10 +92,6 @@ public void testMethodsOnClassNoImpliedStaticInterface() throws Exception { @Test public void testMethodsOnClassNoViolationsChecked() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedStaticOnNestedEnum", "false"); - checkConfig.addProperty("violateImpliedStaticOnNestedInterface", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassMemberImpliedModifierOnClassNoViolations.java"), @@ -113,8 +100,6 @@ public void testMethodsOnClassNoViolationsChecked() throws Exception { @Test public void testMethodsOnInterface() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassMemberImpliedModifierCheck.class); final String[] expected = { "60:13: " + getCheckMessage(MSG_KEY, "static"), "67:13: " + getCheckMessage(MSG_KEY, "static"), @@ -130,8 +115,6 @@ public void testMethodsOnInterface() throws Exception { @Test public void testClassMemberImpliedModifierRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassMemberImpliedModifierCheck.class); final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY, "static"), "20:5: " + getCheckMessage(MSG_KEY, "static"), @@ -147,9 +130,6 @@ public void testClassMemberImpliedModifierRecords() throws Exception { @Test public void testClassMemberImpliedModifierNoViolationRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedStaticOnNestedRecord", "false"); final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY, "static"), "20:5: " + getCheckMessage(MSG_KEY, "static"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheckTest.java index a3a97ac8441..206184ea0fc 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheckTest.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -42,8 +41,6 @@ protected String getPackageLocation() { @Test public void testMethodsOnInterfaceNoImpliedPublicAbstract() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY, "public"), "27:5: " + getCheckMessage(MSG_KEY, "public"), @@ -73,9 +70,6 @@ public void testGetRequiredTokens() { @Test public void testMethodsOnInterfaceNoImpliedAbstractAllowImpliedPublic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedPublicMethod", "false"); final String[] expected = { "36:5: " + getCheckMessage(MSG_KEY, "abstract"), "38:5: " + getCheckMessage(MSG_KEY, "abstract"), @@ -87,9 +81,6 @@ public void testMethodsOnInterfaceNoImpliedAbstractAllowImpliedPublic() throws E @Test public void testMethodsOnInterfaceNoImpliedPublicAllowImpliedAbstract() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedAbstractMethod", "false"); final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY, "public"), "27:5: " + getCheckMessage(MSG_KEY, "public"), @@ -103,10 +94,6 @@ public void testMethodsOnInterfaceNoImpliedPublicAllowImpliedAbstract() throws E @Test public void testMethodsOnInterfaceAllowImpliedPublicAbstract() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedPublicMethod", "false"); - checkConfig.addProperty("violateImpliedAbstractMethod", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierMethodsOnInterface4.java"), @@ -115,8 +102,6 @@ public void testMethodsOnInterfaceAllowImpliedPublicAbstract() throws Exception @Test public void testMethodsOnClassIgnored() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierMethodsOnClass.java"), @@ -125,8 +110,6 @@ public void testMethodsOnClassIgnored() throws Exception { @Test public void testMethodsOnInterfaceNestedNoImpliedPublicAbstract() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = { "23:9: " + getCheckMessage(MSG_KEY, "public"), "29:9: " + getCheckMessage(MSG_KEY, "public"), @@ -142,8 +125,6 @@ public void testMethodsOnInterfaceNestedNoImpliedPublicAbstract() throws Excepti @Test public void testMethodsOnClassNestedNoImpliedPublicAbstract() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = { "23:9: " + getCheckMessage(MSG_KEY, "public"), "29:9: " + getCheckMessage(MSG_KEY, "public"), @@ -159,8 +140,6 @@ public void testMethodsOnClassNestedNoImpliedPublicAbstract() throws Exception { @Test public void testFieldsOnInterfaceNoImpliedPublicStaticFinal() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = { "20:5: " + getCheckMessage(MSG_KEY, "final"), "22:5: " + getCheckMessage(MSG_KEY, "static"), @@ -182,9 +161,6 @@ public void testFieldsOnInterfaceNoImpliedPublicStaticFinal() throws Exception { @Test public void testFieldsOnInterfaceNoImpliedPublicStaticAllowImpliedFinal() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedFinalField", "false"); final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY, "static"), "24:5: " + getCheckMessage(MSG_KEY, "static"), @@ -202,9 +178,6 @@ public void testFieldsOnInterfaceNoImpliedPublicStaticAllowImpliedFinal() throws @Test public void testFieldsOnInterfaceNoImpliedPublicFinalAllowImpliedStatic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedStaticField", "false"); final String[] expected = { "20:5: " + getCheckMessage(MSG_KEY, "final"), "24:5: " + getCheckMessage(MSG_KEY, "final"), @@ -222,9 +195,6 @@ public void testFieldsOnInterfaceNoImpliedPublicFinalAllowImpliedStatic() throws @Test public void testFieldsOnInterfaceNoImpliedStaticFinalAllowImpliedPublic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedPublicField", "false"); final String[] expected = { "20:5: " + getCheckMessage(MSG_KEY, "final"), "22:5: " + getCheckMessage(MSG_KEY, "static"), @@ -242,11 +212,6 @@ public void testFieldsOnInterfaceNoImpliedStaticFinalAllowImpliedPublic() throws @Test public void testFieldsOnInterfaceAllowImpliedPublicStaticFinal() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedPublicField", "false"); - checkConfig.addProperty("violateImpliedStaticField", "false"); - checkConfig.addProperty("violateImpliedFinalField", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierFieldsOnInterface5.java"), @@ -255,8 +220,6 @@ public void testFieldsOnInterfaceAllowImpliedPublicStaticFinal() throws Exceptio @Test public void testFieldsOnClassIgnored() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierFieldsOnClass.java"), @@ -265,8 +228,6 @@ public void testFieldsOnClassIgnored() throws Exception { @Test public void testNestedOnInterfaceNoImpliedPublicStatic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY, "static"), "24:5: " + getCheckMessage(MSG_KEY, "public"), @@ -288,9 +249,6 @@ public void testNestedOnInterfaceNoImpliedPublicStatic() throws Exception { @Test public void testNestedOnInterfaceNoImpliedStaticAllowImpliedPublic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedPublicNested", "false"); final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY, "static"), "27:5: " + getCheckMessage(MSG_KEY, "static"), @@ -306,9 +264,6 @@ public void testNestedOnInterfaceNoImpliedStaticAllowImpliedPublic() throws Exce @Test public void testNestedOnInterfaceNoImpliedPublicAllowImpliedStatic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedStaticNested", "false"); final String[] expected = { "24:5: " + getCheckMessage(MSG_KEY, "public"), "27:5: " + getCheckMessage(MSG_KEY, "public"), @@ -324,10 +279,6 @@ public void testNestedOnInterfaceNoImpliedPublicAllowImpliedStatic() throws Exce @Test public void testNestedOnInterfaceAllowImpliedPublicStatic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); - checkConfig.addProperty("violateImpliedPublicNested", "false"); - checkConfig.addProperty("violateImpliedStaticNested", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierNestedOnInterface4.java"), @@ -336,8 +287,6 @@ public void testNestedOnInterfaceAllowImpliedPublicStatic() throws Exception { @Test public void testNestedOnClassIgnored() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierNestedOnClass.java"), @@ -346,8 +295,6 @@ public void testNestedOnClassIgnored() throws Exception { @Test public void testNestedOnInterfaceNestedNoImpliedPublicStatic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = { "20:9: " + getCheckMessage(MSG_KEY, "public"), "20:9: " + getCheckMessage(MSG_KEY, "static"), @@ -363,8 +310,6 @@ public void testNestedOnInterfaceNestedNoImpliedPublicStatic() throws Exception @Test public void testNestedOnClassNestedNoImpliedPublicStatic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = { "20:9: " + getCheckMessage(MSG_KEY, "public"), "20:9: " + getCheckMessage(MSG_KEY, "static"), @@ -380,8 +325,6 @@ public void testNestedOnClassNestedNoImpliedPublicStatic() throws Exception { @Test public void testPackageScopeInterface() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = { "20:5: " + getCheckMessage(MSG_KEY, "final"), "22:5: " + getCheckMessage(MSG_KEY, "static"), @@ -413,8 +356,6 @@ public void testPackageScopeInterface() throws Exception { @Test public void testPrivateMethodsOnInterface() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceMemberImpliedModifierCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputInterfaceMemberImpliedModifierPrivateMethods.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheckTest.java index 6f6693288cb..893d145aa3b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheckTest.java @@ -28,7 +28,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -50,8 +49,6 @@ public void testGetRequiredTokens() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ModifierOrderCheck.class); final String[] expected = { "15:10: " + getCheckMessage(MSG_MODIFIER_ORDER, "final"), "19:12: " + getCheckMessage(MSG_MODIFIER_ORDER, "private"), @@ -68,8 +65,6 @@ public void testIt() throws Exception { @Test public void testDefaultMethods() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ModifierOrderCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputModifierOrderDefaultMethods.java"), expected); @@ -110,7 +105,6 @@ public void testGetAcceptableTokens() { @Test public void testSkipTypeAnnotations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ModifierOrderCheck.class); final String[] expected = { "110:13: " + getCheckMessage(MSG_ANNOTATION_ORDER, "@MethodAnnotation"), }; @@ -121,7 +115,6 @@ public void testSkipTypeAnnotations() throws Exception { @Test public void testAnnotationOnAnnotationDeclaration() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ModifierOrderCheck.class); final String[] expected = { "9:8: " + getCheckMessage(MSG_ANNOTATION_ORDER, "@InterfaceAnnotation"), }; @@ -131,7 +124,6 @@ public void testAnnotationOnAnnotationDeclaration() throws Exception { @Test public void testModifierOrderSealedAndNonSealed() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ModifierOrderCheck.class); final String[] expected = { "10:8: " + getCheckMessage(MSG_MODIFIER_ORDER, "public"), "26:12: " + getCheckMessage(MSG_MODIFIER_ORDER, "private"), @@ -146,7 +138,6 @@ public void testModifierOrderSealedAndNonSealed() throws Exception { @Test public void testModifierOrderSealedAndNonSealedNoViolation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ModifierOrderCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputModifierOrderSealedAndNonSealedNoViolation.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java index ea4bbbd1549..dc6d865c7d0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -39,8 +38,6 @@ protected String getPackageLocation() { @Test public void testClassesInsideOfInterfaces() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "19:5: " + getCheckMessage(MSG_KEY, "static"), "25:5: " + getCheckMessage(MSG_KEY, "public"), @@ -54,8 +51,6 @@ public void testClassesInsideOfInterfaces() throws Exception { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "57:12: " + getCheckMessage(MSG_KEY, "static"), "60:9: " + getCheckMessage(MSG_KEY, "public"), @@ -79,8 +74,6 @@ public void testIt() throws Exception { @Test public void testStaticMethodInInterface() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantModifierCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRedundantModifierStaticMethodInInterface.java"), @@ -90,8 +83,6 @@ public void testStaticMethodInInterface() @Test public void testFinalInInterface() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "13:9: " + getCheckMessage(MSG_KEY, "final"), }; @@ -101,8 +92,6 @@ public void testFinalInInterface() @Test public void testEnumConstructorIsImplicitlyPrivate() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY, "private"), }; @@ -112,8 +101,6 @@ public void testEnumConstructorIsImplicitlyPrivate() throws Exception { @Test public void testInnerTypeInInterfaceIsImplicitlyStatic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, "static"), "16:5: " + getCheckMessage(MSG_KEY, "static"), @@ -125,8 +112,6 @@ public void testInnerTypeInInterfaceIsImplicitlyStatic() throws Exception { @Test public void testNotPublicClassConstructorHasNotPublicModifier() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY, "public"), @@ -138,8 +123,6 @@ public void testNotPublicClassConstructorHasNotPublicModifier() throws Exception @Test public void testNestedClassConsInPublicInterfaceHasValidPublicModifier() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "22:17: " + getCheckMessage(MSG_KEY, "public"), @@ -180,8 +163,6 @@ public void testGetRequiredTokens() { @Test public void testNestedStaticEnum() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, "static"), "16:9: " + getCheckMessage(MSG_KEY, "static"), @@ -195,8 +176,6 @@ public void testNestedStaticEnum() throws Exception { @Test public void testFinalInAnonymousClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "22:20: " + getCheckMessage(MSG_KEY, "final"), }; @@ -207,7 +186,6 @@ public void testFinalInAnonymousClass() @Test public void testFinalInTryWithResource() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "30:14: " + getCheckMessage(MSG_KEY, "final"), "35:14: " + getCheckMessage(MSG_KEY, "final"), @@ -220,7 +198,6 @@ public void testFinalInTryWithResource() throws Exception { @Test public void testFinalInAbstractMethods() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "12:33: " + getCheckMessage(MSG_KEY, "final"), "16:49: " + getCheckMessage(MSG_KEY, "final"), @@ -235,7 +212,6 @@ public void testFinalInAbstractMethods() throws Exception { @Test public void testEnumMethods() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "15:16: " + getCheckMessage(MSG_KEY, "final"), "30:16: " + getCheckMessage(MSG_KEY, "final"), @@ -246,7 +222,6 @@ public void testEnumMethods() throws Exception { @Test public void testEnumStaticMethodsInPublicClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "20:23: " + getCheckMessage(MSG_KEY, "final"), }; @@ -256,7 +231,6 @@ public void testEnumStaticMethodsInPublicClass() throws Exception { @Test public void testAnnotationOnEnumConstructor() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY, "private"), }; @@ -267,7 +241,6 @@ public void testAnnotationOnEnumConstructor() throws Exception { @Test public void testPrivateMethodInPrivateClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "13:17: " + getCheckMessage(MSG_KEY, "final"), }; @@ -278,7 +251,6 @@ public void testPrivateMethodInPrivateClass() throws Exception { @Test public void testTryWithResourcesBlock() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RedundantModifierCheck.class); final String[] expected = { "18:19: " + getCheckMessage(MSG_KEY, "final"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheckTest.java index 52b6ba21d69..b4fc8d1104f 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheckTest.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport { @@ -36,8 +35,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); final int expectedCapitalCount = 4; final String[] expected = { @@ -57,12 +54,6 @@ public void testDefault() throws Exception { @Test public void testTypeNamesForThreePermittedCapitalLetters() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "3"); - checkConfig.addProperty("allowedAbbreviations", "III"); - checkConfig.addProperty("tokens", "CLASS_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 4; final String[] expected = { @@ -78,12 +69,6 @@ public void testTypeNamesForThreePermittedCapitalLetters() throws Exception { @Test public void testTypeNamesForFourPermittedCapitalLetters() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "4"); - checkConfig.addProperty("allowedAbbreviations", "CLASS, FACTORY"); - checkConfig.addProperty("tokens", "CLASS_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 5; final String[] expected = { @@ -96,12 +81,6 @@ public void testTypeNamesForFourPermittedCapitalLetters() throws Exception { @Test public void testTypeNamesForFivePermittedCapitalLetters() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "5"); - checkConfig.addProperty("allowedAbbreviations", "CLASS"); - checkConfig.addProperty("tokens", "CLASS_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 6; final String[] expected = { "45:11: " + getWarningMessage("AbstractINNERRClass", expectedCapitalCount), @@ -114,15 +93,6 @@ public void testTypeNamesForFivePermittedCapitalLetters() throws Exception { @Test public void testTypeAndVariablesAndMethodNames() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "5"); - checkConfig.addProperty("allowedAbbreviations", "CLASS"); - checkConfig.addProperty("tokens", "CLASS_DEF" - + ", VARIABLE_DEF" - + ", METHOD_DEF, ENUM_DEF, ENUM_CONSTANT_DEF" - + ", PARAMETER_DEF, INTERFACE_DEF, ANNOTATION_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 6; final String[] expected = { @@ -139,18 +109,6 @@ public void testTypeAndVariablesAndMethodNames() throws Exception { @Test public void testTypeAndVariablesAndMethodNamesWithNoIgnores() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "5"); - checkConfig.addProperty("allowedAbbreviations", "NUMBER, MARAZMATIC, VARIABLE"); - checkConfig.addProperty("ignoreStatic", "false"); - checkConfig.addProperty("ignoreFinal", "false"); - checkConfig.addProperty("ignoreStaticFinal", "false"); - checkConfig.addProperty("tokens", "CLASS_DEF" - + ", VARIABLE_DEF" - + ", METHOD_DEF, ENUM_DEF, ENUM_CONSTANT_DEF" - + ", PARAMETER_DEF, INTERFACE_DEF, ANNOTATION_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 6; final String[] expected = { @@ -172,18 +130,6 @@ public void testTypeAndVariablesAndMethodNamesWithNoIgnores() throws Exception { @Test public void testTypeAndVariablesAndMethodNamesWithIgnores() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "5"); - checkConfig.addProperty("allowedAbbreviations", "NUMBER, MARAZMATIC, VARIABLE"); - checkConfig.addProperty("ignoreStatic", "true"); - checkConfig.addProperty("ignoreFinal", "true"); - checkConfig.addProperty("ignoreStaticFinal", "true"); - checkConfig.addProperty("tokens", "CLASS_DEF" - + ", VARIABLE_DEF" - + ", METHOD_DEF, ENUM_DEF, ENUM_CONSTANT_DEF" - + ", PARAMETER_DEF, INTERFACE_DEF, ANNOTATION_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 6; final String[] expected = { @@ -201,18 +147,6 @@ public void testTypeAndVariablesAndMethodNamesWithIgnores() throws Exception { @Test public void testTypeAndVariablesAndMethodNamesWithIgnoresFinal() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "4"); - checkConfig.addProperty("allowedAbbreviations", "MARAZMATIC, VARIABLE"); - checkConfig.addProperty("ignoreStatic", "false"); - checkConfig.addProperty("ignoreFinal", "true"); - checkConfig.addProperty("ignoreStaticFinal", "true"); - checkConfig.addProperty("tokens", "CLASS_DEF" - + ", VARIABLE_DEF" - + ", METHOD_DEF, ENUM_DEF, ENUM_CONSTANT_DEF" - + ", PARAMETER_DEF, INTERFACE_DEF, ANNOTATION_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 5; final String[] expected = { @@ -233,18 +167,6 @@ public void testTypeAndVariablesAndMethodNamesWithIgnoresFinal() throws Exceptio @Test public void testTypeAndVariablesAndMethodNamesWithIgnoresStatic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "4"); - checkConfig.addProperty("allowedAbbreviations", "MARAZMATIC, VARIABLE"); - checkConfig.addProperty("ignoreStatic", "true"); - checkConfig.addProperty("ignoreFinal", "false"); - checkConfig.addProperty("ignoreStaticFinal", "true"); - checkConfig.addProperty("tokens", "CLASS_DEF" - + ", VARIABLE_DEF" - + ", METHOD_DEF, ENUM_DEF, ENUM_CONSTANT_DEF" - + ", PARAMETER_DEF, INTERFACE_DEF, ANNOTATION_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 5; final String[] expected = { @@ -265,18 +187,6 @@ public void testTypeAndVariablesAndMethodNamesWithIgnoresStatic() throws Excepti @Test public void testTypeAndVariablesAndMethodNamesWithIgnoresStaticFinal() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "4"); - checkConfig.addProperty("allowedAbbreviations", "MARAZMATIC, VARIABLE"); - checkConfig.addProperty("ignoreStatic", "false"); - checkConfig.addProperty("ignoreFinal", "false"); - checkConfig.addProperty("ignoreStaticFinal", "true"); - checkConfig.addProperty("tokens", "CLASS_DEF" - + ", VARIABLE_DEF" - + ", METHOD_DEF, ENUM_DEF, ENUM_CONSTANT_DEF" - + ", PARAMETER_DEF, INTERFACE_DEF, ANNOTATION_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 5; final String[] expected = { @@ -299,18 +209,6 @@ public void testTypeAndVariablesAndMethodNamesWithIgnoresStaticFinal() throws Ex @Test public void testTypeAndVariablesAndMethodNamesWithIgnoresNonStaticFinal() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "4"); - checkConfig.addProperty("allowedAbbreviations", "MARAZMATIC, VARIABLE"); - checkConfig.addProperty("ignoreStatic", "true"); - checkConfig.addProperty("ignoreFinal", "true"); - checkConfig.addProperty("ignoreStaticFinal", "false"); - checkConfig.addProperty("tokens", "CLASS_DEF" - + ", VARIABLE_DEF" - + ", METHOD_DEF, ENUM_DEF, ENUM_CONSTANT_DEF" - + ", PARAMETER_DEF, INTERFACE_DEF, ANNOTATION_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 5; final String[] expected = { @@ -351,18 +249,6 @@ public void testTypeAndVariablesAndMethodNamesWithIgnoresNonStaticFinal() throws @Test public void testTypeAndVariablesAndMethodNamesWithIgnoresFinalKeepStaticFinal() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "4"); - checkConfig.addProperty("allowedAbbreviations", "MARAZMATIC, VARIABLE"); - checkConfig.addProperty("ignoreStatic", "false"); - checkConfig.addProperty("ignoreFinal", "true"); - checkConfig.addProperty("ignoreStaticFinal", "false"); - checkConfig.addProperty("tokens", "CLASS_DEF" - + ", VARIABLE_DEF" - + ", METHOD_DEF, ENUM_DEF, ENUM_CONSTANT_DEF" - + ", PARAMETER_DEF, INTERFACE_DEF, ANNOTATION_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 5; final String[] expected = { @@ -394,18 +280,6 @@ public void testTypeAndVariablesAndMethodNamesWithIgnoresFinalKeepStaticFinal() @Test public void testTypeAndVariablesAndMethodNamesWithIgnoresStaticKeepStaticFinal() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "4"); - checkConfig.addProperty("allowedAbbreviations", "MARAZMATIC, VARIABLE"); - checkConfig.addProperty("ignoreStatic", "true"); - checkConfig.addProperty("ignoreFinal", "false"); - checkConfig.addProperty("ignoreStaticFinal", "false"); - checkConfig.addProperty("tokens", "CLASS_DEF" - + ", VARIABLE_DEF" - + ", METHOD_DEF, ENUM_DEF, ENUM_CONSTANT_DEF" - + ", PARAMETER_DEF, INTERFACE_DEF, ANNOTATION_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 5; final String[] expected = { @@ -437,12 +311,6 @@ public void testTypeAndVariablesAndMethodNamesWithIgnoresStaticKeepStaticFinal() @Test public void testTypeNamesForThreePermittedCapitalLettersWithOverriddenMethod() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "3"); - checkConfig.addProperty("allowedAbbreviations", ""); - checkConfig.addProperty("tokens", "CLASS_DEF, METHOD_DEF"); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final int expectedCapitalCount = 4; final String[] expected = { @@ -456,9 +324,6 @@ public void testTypeNamesForThreePermittedCapitalLettersWithOverriddenMethod() @Test public void testOverriddenMethod() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("ignoreOverriddenMethods", "false"); final int expectedCapitalCount = 4; final String[] expected = { @@ -474,18 +339,6 @@ public void testOverriddenMethod() @Test public void testTypeNamesForZeroPermittedCapitalLetter() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", - "0"); - checkConfig.addProperty("allowedAbbreviations", ""); - checkConfig.addProperty("ignoreStatic", "false"); - checkConfig.addProperty("ignoreFinal", "false"); - checkConfig.addProperty("ignoreStaticFinal", "false"); - checkConfig.addProperty("ignoreOverriddenMethods", "false"); - checkConfig.addProperty("tokens", "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, " - + "ANNOTATION_DEF, ANNOTATION_FIELD_DEF, ENUM_CONSTANT_DEF, " - + "PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF"); final int expectedCapitalCount = 1; final String[] expected = { "20:16: " + getWarningMessage("NonAAAAbstractClassName6", expectedCapitalCount), @@ -523,11 +376,6 @@ public void testTypeNamesForZeroPermittedCapitalLetter() throws Exception { @Test public void testNullPointerException() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviationLength", "2"); - checkConfig.addProperty("ignoreFinal", "false"); - checkConfig.addProperty("allowedAbbreviations", null); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -539,8 +387,6 @@ public void testNullPointerException() throws Exception { @Test public void testAbbreviationAsWordInNameCheckEnhancedInstanceof() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); final int expectedCapitalCount = 4; @@ -560,10 +406,6 @@ public void testAbbreviationAsWordInNameCheckEnhancedInstanceof() @Test public void testAbbreviationAsWordInNameCheckEnhancedInstanceofAllowXmlLength1() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); - checkConfig.addProperty("allowedAbbreviations", "XML"); - checkConfig.addProperty("allowedAbbreviationLength", "1"); final int expectedCapitalCount = 2; @@ -585,8 +427,6 @@ public void testAbbreviationAsWordInNameCheckEnhancedInstanceofAllowXmlLength1() @Test public void testAbbreviationAsWordInNameCheckRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); final int expectedCapitalCount = 4; @@ -620,8 +460,6 @@ private String getWarningMessage(String typeName, int expectedCapitalCount) { @Test public void testReceiver() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbbreviationAsWordInNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java index c1323717fbf..9ec4ce35017 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java @@ -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 AbstractClassNameCheckTest extends AbstractModuleTestSupport { @@ -38,10 +37,6 @@ protected String getPackageLocation() { @Test public void testIllegalAbstractClassName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbstractClassNameCheck.class); - checkConfig.addProperty("ignoreName", "false"); - checkConfig.addProperty("ignoreModifier", "true"); final String pattern = "^Abstract.+$"; @@ -60,11 +55,6 @@ public void testIllegalAbstractClassName() throws Exception { @Test public void testCustomFormat() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AbstractClassNameCheck.class); - checkConfig.addProperty("ignoreName", "false"); - checkConfig.addProperty("ignoreModifier", "true"); - checkConfig.addProperty("format", "^NonAbstract.+$"); final String[] expected = { "12:1: " @@ -82,9 +72,6 @@ public void testCustomFormat() throws Exception { @Test public void testIllegalClassType() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AbstractClassNameCheck.class); - checkConfig.addProperty("ignoreName", "true"); - checkConfig.addProperty("ignoreModifier", "false"); final String[] expected = { "18:1: " + getCheckMessage(MSG_NO_ABSTRACT_CLASS_MODIFIER, "AbstractClassType"), @@ -97,9 +84,6 @@ public void testIllegalClassType() throws Exception { @Test public void testAllVariants() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AbstractClassNameCheck.class); - checkConfig.addProperty("ignoreName", "false"); - checkConfig.addProperty("ignoreModifier", "false"); final String pattern = "^Abstract.+$"; @@ -121,7 +105,6 @@ public void testAllVariants() throws Exception { @Test public void testFalsePositive() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(AbstractClassNameCheck.class); final String pattern = "^Abstract.+$"; final String[] expected = { "12:1: " diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheckTest.java index 6a89a2548b3..6930029875f 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheckTest.java @@ -25,8 +25,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.Configuration; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -50,7 +48,6 @@ public void testTokens() { @Test public void testDefaultConfigurationOnCorrectFile() throws Exception { - final Configuration checkConfig = createModuleConfig(CatchParameterNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -59,7 +56,6 @@ public void testDefaultConfigurationOnCorrectFile() throws Exception { @Test public void testDefaultConfigurationOnFileWithViolations() throws Exception { - final Configuration checkConfig = createModuleConfig(CatchParameterNameCheck.class); final String defaultFormat = "^(e|t|ex|[a-z][a-z][a-zA-Z]+)$"; final String[] expected = { @@ -79,8 +75,6 @@ public void testDefaultConfigurationOnFileWithViolations() throws Exception { @Test public void testCustomFormatFromJavadoc() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(CatchParameterNameCheck.class); - checkConfig.addProperty("format", "^[a-z][a-zA-Z0-9]+$"); final String[] expected = { "13:28: " + getCheckMessage(MSG_INVALID_PATTERN, "e", "^[a-z][a-zA-Z0-9]+$"), @@ -93,8 +87,6 @@ public void testCustomFormatFromJavadoc() throws Exception { @Test public void testCustomFormatWithNoAnchors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(CatchParameterNameCheck.class); - checkConfig.addProperty("format", "[a-z]"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheckTest.java index 650945b1a0b..96c408c4ed4 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheckTest.java @@ -25,7 +25,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 ClassTypeParameterNameCheckTest @@ -48,8 +47,6 @@ public void testGetClassRequiredTokens() { @Test public void testClassDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassTypeParameterNameCheck.class); final String pattern = "^[A-Z]$"; @@ -65,9 +62,6 @@ public void testClassDefault() @Test public void testClassFooName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ClassTypeParameterNameCheck.class); - checkConfig.addProperty("format", "^foo$"); final String pattern = "^foo$"; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheckTest.java index aa873ba9f22..715177305f5 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheckTest.java @@ -71,8 +71,6 @@ public void testIllegalRegexp() @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ConstantNameCheck.class); final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @@ -87,11 +85,6 @@ public void testDefault() @Test public void testAccessControlTuning() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ConstantNameCheck.class); - checkConfig.addProperty("applyToPublic", "false"); - checkConfig.addProperty("applyToProtected", "false"); - checkConfig.addProperty("applyToPackage", "false"); final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @@ -105,8 +98,6 @@ public void testAccessControlTuning() @Test public void testInterfaceAndAnnotation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ConstantNameCheck.class); final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @@ -121,8 +112,6 @@ public void testInterfaceAndAnnotation() @Test public void testDefault1() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ConstantNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputConstantName.java"), expected); @@ -130,8 +119,6 @@ public void testDefault1() @Test public void testIntoInterface() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ConstantNameCheck.class); final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @@ -151,9 +138,6 @@ public void testIntoInterface() throws Exception { @Test public void testIntoInterfaceExcludePublic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ConstantNameCheck.class); - checkConfig.addProperty("applyToPublic", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -163,8 +147,6 @@ public void testIntoInterfaceExcludePublic() throws Exception { @Test public void testStaticMethodInInterface() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ConstantNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputConstantNameStaticModifierInInterface.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/IllegalIdentifierNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/IllegalIdentifierNameCheckTest.java index ce98d6217e3..101e85847b0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/IllegalIdentifierNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/IllegalIdentifierNameCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -72,8 +71,6 @@ public void testGetRequiredTokens() { @Test public void testIllegalIdentifierNameDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalIdentifierNameCheck.class); final String format = "(?i)^(?!(record|yield|var|permits|sealed|_)$).+$"; @@ -98,11 +95,6 @@ public void testIllegalIdentifierNameDefault() throws Exception { @Test public void testIllegalIdentifierNameOpenTransitive() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalIdentifierNameCheck.class); - checkConfig.addProperty("format", - "(?i)^(?!(record|yield|var|permits|sealed|open|transitive)$).+$"); - final String format = "(?i)^(?!(record|yield|var|permits|sealed|open|transitive)$).+$"; final String[] expected = { @@ -127,8 +119,6 @@ public void testIllegalIdentifierNameOpenTransitive() throws Exception { @Test public void testIllegalIdentifierNameParameterReceiver() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalIdentifierNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -139,8 +129,6 @@ public void testIllegalIdentifierNameParameterReceiver() throws Exception { @Test public void testIllegalIdentifierNameUnderscore() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalIdentifierNameCheck.class); final String format = "(?i)^(?!(record|yield|var|permits|sealed|_)$).+$"; final String[] expected = { @@ -152,8 +140,6 @@ public void testIllegalIdentifierNameUnderscore() throws Exception { @Test public void testIllegalIdentifierNameLambda() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(IllegalIdentifierNameCheck.class); final String format = "(?i)^(?!(record|yield|var|permits|sealed|_)$).+$"; final String[] expected = { diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheckTest.java index 3a7c5eded33..8dbddb33c36 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheckTest.java @@ -25,7 +25,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 InterfaceTypeParameterNameCheckTest @@ -58,8 +57,6 @@ public void testGetRequiredTokens() { @Test public void testInterfaceDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceTypeParameterNameCheck.class); final String pattern = "^[A-Z]$"; @@ -73,9 +70,6 @@ public void testInterfaceDefault() @Test public void testInterfaceFooName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(InterfaceTypeParameterNameCheck.class); - checkConfig.addProperty("format", "^foo$"); final String pattern = "^foo$"; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheckTest.java index 02bb700e054..9358c0b5d29 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheckTest.java @@ -25,7 +25,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 LambdaParameterNameCheckTest extends AbstractModuleTestSupport { @@ -59,10 +58,6 @@ public void testAcceptableTokens() { @Test public void testParametersInLambda() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LambdaParameterNameCheck.class); - - checkConfig.addProperty("format", "^(id)|([a-z][a-z0-9][a-zA-Z0-9]+)$"); final String pattern = "^(id)|([a-z][a-z0-9][a-zA-Z0-9]+)$"; @@ -79,8 +74,6 @@ public void testParametersInLambda() throws Exception { @Test public void testLambdaParameterNameSwitchExpression() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LambdaParameterNameCheck.class); final String pattern = "^[a-z][a-zA-Z0-9]*$"; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckTest.java index cd76531079c..8f5d782cdc7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -48,8 +47,6 @@ public void testGetRequiredTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LocalFinalVariableNameCheck.class); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -63,9 +60,6 @@ public void testDefault() @Test public void testSet() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LocalFinalVariableNameCheck.class); - checkConfig.addProperty("format", "[A-Z]+"); final String pattern = "[A-Z]+"; @@ -79,8 +73,6 @@ public void testSet() @Test public void testInnerClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LocalFinalVariableNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputLocalFinalVariableNameInnerClass.java"), expected); @@ -101,9 +93,6 @@ public void testGetAcceptableTokens() { @Test public void testTryWithResources() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LocalFinalVariableNameCheck.class); - checkConfig.addProperty("format", "[A-Z]+"); final String pattern = "[A-Z]+"; @@ -120,9 +109,6 @@ public void testTryWithResources() throws Exception { @Test public void testTryWithResourcesJava9() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LocalFinalVariableNameCheck.class); - checkConfig.addProperty("format", "[a-z]+"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheckTest.java index 773ecf53744..6ac6d64cb72 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -49,8 +48,6 @@ public void testGetAcceptableTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LocalVariableNameCheck.class); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -67,8 +64,6 @@ public void testDefault() @Test public void testInnerClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LocalVariableNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputLocalVariableNameInnerClass.java"), expected); @@ -77,10 +72,6 @@ public void testInnerClass() @Test public void testLoopVariables() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LocalVariableNameCheck.class); - checkConfig.addProperty("format", "^[a-z]{2,}[a-zA-Z0-9]*$"); - checkConfig.addProperty("allowOneCharVarInForLoop", "true"); final String pattern = "^[a-z]{2,}[a-zA-Z0-9]*$"; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckTest.java index c9cb6d5f3d3..a41bf6306e9 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckTest.java @@ -25,7 +25,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 MemberNameCheckTest @@ -47,9 +46,6 @@ public void testGetRequiredTokens() { @Test public void testSpecified() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); - checkConfig.addProperty("format", "^m[A-Z][a-zA-Z0-9]*$"); final String pattern = "^m[A-Z][a-zA-Z0-9]*$"; @@ -64,8 +60,6 @@ public void testSpecified() @Test public void testInnerClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -78,8 +72,6 @@ public void testInnerClass() @Test public void testDefaults() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -95,9 +87,6 @@ public void testDefaults() throws Exception { @Test public void testUnderlined() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); - checkConfig.addProperty("format", "^_[a-z]*$"); final String pattern = "^_[a-z]*$"; @@ -113,12 +102,6 @@ public void testUnderlined() throws Exception { @Test public void testPublicOnly() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); - checkConfig.addProperty("format", "^_[a-z]*$"); - checkConfig.addProperty("applyToProtected", "false"); - checkConfig.addProperty("applyToPackage", "false"); - checkConfig.addProperty("applyToPrivate", "false"); final String pattern = "^_[a-z]*$"; @@ -131,12 +114,6 @@ public void testPublicOnly() throws Exception { @Test public void testProtectedOnly() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); - checkConfig.addProperty("format", "^_[a-z]*$"); - checkConfig.addProperty("applyToPublic", "false"); - checkConfig.addProperty("applyToPackage", "false"); - checkConfig.addProperty("applyToPrivate", "false"); final String pattern = "^_[a-z]*$"; @@ -149,12 +126,6 @@ public void testProtectedOnly() throws Exception { @Test public void testPackageOnly() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); - checkConfig.addProperty("format", "^_[a-z]*$"); - checkConfig.addProperty("applyToPublic", "false"); - checkConfig.addProperty("applyToProtected", "false"); - checkConfig.addProperty("applyToPrivate", "false"); final String pattern = "^_[a-z]*$"; @@ -167,12 +138,6 @@ public void testPackageOnly() throws Exception { @Test public void testPrivateOnly() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); - checkConfig.addProperty("format", "^_[a-z]*$"); - checkConfig.addProperty("applyToPublic", "false"); - checkConfig.addProperty("applyToProtected", "false"); - checkConfig.addProperty("applyToPackage", "false"); final String pattern = "^_[a-z]*$"; @@ -185,9 +150,6 @@ public void testPrivateOnly() throws Exception { @Test public void testNotPrivate() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); - checkConfig.addProperty("applyToPrivate", "false"); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -202,9 +164,6 @@ public void testNotPrivate() throws Exception { @Test public void memberNameExtended() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); - checkConfig.addProperty("format", "^[a-z][a-z0-9][a-zA-Z0-9]*$"); final String pattern = "^[a-z][a-z0-9][a-zA-Z0-9]*$"; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckTest.java index 77c67d38646..1554338c8b7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckTest.java @@ -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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -49,8 +48,6 @@ public void testGetRequiredTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodNameCheck.class); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -63,8 +60,6 @@ public void testDefault() @Test public void testMethodEqClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodNameCheck.class); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -93,12 +88,6 @@ public void testMethodEqClass() throws Exception { @Test public void testMethodEqClassAllow() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodNameCheck.class); - - // allow method names and class names to equal - checkConfig.addProperty("allowClassName", "true"); - final String pattern = "^[a-z][a-zA-Z0-9]*$"; final String[] expected = { @@ -121,15 +110,6 @@ public void testMethodEqClassAllow() throws Exception { @Test public void testAccessTuning() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodNameCheck.class); - - // allow method names and class names to equal - checkConfig.addProperty("allowClassName", "true"); - - // allow method names and class names to equal - checkConfig.addProperty("applyToPrivate", "false"); - final String pattern = "^[a-z][a-zA-Z0-9]*$"; final String[] expected = { @@ -150,8 +130,6 @@ public void testAccessTuning() throws Exception { @Test public void testForNpe() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -161,8 +139,6 @@ public void testForNpe() throws Exception { @Test public void testOverriddenMethods() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodNameCheck.class); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -177,9 +153,6 @@ public void testOverriddenMethods() throws Exception { @Test public void testInterfacesExcludePublic() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodNameCheck.class); - checkConfig.addProperty("applyToPublic", "false"); final String pattern = "^[a-z][a-zA-Z0-9]*$"; final String[] expected = { @@ -194,9 +167,6 @@ public void testInterfacesExcludePublic() throws Exception { @Test public void testInterfacesExcludePrivate() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodNameCheck.class); - checkConfig.addProperty("applyToPrivate", "false"); final String pattern = "^[a-z][a-zA-Z0-9]*$"; final String[] expected = { diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodTypeParameterNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodTypeParameterNameCheckTest.java index 8a7c209144a..1ca2928a0e1 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodTypeParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodTypeParameterNameCheckTest.java @@ -25,7 +25,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 MethodTypeParameterNameCheckTest @@ -58,8 +57,6 @@ public void testGetRequiredTokens() { @Test public void testMethodDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodTypeParameterNameCheck.class); final String pattern = "^[A-Z]$"; @@ -77,9 +74,6 @@ public void testMethodDefault() @Test public void testMethodFooName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodTypeParameterNameCheck.class); - checkConfig.addProperty("format", "^foo$"); final String pattern = "^foo$"; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckTest.java index 3eabcf44237..da231377e5a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -48,9 +47,6 @@ public void testGetRequiredTokens() { @Test public void testSpecified() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(PackageNameCheck.class); - checkConfig.addProperty("format", "[A-Z]+"); final String pattern = "[A-Z]+"; @@ -65,8 +61,6 @@ public void testSpecified() @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(PackageNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputPackageNameSimple.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java index a7d4cb37681..83d6ce829e4 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -48,9 +47,6 @@ public void testGetRequiredTokens() { @Test public void testCatch() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNameCheck.class); - checkConfig.addProperty("format", "^NO_WAY_MATEY$"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputParameterNameCatchOnly.java"), expected); @@ -59,9 +55,6 @@ public void testCatch() @Test public void testSpecified() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNameCheck.class); - checkConfig.addProperty("format", "^a[A-Z][a-zA-Z0-9]*$"); final String pattern = "^a[A-Z][a-zA-Z0-9]*$"; @@ -77,8 +70,6 @@ public void testSpecified() @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputParameterName.java"), expected); @@ -97,10 +88,6 @@ public void testGetAcceptableTokens() { @Test public void testSkipMethodsWithOverrideAnnotationTrue() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNameCheck.class); - checkConfig.addProperty("format", "^h$"); - checkConfig.addProperty("ignoreOverridden", "true"); final String pattern = "^h$"; @@ -120,10 +107,6 @@ public void testSkipMethodsWithOverrideAnnotationTrue() @Test public void testSkipMethodsWithOverrideAnnotationFalse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNameCheck.class); - checkConfig.addProperty("format", "^h$"); - checkConfig.addProperty("ignoreOverridden", "false"); final String pattern = "^h$"; @@ -144,10 +127,6 @@ public void testSkipMethodsWithOverrideAnnotationFalse() @Test public void testPublicAccessModifier() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNameCheck.class); - checkConfig.addProperty("format", "^h$"); - checkConfig.addProperty("accessModifiers", AccessModifierOption.PUBLIC.toString()); final String pattern = "^h$"; @@ -166,9 +145,6 @@ public void testPublicAccessModifier() @Test public void testIsOverriddenNoNullPointerException() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParameterNameCheck.class); - checkConfig.addProperty("format", "^[a-z][a-zA-Z0-9]*$"); - checkConfig.addProperty("ignoreOverridden", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputParameterNameOverrideAnnotationNoNPE.java"), expected); @@ -176,7 +152,6 @@ public void testIsOverriddenNoNullPointerException() @Test public void testReceiverParameter() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParameterNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputParameterNameReceiver.java"), expected); @@ -184,7 +159,6 @@ public void testReceiverParameter() throws Exception { @Test public void testLambdaParameterNoViolationAtAll() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParameterNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputParameterNameLambda.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PatternVariableNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PatternVariableNameCheckTest.java index 220f70c8383..356c714bc05 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PatternVariableNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PatternVariableNameCheckTest.java @@ -25,7 +25,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 PatternVariableNameCheckTest @@ -47,8 +46,6 @@ public void testGetAcceptableTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(PatternVariableNameCheck.class); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -71,9 +68,6 @@ public void testDefault() throws Exception { @Test public void testPatternVariableNameNoSingleChar() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(PatternVariableNameCheck.class); - checkConfig.addProperty("format", "^[a-z][a-zA-Z0-9]+$"); final String pattern = "^[a-z][a-zA-Z0-9]+$"; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordComponentNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordComponentNameCheckTest.java index a7539419705..4a49b41bb98 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordComponentNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordComponentNameCheckTest.java @@ -25,7 +25,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 RecordComponentNameCheckTest extends AbstractModuleTestSupport { @@ -47,8 +46,6 @@ public void testGetClassRequiredTokens() { @Test public void testRecordDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RecordComponentNameCheck.class); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -65,9 +62,6 @@ public void testRecordDefault() @Test public void testClassFooName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RecordComponentNameCheck.class); - checkConfig.addProperty("format", "^[a-z0-9]+$"); final String pattern = "^[a-z0-9]+$"; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordTypeParameterNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordTypeParameterNameCheckTest.java index 5acce6bc7bc..ab687a2f3ec 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordTypeParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordTypeParameterNameCheckTest.java @@ -25,7 +25,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 RecordTypeParameterNameCheckTest extends AbstractModuleTestSupport { @@ -47,8 +46,6 @@ public void testGetClassRequiredTokens() { @Test public void testRecordDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RecordTypeParameterNameCheck.class); final String pattern = "^[A-Z]$"; @@ -64,9 +61,6 @@ public void testRecordDefault() @Test public void testClassFooName() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RecordTypeParameterNameCheck.class); - checkConfig.addProperty("format", "^foo$"); final String pattern = "^foo$"; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheckTest.java index c13e3dc2d72..ba2aa040732 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -48,9 +47,6 @@ public void testGetRequiredTokens() { @Test public void testSpecified() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(StaticVariableNameCheck.class); - checkConfig.addProperty("format", "^s[A-Z][a-zA-Z0-9]*$"); final String pattern = "^s[A-Z][a-zA-Z0-9]*$"; @@ -64,13 +60,6 @@ public void testSpecified() @Test public void testAccessTuning() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(StaticVariableNameCheck.class); - checkConfig.addProperty("format", "^s[A-Z][a-zA-Z0-9]*$"); - - // allow method names and class names to equal - checkConfig.addProperty("applyToPrivate", "false"); - final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputStaticVariableName2.java"), expected); @@ -79,8 +68,6 @@ public void testAccessTuning() @Test public void testInterfaceOrAnnotationBlock() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(StaticVariableNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputStaticVariableName.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckTest.java index 862c19dfefe..48ceecedb98 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class TypeNameCheckTest extends AbstractModuleTestSupport { @@ -38,9 +37,6 @@ protected String getPackageLocation() { @Test public void testSpecified() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(TypeNameCheck.class); - checkConfig.addProperty("format", "^inputHe"); final String[] expected = { "25:14: " + getCheckMessage(MSG_INVALID_PATTERN, "InputTypeName", "^inputHe"), @@ -52,8 +48,6 @@ public void testSpecified() @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(TypeNameCheck.class); final String[] expected = { "15:7: " + getCheckMessage(MSG_INVALID_PATTERN, "inputHeaderClass2", DEFAULT_PATTERN), @@ -71,9 +65,6 @@ public void testDefault() @Test public void testClassSpecific() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(TypeNameCheck.class); - checkConfig.addProperty("tokens", "CLASS_DEF"); final String[] expected = { "15:7: " + getCheckMessage(MSG_INVALID_PATTERN, "inputHeaderClass3", DEFAULT_PATTERN), @@ -85,9 +76,6 @@ public void testClassSpecific() @Test public void testInterfaceSpecific() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(TypeNameCheck.class); - checkConfig.addProperty("tokens", "INTERFACE_DEF"); final String[] expected = { "17:22: " + getCheckMessage(MSG_INVALID_PATTERN, "inputHeaderInterface", DEFAULT_PATTERN), @@ -99,9 +87,6 @@ public void testInterfaceSpecific() @Test public void testEnumSpecific() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(TypeNameCheck.class); - checkConfig.addProperty("tokens", "ENUM_DEF"); final String[] expected = { "19:17: " + getCheckMessage(MSG_INVALID_PATTERN, "inputHeaderEnum", DEFAULT_PATTERN), @@ -113,9 +98,6 @@ public void testEnumSpecific() @Test public void testAnnotationSpecific() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(TypeNameCheck.class); - checkConfig.addProperty("tokens", "ANNOTATION_DEF"); final String[] expected = { "21:23: " + getCheckMessage(MSG_INVALID_PATTERN, "inputHeaderAnnotation", DEFAULT_PATTERN), @@ -126,8 +108,6 @@ public void testAnnotationSpecific() @Test public void testTypeNameRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(TypeNameCheck.class); final String[] expected = { "23:10: " + getCheckMessage(MSG_INVALID_PATTERN, "Third_Name", DEFAULT_PATTERN), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheckTest.java index c3e3861bd48..5325c3f8b7a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheckTest.java @@ -53,9 +53,6 @@ public void testGetRequiredTokens() { @Test public void testRequiredPass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "Test case file"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSemantic.java"), expected); @@ -74,10 +71,6 @@ public void testRequiredFail() throws Exception { @Test public void testRequiredNoDuplicatesPass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "Test case file"); - checkConfig.addProperty("duplicateLimit", "0"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSemantic3.java"), expected); @@ -85,9 +78,6 @@ public void testRequiredNoDuplicatesPass() throws Exception { @Test public void testSetDuplicatesTrue() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "Test case file"); - checkConfig.addProperty("duplicateLimit", "-1"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSemantic4.java"), expected); @@ -95,10 +85,6 @@ public void testSetDuplicatesTrue() throws Exception { @Test public void testRequiredNoDuplicatesFail() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "Boolean x = new Boolean"); - checkConfig.addProperty("duplicateLimit", "0"); final String[] expected = { "27: " + getCheckMessage(MSG_DUPLICATE_REGEXP, "Boolean x = new Boolean"), "32: " + getCheckMessage(MSG_DUPLICATE_REGEXP, "Boolean x = new Boolean"), @@ -109,10 +95,6 @@ public void testRequiredNoDuplicatesFail() throws Exception { @Test public void testIllegalPass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "This\\stext is not in the file"); - checkConfig.addProperty("illegalPattern", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSemantic6.java"), expected); @@ -120,11 +102,6 @@ public void testIllegalPass() throws Exception { @Test public void testStopEarly() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "a"); - checkConfig.addProperty("illegalPattern", "false"); - checkConfig.addProperty("duplicateLimit", "-1"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpCheckStopEarly.java"), expected); @@ -132,11 +109,6 @@ public void testStopEarly() throws Exception { @Test public void testIllegalFailBelowErrorLimit() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "^import"); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("errorLimit", "4"); final String[] expected = { "15: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "^import"), "16: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "^import"), @@ -148,11 +120,6 @@ public void testIllegalFailBelowErrorLimit() throws Exception { @Test public void testIllegalFailAboveErrorLimit() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "^import"); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("errorLimit", "2"); final String error = "The error limit has been exceeded, " + "the check is aborting, there may be more unreported errors."; final String[] expected = { @@ -166,11 +133,6 @@ public void testIllegalFailAboveErrorLimit() throws Exception { @Test public void testMessagePropertyGood() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "System\\.(out)|(err)\\.print(ln)?\\("); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("message", "Bad line :("); final String[] expected = { "77: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "Bad line :("), }; @@ -181,11 +143,6 @@ public void testMessagePropertyGood() @Test public void testMessagePropertyBad() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "System\\.(out)|(err)\\.print(ln)?\\("); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("message", null); final String[] expected = { "77: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("), }; @@ -196,11 +153,6 @@ public void testMessagePropertyBad() @Test public void testMessagePropertyBad2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "System\\.(out)|(err)\\.print(ln)?\\("); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("message", ""); final String[] expected = { "77: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("), }; @@ -210,10 +162,6 @@ public void testMessagePropertyBad2() @Test public void testIgnoreCaseTrue() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "(?i)SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("); - checkConfig.addProperty("illegalPattern", "true"); final String[] expected = { "77: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "(?i)SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("), @@ -224,10 +172,6 @@ public void testIgnoreCaseTrue() throws Exception { @Test public void testIgnoreCaseFalse() throws Exception { - final DefaultConfiguration checkConfigTrue = - createModuleConfig(RegexpCheck.class); - checkConfigTrue.addProperty("format", "(?i)SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("); - checkConfigTrue.addProperty("illegalPattern", "true"); final String[] expectedTrue = { "77: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "(?i)SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("), @@ -235,10 +179,6 @@ public void testIgnoreCaseFalse() throws Exception { verifyWithInlineConfigParser( getPath("InputRegexpSemantic13.java"), expectedTrue); - final DefaultConfiguration checkConfigFalse = - createModuleConfig(RegexpCheck.class); - checkConfigFalse.addProperty("format", "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("); - checkConfigFalse.addProperty("illegalPattern", "true"); final String[] expectedFalse = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSemantic14.java"), expectedFalse); @@ -247,11 +187,6 @@ public void testIgnoreCaseFalse() throws Exception { @Test public void testIgnoreCommentsCppStyle() throws Exception { // See if the comment is removed properly - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "don't use trailing comments"); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpTrailingComment.java"), expected); @@ -260,11 +195,6 @@ public void testIgnoreCommentsCppStyle() throws Exception { @Test public void testIgnoreCommentsFalseCppStyle() throws Exception { // See if the comment is removed properly - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "don't\\suse trailing comments"); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("ignoreComments", "false"); final String[] expected = { "16: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "don't\\suse trailing comments"), }; @@ -275,11 +205,6 @@ public void testIgnoreCommentsFalseCppStyle() throws Exception { @Test public void testIgnoreCommentsBlockStyle() throws Exception { // See if the comment is removed properly - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "c-style 1"); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpTrailingComment3.java"), expected); @@ -287,11 +212,6 @@ public void testIgnoreCommentsBlockStyle() throws Exception { @Test public void testIgnoreCommentsFalseBlockStyle() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "c-style\\s1"); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("ignoreComments", "false"); final String[] expected = { "31: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "c-style\\s1"), }; @@ -302,11 +222,6 @@ public void testIgnoreCommentsFalseBlockStyle() throws Exception { @Test public void testIgnoreCommentsMultipleBlockStyle() throws Exception { // See if a second comment on the same line is removed properly - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "c-style 2"); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpTrailingComment5.java"), expected); @@ -314,11 +229,6 @@ public void testIgnoreCommentsMultipleBlockStyle() throws Exception { @Test public void testIgnoreCommentsMultiLine() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "Let's check multi-line comments"); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpTrailingComment6.java"), expected); @@ -326,11 +236,6 @@ public void testIgnoreCommentsMultiLine() throws Exception { @Test public void testIgnoreCommentsInlineStart() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "long ms /"); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpTrailingComment7.java"), expected); @@ -338,11 +243,6 @@ public void testIgnoreCommentsInlineStart() throws Exception { @Test public void testIgnoreCommentsInlineEnd() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "int z"); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = { "34: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "int z"), }; @@ -352,11 +252,6 @@ public void testIgnoreCommentsInlineEnd() throws Exception { @Test public void testIgnoreCommentsInlineMiddle() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "int y"); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = { "35: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "int y"), }; @@ -367,11 +262,6 @@ public void testIgnoreCommentsInlineMiddle() throws Exception { @Test public void testIgnoreCommentsNoSpaces() throws Exception { // make sure the comment is not turned into spaces - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpCheck.class); - checkConfig.addProperty("format", "long ms "); - checkConfig.addProperty("illegalPattern", "true"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpTrailingComment10.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java index 92ba3db0179..58551356a45 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java @@ -50,8 +50,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); - checkConfig.addProperty("format", "System\\.(out)|(err)\\.print(ln)?\\("); final String[] expected = { "78: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "System\\.(out)|(err)\\.print(ln)?\\("), }; @@ -62,9 +60,6 @@ public void testIt() throws Exception { @Test public void testMessageProperty() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); - checkConfig.addProperty("format", "System\\.(out)|(err)\\.print(ln)?\\("); - checkConfig.addProperty("message", "Bad line :("); final String[] expected = { "79: " + "Bad line :(", }; @@ -74,9 +69,6 @@ public void testMessageProperty() @Test public void testIgnoreCaseTrue() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); - checkConfig.addProperty("format", "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("); - checkConfig.addProperty("ignoreCase", "true"); final String[] expected = { "79: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("), }; @@ -86,9 +78,6 @@ public void testIgnoreCaseTrue() throws Exception { @Test public void testIgnoreCaseFalse() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); - checkConfig.addProperty("format", "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("); - checkConfig.addProperty("ignoreCase", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpMultilineSemantic4.java"), expected); @@ -96,8 +85,6 @@ public void testIgnoreCaseFalse() throws Exception { @Test public void testIllegalFailBelowErrorLimit() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); - checkConfig.addProperty("format", "^import"); final String[] expected = { "16: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "^import"), "17: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "^import"), @@ -167,7 +154,6 @@ public void testStateIsBeingReset() throws Exception { @Test public void testDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpMultilineSemantic6.java"), expected); @@ -175,8 +161,6 @@ public void testDefaultConfiguration() throws Exception { @Test public void testNullFormat() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); - checkConfig.addProperty("format", null); final String[] expected = { "1: " + getCheckMessage(MSG_EMPTY), }; @@ -186,8 +170,6 @@ public void testNullFormat() throws Exception { @Test public void testEmptyFormat() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); - checkConfig.addProperty("format", ""); final String[] expected = { "1: " + getCheckMessage(MSG_EMPTY), }; @@ -255,9 +237,6 @@ private static CharSequence makeLargeXyString() { @Test public void testGoodLimit() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); - checkConfig.addProperty("format", "^import"); - checkConfig.addProperty("maximum", "5000"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpMultilineSemantic9.java"), expected); @@ -265,9 +244,6 @@ public void testGoodLimit() throws Exception { @Test public void testMultilineSupport() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); - checkConfig.addProperty("format", "(a)bc.*def"); - checkConfig.addProperty("matchAcrossLines", "true"); final String[] expected = { "22: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "(a)bc.*def"), }; @@ -277,9 +253,6 @@ public void testMultilineSupport() throws Exception { @Test public void testMultilineSupportNotGreedy() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); - checkConfig.addProperty("format", "(a)bc.*?def"); - checkConfig.addProperty("matchAcrossLines", "true"); final String[] expected = { "22: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "(a)bc.*?def"), "24: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "(a)bc.*?def"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineCheckTest.java index 7647c253744..aaab29dd820 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineCheckTest.java @@ -29,7 +29,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.FileText; import com.puppycrawl.tools.checkstyle.internal.testmodules.TestLoggingReporter; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -45,8 +44,6 @@ protected String getPackageLocation() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpSinglelineCheck.class); - checkConfig.addProperty("format", "System\\.(out)|(err)\\.print(ln)?\\("); final String[] expected = { "77: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "System\\.(out)|(err)\\.print(ln)?\\("), }; @@ -57,9 +54,6 @@ public void testIt() throws Exception { @Test public void testMessageProperty() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpSinglelineCheck.class); - checkConfig.addProperty("format", "System\\.(out)|(err)\\.print(ln)?\\("); - checkConfig.addProperty("message", "Bad line :("); final String[] expected = { "78: Bad line :(", }; @@ -69,10 +63,6 @@ public void testMessageProperty() @Test public void testIgnoreCaseTrue() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpSinglelineCheck.class); - checkConfig.addProperty("format", "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("); - checkConfig.addProperty("ignoreCase", "true"); - checkConfig.addProperty("maximum", "0"); final String[] expected = { "78: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("), @@ -83,9 +73,6 @@ public void testIgnoreCaseTrue() throws Exception { @Test public void testIgnoreCaseFalse() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpSinglelineCheck.class); - checkConfig.addProperty("format", "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("); - checkConfig.addProperty("ignoreCase", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineSemantic4.java"), expected); @@ -93,9 +80,6 @@ public void testIgnoreCaseFalse() throws Exception { @Test public void testMinimum() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpSinglelineCheck.class); - checkConfig.addProperty("format", "\\r"); - checkConfig.addProperty("minimum", "500"); final String[] expected = { "1: " + getCheckMessage(MSG_REGEXP_MINIMUM, "500", "\\r"), }; @@ -106,10 +90,6 @@ public void testMinimum() throws Exception { @Test public void testSetMessage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpSinglelineCheck.class); - checkConfig.addProperty("format", "\\r"); - checkConfig.addProperty("minimum", "500"); - checkConfig.addProperty("message", "someMessage"); final String[] expected = { "1: someMessage", }; @@ -120,9 +100,6 @@ public void testSetMessage() throws Exception { @Test public void testMaximum() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(RegexpSinglelineCheck.class); - checkConfig.addProperty("format", "System\\.(out)|(err)\\.print(ln)?\\("); - checkConfig.addProperty("maximum", "1"); verifyWithInlineConfigParser( getPath("InputRegexpSinglelineSemantic7.java"), EMPTY); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheckTest.java index 902f3234201..737797cc357 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheckTest.java @@ -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.utils.CommonUtil; public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { @@ -54,9 +53,6 @@ public void testGetRequiredTokens() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "System\\.(out)|(err)\\.print(ln)?\\("); final String[] expected = { "77: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "System\\.(out)|(err)\\.print(ln)?\\("), }; @@ -67,10 +63,6 @@ public void testIt() throws Exception { @Test public void testMessageProperty() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "System\\.(out)|(err)\\.print(ln)?\\("); - checkConfig.addProperty("message", "Bad line :("); final String[] expected = { "78: " + "Bad line :(", }; @@ -80,10 +72,6 @@ public void testMessageProperty() @Test public void testIgnoreCaseTrue() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("); - checkConfig.addProperty("ignoreCase", "true"); final String[] expected = { "78: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("), }; @@ -93,10 +81,6 @@ public void testIgnoreCaseTrue() throws Exception { @Test public void testIgnoreCaseFalse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("); - checkConfig.addProperty("ignoreCase", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaSemantic4.java"), expected); @@ -104,11 +88,7 @@ public void testIgnoreCaseFalse() throws Exception { @Test public void testIgnoreCommentsCppStyle() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); // See if the comment is removed properly - checkConfig.addProperty("format", "don't use trailing comments"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaTrailingComment.java"), expected); @@ -116,11 +96,7 @@ public void testIgnoreCommentsCppStyle() throws Exception { @Test public void testIgnoreCommentsFalseCppStyle() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); // See if the comment is removed properly - checkConfig.addProperty("format", "don't\\suse trailing comments"); - checkConfig.addProperty("ignoreComments", "false"); final String[] expected = { "16: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "don't\\suse trailing comments"), }; @@ -130,11 +106,7 @@ public void testIgnoreCommentsFalseCppStyle() throws Exception { @Test public void testIgnoreCommentsBlockStyle() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); // See if the comment is removed properly - checkConfig.addProperty("format", "c-style 1"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaTrailingComment3.java"), expected); @@ -142,10 +114,6 @@ public void testIgnoreCommentsBlockStyle() throws Exception { @Test public void testIgnoreCommentsFalseBlockStyle() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "c-style\\s1"); - checkConfig.addProperty("ignoreComments", "false"); final String[] expected = { "31: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "c-style\\s1"), }; @@ -155,11 +123,7 @@ public void testIgnoreCommentsFalseBlockStyle() throws Exception { @Test public void testIgnoreCommentsMultipleBlockStyle() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); // See if a second comment on the same line is removed properly - checkConfig.addProperty("format", "c-style 2"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaTrailingComment5.java"), expected); @@ -167,10 +131,6 @@ public void testIgnoreCommentsMultipleBlockStyle() throws Exception { @Test public void testIgnoreCommentsMultiLine() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "Let's check multi-line comments"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaTrailingComment6.java"), expected); @@ -178,10 +138,6 @@ public void testIgnoreCommentsMultiLine() throws Exception { @Test public void testIgnoreCommentsInlineStart() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "long ms /"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaTrailingComment7.java"), expected); @@ -189,10 +145,6 @@ public void testIgnoreCommentsInlineStart() throws Exception { @Test public void testIgnoreCommentsInlineEnd() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "int z"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = { "34: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "int z"), }; @@ -202,10 +154,6 @@ public void testIgnoreCommentsInlineEnd() throws Exception { @Test public void testIgnoreCommentsInlineMiddle() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "int y"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = { "35: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "int y"), }; @@ -215,11 +163,7 @@ public void testIgnoreCommentsInlineMiddle() throws Exception { @Test public void testIgnoreCommentsNoSpaces() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); // make sure the comment is not turned into spaces - checkConfig.addProperty("format", "long ms "); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaTrailingComment10.java"), expected); @@ -227,11 +171,7 @@ public void testIgnoreCommentsNoSpaces() throws Exception { @Test public void test1371588() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); // StackOverflowError with trailing space and ignoreComments - checkConfig.addProperty("format", "\\s+$"); - checkConfig.addProperty("ignoreComments", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaTrailingComment11.java"), expected); @@ -239,11 +179,6 @@ public void test1371588() throws Exception { @Test public void testExistingInDoc() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "Test case file"); - checkConfig.addProperty("minimum", "1"); - checkConfig.addProperty("maximum", "1000"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaSemantic5.java"), expected); @@ -251,11 +186,6 @@ public void testExistingInDoc() throws Exception { @Test public void testExistingInCode() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "package"); - checkConfig.addProperty("minimum", "1"); - checkConfig.addProperty("maximum", "1000"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaSemantic6.java"), expected); @@ -263,11 +193,6 @@ public void testExistingInCode() throws Exception { @Test public void testMissing() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RegexpSinglelineJavaCheck.class); - checkConfig.addProperty("format", "This\\stext is not in the file"); - checkConfig.addProperty("minimum", "1"); - checkConfig.addProperty("maximum", "1000"); final String[] expected = { "1: " + getCheckMessage(MSG_REGEXP_MINIMUM, 1, "This\\stext is not in the file"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheckTest.java index 3907b913a26..28d45d693a9 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheckTest.java @@ -25,7 +25,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; /** @@ -58,8 +57,6 @@ public void testGetAcceptableTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AnonInnerLengthCheck.class); final String[] expected = { "53:35: " + getCheckMessage(MSG_KEY, 21, 20), }; @@ -69,9 +66,6 @@ public void testDefault() throws Exception { @Test public void testNonDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(AnonInnerLengthCheck.class); - checkConfig.addProperty("max", "6"); final String[] expected = { "54:35: " + getCheckMessage(MSG_KEY, 21, 6), "79:35: " + getCheckMessage(MSG_KEY, 20, 6), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheckTest.java index b27089bd7a4..c2c579e6b1f 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheckTest.java @@ -30,7 +30,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.Context; import com.puppycrawl.tools.checkstyle.api.TokenTypes; @@ -59,10 +58,6 @@ public void testStatefulFieldsClearedOnBeginTree() throws Exception { @Test public void testMaxZero() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ExecutableStatementCountCheck.class); - - checkConfig.addProperty("max", "0"); final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, 3, 0), @@ -84,11 +79,6 @@ public void testMaxZero() throws Exception { @Test public void testMethodDef() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ExecutableStatementCountCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("tokens", "METHOD_DEF"); final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, 3, 0), @@ -105,11 +95,6 @@ public void testMethodDef() throws Exception { @Test public void testCtorDef() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ExecutableStatementCountCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("tokens", "CTOR_DEF"); final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -122,11 +107,6 @@ public void testCtorDef() throws Exception { @Test public void testStaticInit() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ExecutableStatementCountCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("tokens", "STATIC_INIT"); final String[] expected = { "13:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -138,11 +118,6 @@ public void testStaticInit() throws Exception { @Test public void testInstanceInit() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ExecutableStatementCountCheck.class); - - checkConfig.addProperty("max", "0"); - checkConfig.addProperty("tokens", "INSTANCE_INIT"); final String[] expected = { "13:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -186,8 +161,6 @@ public void testLeaveTokenWithWrongTokenType() { @Test public void testDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ExecutableStatementCountCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -196,9 +169,6 @@ public void testDefaultConfiguration() throws Exception { @Test public void testExecutableStatementCountRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ExecutableStatementCountCheck.class); - checkConfig.addProperty("max", "1"); final int max = 1; @@ -218,10 +188,6 @@ public void testExecutableStatementCountRecords() throws Exception { @Test public void testExecutableStatementCountLambdas() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ExecutableStatementCountCheck.class); - checkConfig.addProperty("max", "1"); - checkConfig.addProperty("tokens", "LAMBDA"); final int max = 1; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckTest.java index 716921ba3a7..c95653dd50f 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckTest.java @@ -40,9 +40,6 @@ protected String getPackageLocation() { @Test public void testAlarm() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FileLengthCheck.class); - checkConfig.addProperty("max", "20"); final String[] expected = { "1: " + getCheckMessage(MSG_KEY, 228, 20), }; @@ -52,9 +49,6 @@ public void testAlarm() throws Exception { @Test public void testFileLengthEqualToMaxLength() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FileLengthCheck.class); - checkConfig.addProperty("max", "225"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputFileLength2.java"), expected); @@ -62,9 +56,6 @@ public void testFileLengthEqualToMaxLength() throws Exception { @Test public void testOk() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FileLengthCheck.class); - checkConfig.addProperty("max", "1000"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputFileLength3.java"), expected); @@ -89,9 +80,6 @@ public void testArgs() throws Exception { @Test public void testNoAlarmByExtension() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FileLengthCheck.class); - checkConfig.addProperty("fileExtensions", "txt"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LambdaBodyLengthCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LambdaBodyLengthCheckTest.java index f88c53642e7..697e95c7a0e 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LambdaBodyLengthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LambdaBodyLengthCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -56,8 +55,6 @@ public void testGetAcceptableTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LambdaBodyLengthCheck.class); final String[] expected = { "16:27: " + getCheckMessage(MSG_KEY, 12, 10), "28:27: " + getCheckMessage(MSG_KEY, 12, 10), @@ -72,8 +69,6 @@ public void testDefault() throws Exception { @Test public void testDefaultSwitchExpressions() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LambdaBodyLengthCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputLambdaBodyLengthSwitchExps.java"), expected); @@ -81,9 +76,6 @@ public void testDefaultSwitchExpressions() throws Exception { @Test public void testMaxLimitIsDifferent() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LambdaBodyLengthCheck.class); - checkConfig.addProperty("max", "3"); final String[] expected = { "16:27: " + getCheckMessage(MSG_KEY, 4, 3), "20:27: " + getCheckMessage(MSG_KEY, 4, 3), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java index 6a4cc12e8f7..4d7242431de 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java @@ -38,10 +38,6 @@ protected String getPackageLocation() { @Test public void testSimple() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LineLengthCheck.class); - checkConfig.addProperty("max", "80"); - checkConfig.addProperty("ignorePattern", "^.*is OK.*regexp.*$"); final String[] expected = { "22: " + getCheckMessage(MSG_KEY, 80, 81), "149: " + getCheckMessage(MSG_KEY, 80, 83), @@ -53,11 +49,6 @@ public void testSimple() @Test public void shouldLogActualLineLength() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LineLengthCheck.class); - checkConfig.addProperty("max", "80"); - checkConfig.addProperty("ignorePattern", "^.*is OK.*regexp.*$"); - checkConfig.addMessage("maxLineLen", "{0},{1}"); final String[] expected = { "23: 80,81", "150: 80,83", @@ -68,9 +59,6 @@ public void shouldLogActualLineLength() @Test public void shouldNotLogLongImportStatements() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LineLengthCheck.class); - checkConfig.addProperty("max", "80"); final String[] expected = { "18: " + getCheckMessage(MSG_KEY, 80, 100), }; @@ -80,9 +68,6 @@ public void shouldNotLogLongImportStatements() throws Exception { @Test public void shouldNotLogLongPackageStatements() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LineLengthCheck.class); - checkConfig.addProperty("max", "80"); final String[] expected = { "16: " + getCheckMessage(MSG_KEY, 80, 101), }; @@ -93,11 +78,6 @@ public void shouldNotLogLongPackageStatements() throws Exception { @Test public void shouldNotLogLongLinks() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(LineLengthCheck.class); - checkConfig.addProperty("max", "80"); - checkConfig.addProperty("ignorePattern", - "^ *\\* *([^ ]+|\\{@code .*|)$"); final String[] expected = { "13: " + getCheckMessage(MSG_KEY, 80, 111), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheckTest.java index cc5e925acfb..85771721870 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheckTest.java @@ -29,7 +29,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -68,8 +67,6 @@ public void testGetAcceptableTokens() { @Test public void testDefaults() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodCountCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -79,13 +76,6 @@ public void testDefaults() throws Exception { @Test public void testThrees() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodCountCheck.class); - checkConfig.addProperty("maxPrivate", "3"); - checkConfig.addProperty("maxPackage", "3"); - checkConfig.addProperty("maxProtected", "3"); - checkConfig.addProperty("maxPublic", "3"); - checkConfig.addProperty("maxTotal", "3"); final String[] expected = { "15:1: " + getCheckMessage(MSG_PACKAGE_METHODS, 5, 3), @@ -105,10 +95,6 @@ public void testThrees() throws Exception { @Test public void testEnum() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodCountCheck.class); - checkConfig.addProperty("maxPrivate", "0"); - checkConfig.addProperty("maxTotal", "2"); final String[] expected = { "21:5: " + getCheckMessage(MSG_PRIVATE_METHODS, 1, 0), @@ -121,9 +107,6 @@ public void testEnum() throws Exception { @Test public void testWithPackageModifier() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MethodCountCheck.class); - checkConfig.addProperty("maxPrivate", "0"); - checkConfig.addProperty("maxTotal", "2"); final String[] expected = { "15:1: " + getCheckMessage(MSG_MANY_METHODS, 5, 2), @@ -135,8 +118,6 @@ public void testWithPackageModifier() throws Exception { @Test public void testOnInterfaceDefinitionWithField() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodCountCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -146,8 +127,6 @@ public void testOnInterfaceDefinitionWithField() throws Exception { @Test public void testWithInterfaceDefinitionInClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MethodCountCheck.class); - checkConfig.addProperty("maxTotal", "1"); final String[] expected = { "15:1: " + getCheckMessage(MSG_MANY_METHODS, 2, 1), @@ -159,9 +138,6 @@ public void testWithInterfaceDefinitionInClass() throws Exception { @Test public void testPartialTokens() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MethodCountCheck.class); - checkConfig.addProperty("maxTotal", "1"); - checkConfig.addProperty("tokens", "ENUM_DEF"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -171,9 +147,6 @@ public void testPartialTokens() throws Exception { @Test public void testCountMethodToCorrectDefinition() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MethodCountCheck.class); - checkConfig.addProperty("maxTotal", "1"); - checkConfig.addProperty("tokens", "ENUM_DEF"); final String[] expected = { "22:5: " + getCheckMessage(MSG_MANY_METHODS, 2, 1), @@ -185,9 +158,6 @@ public void testCountMethodToCorrectDefinition() throws Exception { @Test public void testInterfaceMemberScopeIsPublic() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MethodCountCheck.class); - checkConfig.addProperty("maxPublic", "1"); - checkConfig.addProperty("tokens", "ENUM_DEF, CLASS_DEF"); final String[] expected = { "17:5: " + getCheckMessage(MSG_PUBLIC_METHODS, 2, 1), @@ -201,8 +171,6 @@ public void testInterfaceMemberScopeIsPublic() throws Exception { @Test public void testMethodCountRecords() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MethodCountCheck.class); - checkConfig.addProperty("maxTotal", "2"); final int max = 2; final String[] expected = { diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheckTest.java index b7ca44cfb9e..13e75dda6a3 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -59,9 +58,6 @@ public void testGetAcceptableTokens() { @Test public void testIt() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodLengthCheck.class); - checkConfig.addProperty("max", "19"); final String[] expected = { "76:5: " + getCheckMessage(MSG_KEY, 20, 19, "longMethod"), }; @@ -71,10 +67,6 @@ public void testIt() throws Exception { @Test public void testCountEmptyIsFalse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodLengthCheck.class); - checkConfig.addProperty("max", "19"); - checkConfig.addProperty("countEmpty", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMethodLengthCountEmptyIsFalse.java"), expected); @@ -82,10 +74,6 @@ public void testCountEmptyIsFalse() throws Exception { @Test public void testWithComments() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodLengthCheck.class); - checkConfig.addProperty("max", "7"); - checkConfig.addProperty("countEmpty", "false"); final String[] expected = { "34:5: " + getCheckMessage(MSG_KEY, 8, 7, "visit"), }; @@ -95,8 +83,6 @@ public void testWithComments() throws Exception { @Test public void testAbstract() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodLengthCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMethodLengthModifier.java"), expected); @@ -104,11 +90,6 @@ public void testAbstract() throws Exception { @Test public void testRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MethodLengthCheck.class); - checkConfig.addProperty("max", "2"); - checkConfig.addProperty("tokens", - "METHOD_DEF, CTOR_DEF, COMPACT_CTOR_DEF"); final int max = 2; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheckTest.java index 1a13f0d8d8a..0a4a5d7ad78 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -68,8 +67,6 @@ public void testGetAcceptableTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OuterTypeNumberCheck.class); final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY, 3, 1), }; @@ -79,9 +76,6 @@ public void testDefault() throws Exception { @Test public void testMax30() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OuterTypeNumberCheck.class); - checkConfig.addProperty("max", "30"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOuterTypeNumberSimple1.java"), expected); @@ -89,9 +83,6 @@ public void testMax30() throws Exception { @Test public void testWithInnerClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OuterTypeNumberCheck.class); - checkConfig.addProperty("max", "1"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOuterTypeNumberEmptyInner.java"), expected); @@ -99,9 +90,6 @@ public void testWithInnerClass() throws Exception { @Test public void testWithRecords() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(OuterTypeNumberCheck.class); - checkConfig.addProperty("max", "1"); final int max = 1; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheckTest.java index 4aa1cd1b625..a2d370ff73e 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -60,8 +59,6 @@ public void testGetAcceptableTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNumberCheck.class); final String[] expected = { "198:10: " + getCheckMessage(MSG_KEY, 7, 9), }; @@ -72,9 +69,6 @@ public void testDefault() @Test public void testNum() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNumberCheck.class); - checkConfig.addProperty("max", "2"); final String[] expected = { "75:9: " + getCheckMessage(MSG_KEY, 2, 3), "198:10: " + getCheckMessage(MSG_KEY, 2, 9), @@ -86,9 +80,6 @@ public void testNum() @Test public void testMaxParam() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNumberCheck.class); - checkConfig.addProperty("max", "9"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputParameterNumberSimple3.java"), expected); @@ -97,9 +88,6 @@ public void testMaxParam() @Test public void shouldLogActualParameterNumber() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNumberCheck.class); - checkConfig.addMessage("maxParam", "{0},{1}"); final String[] expected = { "199:10: 7,9", }; @@ -110,9 +98,6 @@ public void shouldLogActualParameterNumber() @Test public void testIgnoreOverriddenMethods() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNumberCheck.class); - checkConfig.addProperty("ignoreOverriddenMethods", "true"); final String[] expected = { "15:10: " + getCheckMessage(MSG_KEY, 7, 8), "20:10: " + getCheckMessage(MSG_KEY, 7, 8), @@ -124,8 +109,6 @@ public void testIgnoreOverriddenMethods() @Test public void testIgnoreOverriddenMethodsFalse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParameterNumberCheck.class); final String[] expected = { "15:10: " + getCheckMessage(MSG_KEY, 7, 8), "20:10: " + getCheckMessage(MSG_KEY, 7, 8), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheckTest.java index 54a9b6ade82..238465e0095 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheckTest.java @@ -25,7 +25,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -61,8 +60,6 @@ public void testGetAcceptableTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RecordComponentNumberCheck.class); final int max = 8; @@ -82,8 +79,6 @@ public void testDefault() throws Exception { @Test public void testRecordComponentNumberTopLevel1() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RecordComponentNumberCheck.class); final int max = 8; @@ -98,8 +93,6 @@ public void testRecordComponentNumberTopLevel1() throws Exception { @Test public void testRecordComponentNumberTopLevel2() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RecordComponentNumberCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -110,9 +103,6 @@ public void testRecordComponentNumberTopLevel2() throws Exception { @Test public void testRecordComponentNumberMax1() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RecordComponentNumberCheck.class); - checkConfig.addProperty("max", "1"); final int max = 1; @@ -139,9 +129,6 @@ public void testRecordComponentNumberMax1() throws Exception { @Test public void testRecordComponentNumberMax20() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RecordComponentNumberCheck.class); - checkConfig.addProperty("max", "20"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -150,9 +137,6 @@ public void testRecordComponentNumberMax20() throws Exception { @Test public void testRecordComponentNumberPrivateModifier() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(RecordComponentNumberCheck.class); - checkConfig.addProperty("accessModifiers", "private"); final int max = 8; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadCheckTest.java index c71b02c1225..fdbc13037c5 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadCheckTest.java @@ -51,8 +51,6 @@ public void testGetRequiredTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EmptyForInitializerPadCheck.class); final String[] expected = { "51:15: " + getCheckMessage(MSG_PRECEDED, ";"), }; @@ -62,9 +60,6 @@ public void testDefault() throws Exception { @Test public void testSpaceOption() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(EmptyForInitializerPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); final String[] expected = { "54:14: " + getCheckMessage(MSG_NOT_PRECEDED, ";"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForIteratorPadCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForIteratorPadCheckTest.java index ab333318556..8d9c9ad7898 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForIteratorPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForIteratorPadCheckTest.java @@ -51,7 +51,6 @@ public void testGetRequiredTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyForIteratorPadCheck.class); final String[] expected = { "30:32: " + getCheckMessage(MSG_WS_FOLLOWED, ";"), "46:33: " + getCheckMessage(MSG_WS_FOLLOWED, ";"), @@ -63,8 +62,6 @@ public void testDefault() throws Exception { @Test public void testSpaceOption() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyForIteratorPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); final String[] expected = { "26:31: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheckTest.java index f861bf73767..9d74a89553a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheckTest.java @@ -49,7 +49,6 @@ public void testGetRequiredTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "33:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), @@ -68,8 +67,6 @@ public void testDefault() throws Exception { @Test public void testAllowNoEmptyLineBetweenFields() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowNoEmptyLineBetweenFields", "true"); final String[] expected = { "33:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), @@ -87,7 +84,6 @@ public void testAllowNoEmptyLineBetweenFields() throws Exception { @Test public void testHeader() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "31:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), }; @@ -97,8 +93,6 @@ public void testHeader() throws Exception { @Test public void testMultipleEmptyLinesBetweenClassMembers() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLines", "false"); final String[] expected = { "33:1: " + getCheckMessage(MSG_MULTIPLE_LINES, "package"), "36:1: " + getCheckMessage(MSG_MULTIPLE_LINES, "import"), @@ -114,8 +108,6 @@ public void testMultipleEmptyLinesBetweenClassMembers() throws Exception { @Test public void testFormerArrayIndexOutOfBounds() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLines", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorFormerException.java"), expected); @@ -123,9 +115,6 @@ public void testFormerArrayIndexOutOfBounds() throws Exception { @Test public void testAllowMultipleFieldInClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLines", "false"); - checkConfig.addProperty("allowNoEmptyLineBetweenFields", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorMultipleFieldsInClass.java"), expected); @@ -133,8 +122,6 @@ public void testAllowMultipleFieldInClass() throws Exception { @Test public void testAllowMultipleImportSeparatedFromPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLines", "false"); final String[] expected = { "13:78: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), }; @@ -145,8 +132,6 @@ public void testAllowMultipleImportSeparatedFromPackage() throws Exception { @Test public void testImportSeparatedFromPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLines", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorImportSeparatedFromPackage.java"), @@ -155,7 +140,6 @@ public void testImportSeparatedFromPackage() throws Exception { @Test public void testBlockCommentNotSeparatedFromPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "/*"), }; @@ -166,7 +150,6 @@ public void testBlockCommentNotSeparatedFromPackage() throws Exception { @Test public void testSingleCommentNotSeparatedFromPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "//"), }; @@ -177,7 +160,6 @@ public void testSingleCommentNotSeparatedFromPackage() throws Exception { @Test public void testClassDefinitionNotSeparatedFromPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), }; @@ -188,7 +170,6 @@ public void testClassDefinitionNotSeparatedFromPackage() throws Exception { @Test public void testCommentAfterPackageWithImports() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "//"), }; @@ -210,7 +191,6 @@ public void testJavadocCommentAfterPackageWithImports() throws Exception { @Test public void testPackageImportsClassInSingleLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "13:79: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), "13:101: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), @@ -222,8 +202,6 @@ public void testPackageImportsClassInSingleLine() throws Exception { @Test public void testEmptyLineAfterPackageForPackageAst() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("tokens", "PACKAGE_DEF"); final String[] expected = { "12:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "/*"), }; @@ -234,8 +212,6 @@ public void testEmptyLineAfterPackageForPackageAst() throws Exception { @Test public void testEmptyLineAfterPackageForImportAst() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("tokens", "IMPORT"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorEmptyLineAfterPackageForImportAst.java"), @@ -244,7 +220,6 @@ public void testEmptyLineAfterPackageForImportAst() throws Exception { @Test public void testClassDefinitionAndCommentNotSeparatedFromPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "//"), "15:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), @@ -257,7 +232,6 @@ public void testClassDefinitionAndCommentNotSeparatedFromPackage() throws Except @Test public void testBlockCommentSeparatedFromPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorBlockCommentSeparatedFromPackage.java"), @@ -266,7 +240,6 @@ public void testBlockCommentSeparatedFromPackage() throws Exception { @Test public void testSingleCommentSeparatedFromPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorSingleCommentSeparatedFromPackage.java"), @@ -317,8 +290,6 @@ public void testPrePreviousLineIsEmpty() throws Exception { @Test public void testPreviousLineEmptiness() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLinesInsideClassMembers", "false"); final String[] expected = { "21:30: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), "26:5: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), @@ -332,8 +303,6 @@ public void testPreviousLineEmptiness() throws Exception { @Test public void testDisAllowMultipleEmptyLinesInsideClassMembers() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLinesInsideClassMembers", "false"); final String[] expected = { "37:11: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), "49:11: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), @@ -349,7 +318,6 @@ public void testDisAllowMultipleEmptyLinesInsideClassMembers() throws Exception @Test public void testAllowMultipleEmptyLinesInsideClassMembers() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "91:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), }; @@ -360,7 +328,6 @@ public void testAllowMultipleEmptyLinesInsideClassMembers() throws Exception { @Test public void testImportsAndStaticImports() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorImports.java"), expected); @@ -368,7 +335,6 @@ public void testImportsAndStaticImports() throws Exception { @Test public void testAllowPackageAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("packageinfo/test1/package-info.java"), @@ -377,7 +343,6 @@ public void testAllowPackageAnnotation() throws Exception { @Test public void testAllowJavadocBeforePackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("packageinfo/test2/package-info.java"), @@ -386,7 +351,6 @@ public void testAllowJavadocBeforePackage() throws Exception { @Test public void testDisAllowBlockCommentBeforePackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "15:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), }; @@ -397,7 +361,6 @@ public void testDisAllowBlockCommentBeforePackage() throws Exception { @Test public void testAllowSingleLineCommentPackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "16:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), }; @@ -408,7 +371,6 @@ public void testAllowSingleLineCommentPackage() throws Exception { @Test public void testNonPackageInfoWithJavadocBeforePackage() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "15:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), }; @@ -419,9 +381,6 @@ public void testNonPackageInfoWithJavadocBeforePackage() throws Exception { @Test public void testClassOnly() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("tokens", "CLASS_DEF"); - checkConfig.addProperty("allowMultipleEmptyLinesInsideClassMembers", "false"); final String[] expected = { "70:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), }; @@ -432,8 +391,6 @@ public void testClassOnly() throws Exception { @Test public void testLineSeparationBeforeComments() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLines", "false"); final String[] expected = { "31:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), "35:1: " + getCheckMessage(MSG_MULTIPLE_LINES, "//"), @@ -480,7 +437,6 @@ public void testLineSeparationBeforeComments() throws Exception { @Test public void testIgnoreEmptyLinesBeforeCommentsWhenItIsAllowed() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "31:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), "258:5: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "INTERFACE_DEF"), @@ -491,7 +447,6 @@ public void testIgnoreEmptyLinesBeforeCommentsWhenItIsAllowed() throws Exception @Test public void testNoViolationsOnEmptyLinesBeforeComments() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorNoViolationOnEmptyLineBeforeComments.java"), @@ -527,8 +482,6 @@ public void testEmptyLineSeparatorRecordsAndCompactCtors() throws Exception { @Test public void testEmptyLineSeparatorRecordsAndCompactCtorsNoEmptyLines() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLinesInsideClassMembers", "false"); final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), @@ -544,8 +497,6 @@ public void testEmptyLineSeparatorRecordsAndCompactCtorsNoEmptyLines() throws Ex @Test public void testEmptyLineSeparatorMultipleSingleTypeVariables() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowNoEmptyLineBetweenFields", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -556,8 +507,6 @@ public void testEmptyLineSeparatorMultipleSingleTypeVariables() throws Exception @Test public void testEmptyLineSeparatorEmptyLinesInsideClassMembersRecursive() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLinesInsideClassMembers", "false"); final String[] expected = { "27:15: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), }; @@ -568,8 +517,6 @@ public void testEmptyLineSeparatorEmptyLinesInsideClassMembersRecursive() throws @Test public void testEmptyLineSeparatorNewMethodDef() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLinesInsideClassMembers", "false"); final String[] expected = { "29:34: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), "38:26: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), @@ -581,8 +528,6 @@ public void testEmptyLineSeparatorNewMethodDef() throws Exception { @Test public void testEmptyLineSeparatorPostFixCornerCases() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLinesInsideClassMembers", "false"); final String[] expected = { "18:19: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), "32:29: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), @@ -595,8 +540,6 @@ public void testEmptyLineSeparatorPostFixCornerCases() throws Exception { @Test public void testEmptyLineSeparatorAnnotation() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); - checkConfig.addProperty("allowMultipleEmptyLines", "false"); final String[] expected = { "18:22: " + getCheckMessage(MSG_MULTIPLE_LINES_AFTER, "}"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterCheckTest.java index 0a61b402320..3529311cabc 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterCheckTest.java @@ -39,9 +39,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FileTabCharacterCheck.class); - checkConfig.addProperty("eachLine", "false"); final String[] expected = { "22:25: " + getCheckMessage(MSG_FILE_CONTAINS_TAB), }; @@ -52,9 +49,6 @@ public void testDefault() throws Exception { @Test public void testVerbose() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(FileTabCharacterCheck.class); - checkConfig.addProperty("eachLine", "true"); final String[] expected = { "22:25: " + getCheckMessage(MSG_CONTAINS_TAB), "148:35: " + getCheckMessage(MSG_CONTAINS_TAB), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java index 27a709db2f5..14537187860 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java @@ -31,7 +31,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -57,7 +56,6 @@ public void testGetRequiredTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(GenericWhitespaceCheck.class); final String[] expected = { "22:14: " + getCheckMessage(MSG_WS_PRECEDED, "<"), "22:14: " + getCheckMessage(MSG_WS_FOLLOWED, "<"), @@ -100,7 +98,6 @@ public void testDefault() throws Exception { @Test public void testAtTheStartOfTheLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(GenericWhitespaceCheck.class); final String[] expected = { "16:2: " + getCheckMessage(MSG_WS_PRECEDED, ">"), "18:2: " + getCheckMessage(MSG_WS_PRECEDED, "<"), @@ -111,7 +108,6 @@ public void testAtTheStartOfTheLine() throws Exception { @Test public void testNestedGeneric() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(GenericWhitespaceCheck.class); final String[] expected = { "17:1: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "&"), }; @@ -121,7 +117,6 @@ public void testNestedGeneric() throws Exception { @Test public void testList() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(GenericWhitespaceCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputGenericWhitespaceList.java"), expected); @@ -129,7 +124,6 @@ public void testList() throws Exception { @Test public void testInnerClass() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(GenericWhitespaceCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputGenericWhitespaceInnerClass.java"), expected); @@ -137,7 +131,6 @@ public void testInnerClass() throws Exception { @Test public void testMethodReferences() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(GenericWhitespaceCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputGenericWhitespaceMethodRef1.java"), expected); @@ -145,7 +138,6 @@ public void testMethodReferences() throws Exception { @Test public void testMethodReferences2() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(GenericWhitespaceCheck.class); final String[] expected = { "16:69: " + getCheckMessage(MSG_WS_FOLLOWED, ">"), }; @@ -155,7 +147,6 @@ public void testMethodReferences2() throws Exception { @Test public void testGenericEndsTheLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(GenericWhitespaceCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputGenericWhitespaceEndsTheLine.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadCheckTest.java index f6aba57c577..786b81d9d9a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadCheckTest.java @@ -51,7 +51,6 @@ public void testGetRequiredTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MethodParamPadCheck.class); final String[] expected = { "21:32: " + getCheckMessage(MSG_WS_PRECEDED, "("), "23:15: " + getCheckMessage(MSG_WS_PRECEDED, "("), @@ -78,8 +77,6 @@ public void testDefault() throws Exception { @Test public void testAllowLineBreaks() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MethodParamPadCheck.class); - checkConfig.addProperty("allowLineBreaks", "true"); final String[] expected = { "21:33: " + getCheckMessage(MSG_WS_PRECEDED, "("), "23:15: " + getCheckMessage(MSG_WS_PRECEDED, "("), @@ -97,8 +94,6 @@ public void testAllowLineBreaks() throws Exception { @Test public void testSpaceOption() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MethodParamPadCheck.class); - checkConfig.addProperty("option", "space"); final String[] expected = { "16:32: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "("), "18:14: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "("), @@ -129,8 +124,6 @@ public void testSpaceOption() throws Exception { @Test public void testMethodParamPadRecords() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MethodParamPadCheck.class); - checkConfig.addProperty("allowLineBreaks", "true"); final String[] expected = { "19:25: " + getCheckMessage(MSG_WS_PRECEDED, "("), "20:34: " + getCheckMessage(MSG_WS_PRECEDED, "("), @@ -149,8 +142,6 @@ public void testMethodParamPadRecords() throws Exception { @Test public void test1322879() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MethodParamPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMethodParamPadWhitespaceAround.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoLineWrapCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoLineWrapCheckTest.java index 09fd9b07ac7..2fc99ca0684 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoLineWrapCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoLineWrapCheckTest.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class NoLineWrapCheckTest @@ -37,7 +36,6 @@ protected String getPackageLocation() { @Test public void testCaseWithoutLineWrapping() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoLineWrapCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNoLineWrapGood.java"), expected); @@ -45,7 +43,6 @@ public void testCaseWithoutLineWrapping() throws Exception { @Test public void testDefaultTokensLineWrapping() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoLineWrapCheck.class); final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY, "package"), "13:1: " + getCheckMessage(MSG_KEY, "import"), @@ -58,9 +55,6 @@ public void testDefaultTokensLineWrapping() throws Exception { @Test public void testCustomTokensLineWrapping() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoLineWrapCheck.class); - checkConfig.addProperty( - "tokens", "IMPORT, STATIC_IMPORT, CLASS_DEF, METHOD_DEF, ENUM_DEF"); final String[] expected = { "13:1: " + getCheckMessage(MSG_KEY, "import"), "17:1: " + getCheckMessage(MSG_KEY, "import"), @@ -75,9 +69,6 @@ public void testCustomTokensLineWrapping() @Test public void testNoLineWrapRecordsAndCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoLineWrapCheck.class); - checkConfig.addProperty( - "tokens", "RECORD_DEF, CLASS_DEF, CTOR_DEF, COMPACT_CTOR_DEF"); final String[] expected = { "13:9: " + getCheckMessage(MSG_KEY, "CTOR_DEF"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java index 5e59fe3e1f6..3ddfe282f9a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -42,8 +41,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("allowLineBreaks", "false"); final String[] expected = { "10:13: " + getCheckMessage(MSG_KEY, "."), "11:11: " + getCheckMessage(MSG_KEY, "."), @@ -69,8 +66,6 @@ public void testDefault() throws Exception { @Test public void testDotAllowLineBreaks() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("tokens", "DOT"); final String[] expected = { "9:13: " + getCheckMessage(MSG_KEY, "."), "129:23: " + getCheckMessage(MSG_KEY, "."), @@ -82,8 +77,6 @@ public void testDotAllowLineBreaks() throws Exception { @Test public void testTypecast() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("tokens", "TYPECAST"); final String[] expected = { "87:20: " + getCheckMessage(MSG_KEY, ")"), "89:13: " + getCheckMessage(MSG_KEY, ")"), @@ -95,9 +88,6 @@ public void testTypecast() throws Exception { @Test public void testArrayDeclarations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("tokens", "ARRAY_DECLARATOR"); - checkConfig.addProperty("tokens", "INDEX_OP"); final String[] expected = { "14:12: " + getCheckMessage(MSG_KEY, "Object"), "16:23: " + getCheckMessage(MSG_KEY, "someStuff3"), @@ -127,9 +117,6 @@ public void testArrayDeclarations() throws Exception { @Test public void testArrayDeclarations2() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("tokens", "ARRAY_DECLARATOR"); - checkConfig.addProperty("tokens", "INDEX_OP"); final String[] expected = { "20:31: " + getCheckMessage(MSG_KEY, "]"), "25:41: " + getCheckMessage(MSG_KEY, "create"), @@ -180,17 +167,12 @@ public void testArrayDeclarations2() throws Exception { @Test public void testArrayDeclarations3() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("tokens", "ARRAY_DECLARATOR"); - checkConfig.addProperty("tokens", "INDEX_OP"); verifyWithInlineConfigParser( getPath("InputNoWhitespaceAfterArrayDeclarations3.java")); } @Test public void testSynchronized() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("tokens", "LITERAL_SYNCHRONIZED"); final String[] expected = { "22:9: " + getCheckMessage(MSG_KEY, "synchronized"), }; @@ -200,14 +182,12 @@ public void testSynchronized() throws Exception { @Test public void testNpe() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); verifyWithInlineConfigParser( getPath("InputNoWhitespaceAfterTestNpe.java")); } @Test public void testMethodReference() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); final String[] expected = { "17:41: " + getCheckMessage(MSG_KEY, "int"), "18:62: " + getCheckMessage(MSG_KEY, "String"), @@ -218,8 +198,6 @@ public void testMethodReference() throws Exception { @Test public void testMethodReferenceAfter() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("tokens", "METHOD_REF"); final String[] expected = { "25:35: " + getCheckMessage(MSG_KEY, "::"), "26:64: " + getCheckMessage(MSG_KEY, "::"), @@ -230,8 +208,6 @@ public void testMethodReferenceAfter() throws Exception { @Test public void testArrayDeclarator() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("tokens", "ARRAY_DECLARATOR"); final String[] expected = { "19:32: " + getCheckMessage(MSG_KEY, "Entry"), }; @@ -261,11 +237,6 @@ public void testVisitTokenSwitchReflection() { @Test public void testAllTokens() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("tokens", "ARRAY_INIT, AT, INC, DEC, UNARY_MINUS, UNARY_PLUS, " - + "BNOT, LNOT, DOT, TYPECAST, ARRAY_DECLARATOR, INDEX_OP, LITERAL_SYNCHRONIZED, " - + "METHOD_REF"); - checkConfig.addProperty("allowLineBreaks", "false"); final String[] expected = { "10:13: " + getCheckMessage(MSG_KEY, "."), "11:11: " + getCheckMessage(MSG_KEY, "."), @@ -296,10 +267,6 @@ public void testAllTokens() throws Exception { @Test public void testArrayDeclarationsAndAnnotations() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("tokens", "ARRAY_INIT, AT, INC, DEC, UNARY_MINUS, UNARY_PLUS, " - + "BNOT, LNOT, DOT, TYPECAST, ARRAY_DECLARATOR, INDEX_OP, LITERAL_SYNCHRONIZED, " - + "METHOD_REF"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNoWhitespaceAfterArrayDeclarationsAndAnno.java"), expected); @@ -307,12 +274,6 @@ public void testArrayDeclarationsAndAnnotations() throws Exception { @Test public void testArrayNewTypeStructure() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); - checkConfig.addProperty("tokens", "ARRAY_INIT, AT, INC, DEC, UNARY_MINUS, UNARY_PLUS, " - + "BNOT, LNOT, DOT, TYPECAST, ARRAY_DECLARATOR, INDEX_OP, LITERAL_SYNCHRONIZED, " - + "METHOD_REF"); - checkConfig.addProperty("allowLineBreaks", "false"); - final String[] expected = { "53:17: " + getCheckMessage(MSG_KEY, "ci"), "54:27: " + getCheckMessage(MSG_KEY, "int"), @@ -345,7 +306,6 @@ public void testArrayNewTypeStructure() throws Exception { @Test public void testArrayNewGenericTypeArgument() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceAfterCheck.class); final String[] expected = { "59:15: " + getCheckMessage(MSG_KEY, "i"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCaseDefaultColonCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCaseDefaultColonCheckTest.java index f1c2c8ae4ce..7ec8014ec57 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCaseDefaultColonCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCaseDefaultColonCheckTest.java @@ -25,7 +25,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 NoWhitespaceBeforeCaseDefaultColonCheckTest @@ -39,7 +38,7 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( + createModuleConfig( NoWhitespaceBeforeCaseDefaultColonCheck.class); final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY, ":"), @@ -63,7 +62,7 @@ public void testDefault() throws Exception { @Test public void testDefaultNonCompilable() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig( + createModuleConfig( NoWhitespaceBeforeCaseDefaultColonCheck.class); final String[] expected = { "36:22: " + getCheckMessage(MSG_KEY, ":"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java index 8e29e3aec25..c0d6f5c3d27 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class NoWhitespaceBeforeCheckTest @@ -37,7 +36,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceBeforeCheck.class); final String[] expected = { "34:15: " + getCheckMessage(MSG_KEY, "++"), "34:22: " + getCheckMessage(MSG_KEY, "--"), @@ -59,8 +57,6 @@ public void testDefault() throws Exception { @Test public void testDot() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceBeforeCheck.class); - checkConfig.addProperty("tokens", "DOT"); final String[] expected = { "9:13: " + getCheckMessage(MSG_KEY, "."), "10:5: " + getCheckMessage(MSG_KEY, "."), @@ -75,9 +71,6 @@ public void testDot() throws Exception { @Test public void testDotAllowLineBreaks() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceBeforeCheck.class); - checkConfig.addProperty("tokens", "DOT"); - checkConfig.addProperty("allowLineBreaks", "yes"); final String[] expected = { "9:13: " + getCheckMessage(MSG_KEY, "."), "133:18: " + getCheckMessage(MSG_KEY, "."), @@ -89,8 +82,6 @@ public void testDotAllowLineBreaks() throws Exception { @Test public void testMethodReference() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceBeforeCheck.class); - checkConfig.addProperty("tokens", "METHOD_REF"); final String[] expected = { "25:32: " + getCheckMessage(MSG_KEY, "::"), "26:61: " + getCheckMessage(MSG_KEY, "::"), @@ -101,8 +92,6 @@ public void testMethodReference() throws Exception { @Test public void testDotAtTheStartOfTheLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceBeforeCheck.class); - checkConfig.addProperty("tokens", "DOT"); final String[] expected = { "10:1: " + getCheckMessage(MSG_KEY, "."), }; @@ -112,9 +101,6 @@ public void testDotAtTheStartOfTheLine() throws Exception { @Test public void testMethodRefAtTheStartOfTheLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceBeforeCheck.class); - checkConfig.addProperty("tokens", "METHOD_REF"); - checkConfig.addProperty("allowLineBreaks", "yes"); final String[] expected = { "22:3: " + getCheckMessage(MSG_KEY, "::"), }; @@ -124,9 +110,6 @@ public void testMethodRefAtTheStartOfTheLine() throws Exception { @Test public void testEmptyForLoop() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceBeforeCheck.class); - checkConfig.addProperty("tokens", "SEMI"); - checkConfig.addProperty("allowLineBreaks", "yes"); final String[] expected = { "20:24: " + getCheckMessage(MSG_KEY, ";"), "26:32: " + getCheckMessage(MSG_KEY, ";"), @@ -137,7 +120,6 @@ public void testEmptyForLoop() throws Exception { @Test public void testNoWhitespaceBeforeTextBlocksWithTabIndent() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(NoWhitespaceBeforeCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/OperatorWrapCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/OperatorWrapCheckTest.java index 35354ad2a86..4bd7e17f80d 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/OperatorWrapCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/OperatorWrapCheckTest.java @@ -27,7 +27,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.CheckstyleException; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -42,7 +41,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OperatorWrapCheck.class); final String[] expected = { "23:19: " + getCheckMessage(MSG_LINE_NEW, "+"), "24:15: " + getCheckMessage(MSG_LINE_NEW, "-"), @@ -57,8 +55,6 @@ public void testDefault() @Test public void testOpWrapEol() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OperatorWrapCheck.class); - checkConfig.addProperty("option", WrapOption.EOL.toString()); final String[] expected = { "26:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "-"), "30:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "&&"), @@ -71,8 +67,6 @@ public void testOpWrapEol() @Test public void testNonDefOpsDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OperatorWrapCheck.class); - checkConfig.addProperty("tokens", "METHOD_REF"); final String[] expected = { "37:33: " + getCheckMessage(MSG_LINE_NEW, "::"), }; @@ -83,9 +77,6 @@ public void testNonDefOpsDefault() @Test public void testNonDefOpsWrapEol() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OperatorWrapCheck.class); - checkConfig.addProperty("tokens", "METHOD_REF"); - checkConfig.addProperty("option", WrapOption.EOL.toString()); final String[] expected = { "35:21: " + getCheckMessage(MSG_LINE_PREVIOUS, "::"), "40:21: " + getCheckMessage(MSG_LINE_PREVIOUS, "::"), @@ -97,9 +88,6 @@ public void testNonDefOpsWrapEol() @Test public void testAssignEol() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OperatorWrapCheck.class); - checkConfig.addProperty("tokens", "ASSIGN"); - checkConfig.addProperty("option", WrapOption.EOL.toString()); final String[] expected = { "46:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "="), }; @@ -109,14 +97,6 @@ public void testAssignEol() @Test public void testEol() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OperatorWrapCheck.class); - checkConfig.addProperty("tokens", "ASSIGN"); - checkConfig.addProperty("tokens", "COLON"); - checkConfig.addProperty("tokens", "LAND"); - checkConfig.addProperty("tokens", "LOR"); - checkConfig.addProperty("tokens", "STAR"); - checkConfig.addProperty("tokens", "QUESTION"); - checkConfig.addProperty("option", WrapOption.EOL.toString()); final String[] expected = { "21:17: " + getCheckMessage(MSG_LINE_PREVIOUS, "="), "22:17: " + getCheckMessage(MSG_LINE_PREVIOUS, "*"), @@ -134,14 +114,6 @@ public void testEol() throws Exception { @Test public void testNl() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OperatorWrapCheck.class); - checkConfig.addProperty("tokens", "ASSIGN"); - checkConfig.addProperty("tokens", "COLON"); - checkConfig.addProperty("tokens", "LAND"); - checkConfig.addProperty("tokens", "LOR"); - checkConfig.addProperty("tokens", "STAR"); - checkConfig.addProperty("tokens", "QUESTION"); - checkConfig.addProperty("option", WrapOption.NL.toString()); final String[] expected = { "20:16: " + getCheckMessage(MSG_LINE_NEW, "="), "21:19: " + getCheckMessage(MSG_LINE_NEW, "*"), @@ -158,8 +130,6 @@ public void testNl() throws Exception { @Test public void testInvalidOption() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(OperatorWrapCheck.class); - checkConfig.addProperty("option", "invalid_option"); try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java index 9fe42bcb580..fe1c72d00ce 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java @@ -51,8 +51,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParenPadCheck.class); final String[] expected = { "65:11: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "65:37: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -71,9 +69,6 @@ public void testDefault() @Test public void testSpace() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); final String[] expected = { "36:19: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "36:23: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -118,8 +113,6 @@ public void testSpace() @Test public void testDefaultForIterator() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParenPadCheck.class); final String[] expected = { "24:35: " + getCheckMessage(MSG_WS_PRECEDED, ")"), "27:36: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -136,9 +129,6 @@ public void testDefaultForIterator() @Test public void testSpaceEmptyForIterator() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); final String[] expected = { "18:13: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "18:35: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -156,9 +146,6 @@ public void testSpaceEmptyForIterator() @Test public void test1322879() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputParenPadWithSpace.java"), @@ -167,9 +154,6 @@ public void test1322879() throws Exception { @Test public void testNospaceWithComplexInput() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("option", PadOption.NOSPACE.toString()); final String[] expected = { "55:26: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "55:28: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -299,9 +283,6 @@ public void testNospaceWithComplexInput() throws Exception { @Test public void testConfigureTokens() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("tokens", "METHOD_CALL"); final String[] expected = { "98:39: " + getCheckMessage(MSG_WS_PRECEDED, ")"), "121:22: " + getCheckMessage(MSG_WS_FOLLOWED, "("), @@ -336,8 +317,6 @@ public void testConfigureTokens() throws Exception { @Test public void testInvalidOption() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("option", "invalid_option"); try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -357,7 +336,6 @@ public void testInvalidOption() throws Exception { @Test public void testLambdaAssignment() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParenPadCheck.class); final String[] expected = { "20:41: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "20:45: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -378,8 +356,6 @@ public void testLambdaAssignment() throws Exception { @Test public void testLambdaAssignmentWithSpace() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); final String[] expected = { "20:41: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "20:43: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -398,8 +374,6 @@ public void testLambdaAssignmentWithSpace() throws Exception { @Test public void testLambdaCheckDisabled() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("tokens", "EXPR, METHOD_CALL, METHOD_DEF"); final String[] expected = { "27:61: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "27:63: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -412,9 +386,6 @@ public void testLambdaCheckDisabled() throws Exception { @Test public void testLambdaCheckDisabledWithSpace() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); - checkConfig.addProperty("tokens", "EXPR, METHOD_CALL, METHOD_DEF"); final String[] expected = { "30:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "30:33: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -425,8 +396,6 @@ public void testLambdaCheckDisabledWithSpace() throws Exception { @Test public void testLambdaCheckOnly() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("tokens", "LAMBDA"); final String[] expected = { "17:41: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "17:45: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -443,9 +412,6 @@ public void testLambdaCheckOnly() throws Exception { @Test public void testLambdaCheckOnlyWithSpace() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); - checkConfig.addProperty("tokens", "LAMBDA"); final String[] expected = { "17:41: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "17:43: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -462,8 +428,6 @@ public void testLambdaCheckOnlyWithSpace() throws Exception { @Test public void testLambdaCheckOnlyWithSpace1() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); final String[] expected = { "16:2: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), }; @@ -473,7 +437,6 @@ public void testLambdaCheckOnlyWithSpace1() throws Exception { @Test public void testTryWithResources() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParenPadCheck.class); final String[] expected = { "20:37: " + getCheckMessage(MSG_WS_PRECEDED, ")"), "21:61: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -493,7 +456,6 @@ public void testNoStackoverflowError() @Test public void testParenPadCheckRecords() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParenPadCheck.class); final String[] expected = { "20:21: " + getCheckMessage(MSG_WS_FOLLOWED, "("), @@ -516,8 +478,6 @@ public void testParenPadCheckRecords() throws Exception { @Test public void testParenPadCheckRecordsWithSpace() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(ParenPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); final String[] expected = { "25:19: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SeparatorWrapCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SeparatorWrapCheckTest.java index 2a9a7bca059..a80f994d335 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SeparatorWrapCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SeparatorWrapCheckTest.java @@ -28,7 +28,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.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -44,9 +43,6 @@ protected String getPackageLocation() { @Test public void testDot() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SeparatorWrapCheck.class); - checkConfig.addProperty("option", "NL"); - checkConfig.addProperty("tokens", "DOT"); final String[] expected = { "39:10: " + getCheckMessage(MSG_LINE_NEW, "."), }; @@ -56,9 +52,6 @@ public void testDot() @Test public void testComma() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SeparatorWrapCheck.class); - checkConfig.addProperty("option", "EOL"); - checkConfig.addProperty("tokens", "COMMA"); final String[] expected = { "47:17: " + getCheckMessage(MSG_LINE_PREVIOUS, ","), }; @@ -68,9 +61,6 @@ public void testComma() throws Exception { @Test public void testMethodRef() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SeparatorWrapCheck.class); - checkConfig.addProperty("option", "NL"); - checkConfig.addProperty("tokens", "METHOD_REF"); final String[] expected = { "25:56: " + getCheckMessage(MSG_LINE_NEW, "::"), }; @@ -91,8 +81,6 @@ public void testGetDefaultTokens() { @Test public void testInvalidOption() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SeparatorWrapCheck.class); - checkConfig.addProperty("option", "invalid_option"); try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -112,9 +100,6 @@ public void testInvalidOption() throws Exception { @Test public void testEllipsis() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SeparatorWrapCheck.class); - checkConfig.addProperty("option", "EOL"); - checkConfig.addProperty("tokens", "ELLIPSIS"); final String[] expected = { "19:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "..."), }; @@ -124,9 +109,6 @@ public void testEllipsis() throws Exception { @Test public void testArrayDeclarator() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(SeparatorWrapCheck.class); - checkConfig.addProperty("option", "EOL"); - checkConfig.addProperty("tokens", "ARRAY_DECLARATOR"); final String[] expected = { "17:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "["), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SingleSpaceSeparatorCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SingleSpaceSeparatorCheckTest.java index c9a8f625b72..2739bc398f2 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SingleSpaceSeparatorCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SingleSpaceSeparatorCheckTest.java @@ -37,8 +37,6 @@ protected String getPackageLocation() { @Test public void testNoSpaceErrors() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SingleSpaceSeparatorCheck.class); verifyWithInlineConfigParser( getPath("InputSingleSpaceSeparatorNoErrors.java"), CommonUtil.EMPTY_STRING_ARRAY); @@ -63,9 +61,6 @@ public void testGetAcceptableTokens() { @Test public void testSpaceErrors() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SingleSpaceSeparatorCheck.class); - checkConfig.addProperty("validateComments", "true"); final String[] expected = { "8:10: " + getCheckMessage(MSG_KEY), "8:28: " + getCheckMessage(MSG_KEY), @@ -107,9 +102,6 @@ public void testSpaceErrors() throws Exception { @Test public void testSpaceErrorsAroundComments() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SingleSpaceSeparatorCheck.class); - checkConfig.addProperty("validateComments", "true"); final String[] expected = { "12:11: " + getCheckMessage(MSG_KEY), "12:43: " + getCheckMessage(MSG_KEY), @@ -125,8 +117,6 @@ public void testSpaceErrorsAroundComments() throws Exception { @Test public void testSpaceErrorsInChildNodes() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SingleSpaceSeparatorCheck.class); final String[] expected = { "12:16: " + getCheckMessage(MSG_KEY), }; @@ -137,9 +127,6 @@ public void testSpaceErrorsInChildNodes() throws Exception { @Test public void testMinColumnNo() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SingleSpaceSeparatorCheck.class); - checkConfig.addProperty("validateComments", "true"); final String[] expected = { "12:4: " + getCheckMessage(MSG_KEY), }; @@ -150,8 +137,6 @@ public void testMinColumnNo() throws Exception { @Test public void testWhitespaceInStartOfTheLine() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SingleSpaceSeparatorCheck.class); final String[] expected = { "12:7: " + getCheckMessage(MSG_KEY), }; @@ -162,8 +147,6 @@ public void testWhitespaceInStartOfTheLine() throws Exception { @Test public void testSpaceErrorsIfCommentsIgnored() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SingleSpaceSeparatorCheck.class); final String[] expected = { "20:14: " + getCheckMessage(MSG_KEY), }; @@ -174,8 +157,6 @@ public void testSpaceErrorsIfCommentsIgnored() throws Exception { @Test public void testEmpty() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(SingleSpaceSeparatorCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheckTest.java index 98547aaec0b..e399421d3a5 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheckTest.java @@ -28,7 +28,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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -43,8 +42,6 @@ protected String getPackageLocation() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(TypecastParenPadCheck.class); final String[] expected = { "86:13: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "86:22: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -56,9 +53,6 @@ public void testDefault() @Test public void testSpace() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(TypecastParenPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); final String[] expected = { "84:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "84:27: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -75,9 +69,6 @@ public void testSpace() @Test public void test1322879() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(TypecastParenPadCheck.class); - checkConfig.addProperty("option", PadOption.SPACE.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputTypecastParenPadWhitespaceAround.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheckTest.java index 0cf2cee3bfb..422c357f44a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheckTest.java @@ -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.utils.CommonUtil; public class WhitespaceAfterCheckTest @@ -46,7 +45,6 @@ public void testGetRequiredTokens() { @Test public void testDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAfterCheck.class); final String[] expected = { "45:39: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), "74:29: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), @@ -58,9 +56,6 @@ public void testDefault() throws Exception { @Test public void testCast() throws Exception { - final DefaultConfiguration configurationTestCast = - createModuleConfig(WhitespaceAfterCheck.class); - configurationTestCast.addProperty("tokens", "TYPECAST"); final String[] expected = { "91:20: " + getCheckMessage(MSG_WS_TYPECAST), }; @@ -71,9 +66,6 @@ public void testCast() throws Exception { @Test public void testMultilineCast() throws Exception { - final DefaultConfiguration configurationTestCast = - createModuleConfig(WhitespaceAfterCheck.class); - configurationTestCast.addProperty("tokens", "TYPECAST"); final String[] expected = { "14:23: " + getCheckMessage(MSG_WS_TYPECAST), }; @@ -84,9 +76,6 @@ public void testMultilineCast() throws Exception { @Test public void testSemi() throws Exception { - final DefaultConfiguration configurationTestSemi = - createModuleConfig(WhitespaceAfterCheck.class); - configurationTestSemi.addProperty("tokens", "SEMI"); final String[] expected = { "57:22: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), "57:28: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), @@ -99,9 +88,6 @@ public void testSemi() throws Exception { @Test public void testLiteralWhile() throws Exception { - final DefaultConfiguration configurationTestLiteralWhile = - createModuleConfig(WhitespaceAfterCheck.class); - configurationTestLiteralWhile.addProperty("tokens", "LITERAL_WHILE"); final String[] expected = { "46:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"), }; @@ -112,9 +98,6 @@ public void testLiteralWhile() throws Exception { @Test public void testLiteralIf() throws Exception { - final DefaultConfiguration configurationTestLiteralIf = - createModuleConfig(WhitespaceAfterCheck.class); - configurationTestLiteralIf.addProperty("tokens", "LITERAL_IF"); final String[] expected = { "25:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "if"), }; @@ -125,9 +108,6 @@ public void testLiteralIf() throws Exception { @Test public void testLiteralElse() throws Exception { - final DefaultConfiguration configurationTestLiteralElse = - createModuleConfig(WhitespaceAfterCheck.class); - configurationTestLiteralElse.addProperty("tokens", "LITERAL_ELSE"); final String[] expected = { "34:11: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "else"), }; @@ -138,9 +118,6 @@ public void testLiteralElse() throws Exception { @Test public void testLiteralFor() throws Exception { - final DefaultConfiguration configurationTestLiteralFor = - createModuleConfig(WhitespaceAfterCheck.class); - configurationTestLiteralFor.addProperty("tokens", "LITERAL_FOR"); final String[] expected = { "58:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "for"), }; @@ -151,9 +128,6 @@ public void testLiteralFor() throws Exception { @Test public void testLiteralDo() throws Exception { - final DefaultConfiguration configurationTestLiteralDo = - createModuleConfig(WhitespaceAfterCheck.class); - configurationTestLiteralDo.addProperty("tokens", "LITERAL_DO"); final String[] expected = { "70:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "do"), }; @@ -164,9 +138,6 @@ public void testLiteralDo() throws Exception { @Test public void testDoWhile() throws Exception { - final DefaultConfiguration configurationTestDoWhile = - createModuleConfig(WhitespaceAfterCheck.class); - configurationTestDoWhile.addProperty("tokens", "DO_WHILE"); final String[] expected = { "25:11: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"), }; @@ -177,7 +148,6 @@ public void testDoWhile() throws Exception { @Test public void testEmptyForIterator() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAfterCheck.class); final String[] expected = { "18:30: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), "21:30: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), @@ -189,7 +159,6 @@ public void testEmptyForIterator() throws Exception { @Test public void testTypeArgumentAndParameterCommas() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAfterCheck.class); final String[] expected = { "20:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), "20:22: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), @@ -202,7 +171,6 @@ public void testTypeArgumentAndParameterCommas() throws Exception { @Test public void test1322879() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAfterCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputWhitespaceAfterAround.java"), @@ -211,7 +179,6 @@ public void test1322879() throws Exception { @Test public void testCountUnicodeCorrectly() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAfterCheck.class); final String[] expected = { "14:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundCheckTest.java index 8000af5c7a1..c1faf351883 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundCheckTest.java @@ -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; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -48,7 +47,6 @@ public void testGetRequiredTokens() { @Test public void testKeywordsAndOperators() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = { "32:22: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="), "32:22: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), @@ -98,7 +96,6 @@ public void testKeywordsAndOperators() @Test public void testSimpleInput() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = { "168:26: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), "169:26: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), @@ -114,7 +111,6 @@ public void testSimpleInput() @Test public void testStartOfTheLine() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = { "25:2: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), }; @@ -125,7 +121,6 @@ public void testStartOfTheLine() @Test public void testBraces() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = { "53:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"), "70:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "for"), @@ -147,9 +142,6 @@ public void testBraces() @Test public void testBracesInMethodsAndConstructors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("allowEmptyMethods", "true"); - checkConfig.addProperty("allowEmptyConstructors", "true"); final String[] expected = { "53:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"), "70:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "for"), @@ -165,8 +157,6 @@ public void testBracesInMethodsAndConstructors() @Test public void testArrayInitialization() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("tokens", "ARRAY_INIT"); final String[] expected = { "21:39: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), "25:37: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), @@ -184,7 +174,6 @@ public void testArrayInitialization() @Test public void testGenericsTokensAreFlagged() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = { "27:27: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "&"), "27:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "&"), @@ -195,7 +184,6 @@ public void testGenericsTokensAreFlagged() @Test public void test1322879And1649038() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputWhitespaceAround1.java"), @@ -204,7 +192,6 @@ public void test1322879And1649038() throws Exception { @Test public void testAllowDoubleBraceInitialization() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = { "31:73: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), "32:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), @@ -220,8 +207,6 @@ public void testAllowDoubleBraceInitialization() throws Exception { @Test public void testIgnoreEnhancedForColon() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("ignoreEnhancedForColon", "false"); final String[] expected = { "39:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ":"), }; @@ -232,8 +217,6 @@ public void testIgnoreEnhancedForColon() throws Exception { @Test public void testEmptyTypes() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("allowEmptyTypes", "true"); final String[] expected = { "45:94: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "45:95: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -249,8 +232,6 @@ public void testEmptyTypes() throws Exception { @Test public void testEmptyLoops() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("allowEmptyLoops", "true"); final String[] expected = { "56:65: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "56:66: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -270,7 +251,6 @@ public void testEmptyLoops() throws Exception { @Test public void testSwitchWhitespaceAround() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = { "26:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "switch"), }; @@ -280,7 +260,6 @@ public void testSwitchWhitespaceAround() throws Exception { @Test public void testDoWhileWhitespaceAround() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = { "29:11: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"), }; @@ -290,8 +269,6 @@ public void testDoWhileWhitespaceAround() throws Exception { @Test public void allowEmptyMethods() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("allowEmptyMethods", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputWhitespaceAround3.java"), expected); @@ -364,8 +341,6 @@ public void testGetAcceptableTokens() { @Test public void testAllowEmptyTypesIsSetToFalseAndNonEmptyClasses() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("allowEmptyTypes", "false"); final String[] expected = { "26:68: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), "30:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), @@ -390,8 +365,6 @@ public void testAllowEmptyTypesIsSetToFalseAndNonEmptyClasses() throws Exception @Test public void testAllowEmptyTypesIsSetToTrueAndNonEmptyClasses() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("allowEmptyTypes", "true"); final String[] expected = { "26:69: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), "30:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), @@ -412,7 +385,6 @@ public void testAllowEmptyTypesIsSetToTrueAndNonEmptyClasses() throws Exception @Test public void testNotAllowEmptyLambdaExpressionsByDefault() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = { "27:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "27:28: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -428,8 +400,6 @@ public void testNotAllowEmptyLambdaExpressionsByDefault() throws Exception { @Test public void testAllowEmptyLambdaExpressionsWithAllowEmptyLambdaParameter() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("allowEmptyLambdas", "true"); final String[] expected = { "32:28: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "32:30: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -443,7 +413,6 @@ public void testAllowEmptyLambdaExpressionsWithAllowEmptyLambdaParameter() throw @Test public void testWhitespaceAroundLambda() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = { "28:48: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "->"), "28:48: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "->"), @@ -454,8 +423,6 @@ public void testWhitespaceAroundLambda() throws Exception { @Test public void testWhitespaceAroundEmptyCatchBlock() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("allowEmptyCatches", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputWhitespaceAroundCatch.java"), @@ -464,8 +431,6 @@ public void testWhitespaceAroundEmptyCatchBlock() throws Exception { @Test public void testWhitespaceAroundVarargs() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("tokens", "ELLIPSIS"); final String[] expected = { "19:36: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "..."), "20:37: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "..."), @@ -483,7 +448,6 @@ public void testWhitespaceAroundVarargs() throws Exception { @Test public void testWhitespaceAroundRecords() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); final String[] expected = { "26:23: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "26:24: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -514,8 +478,6 @@ public void testWhitespaceAroundRecords() @Test public void testWhitespaceAroundAllowEmptyCompactCtors() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("allowEmptyConstructors", "true"); final String[] expected = { "26:23: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "26:24: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -547,8 +509,6 @@ public void testWhitespaceAroundAllowEmptyCompactCtors() @Test public void testWhitespaceAroundRecordsAllowEmptyTypes() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("allowEmptyTypes", "true"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputWhitespaceAroundRecordsAllowEmptyTypes.java"), @@ -557,18 +517,6 @@ public void testWhitespaceAroundRecordsAllowEmptyTypes() @Test public void testWhitespaceAroundAllTokens() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class); - checkConfig.addProperty("tokens", "ASSIGN, ARRAY_INIT, BAND, BAND_ASSIGN, BOR, " - + "BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, " - + "DO_WHILE, EQUAL, GE, GT, LAMBDA, LAND, LCURLY, LE, LITERAL_CATCH, LITERAL_DO, " - + "LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, " - + "LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, " - + "MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, " - + "RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, " - + "LITERAL_ASSERT, TYPE_EXTENSION_AND, WILDCARD_TYPE, GENERIC_START, GENERIC_END, " - + "ELLIPSIS"); - checkConfig.addProperty("allowEmptyTypes", "true"); - checkConfig.addProperty("allowEmptyCatches", "true"); final String[] expected = { "27:29: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "<"), "27:29: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "<"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/EmbeddedNullCharTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/EmbeddedNullCharTest.java index da91898e52c..7d666b06f54 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/EmbeddedNullCharTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/EmbeddedNullCharTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** @@ -40,8 +38,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmbeddedNullChar.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/GeneratedJava14LexerTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/GeneratedJava14LexerTest.java index 7e5064548ec..6efa024e71b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/GeneratedJava14LexerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/GeneratedJava14LexerTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -54,8 +53,6 @@ public void testUnexpectedChar() throws Exception { // Encoding problems will occur if default encoding is not UTF-8 Assumptions.assumeTrue(IS_UTF8, "Problems with encoding may occur"); - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); // input is 'ÃЯ' final String[] expected = { "18:9: " + getCheckMessage(MemberNameCheck.class, MSG_INVALID_PATTERN, @@ -66,8 +63,6 @@ public void testUnexpectedChar() throws Exception { @Test public void testSemicolonBetweenImports() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputSemicolonBetweenImports.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/HexFloatsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/HexFloatsTest.java index 0c7373f04dc..6ea559f5f58 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/HexFloatsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/HexFloatsTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** @@ -40,8 +38,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputHexFloat.java"), expected); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java14RecordsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java14RecordsTest.java index 6eb4a23d47e..bff7f661453 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java14RecordsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java14RecordsTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class Java14RecordsTest extends AbstractModuleTestSupport { @@ -36,8 +34,6 @@ protected String getPackageLocation() { @Test public void testJava14Records() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputJava14Records.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7DiamondTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7DiamondTest.java index 9b59e7a7356..c98091b83f5 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7DiamondTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7DiamondTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** @@ -40,8 +38,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJava7Diamond.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7MultiCatchTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7MultiCatchTest.java index 50094053d2e..345d8b5de70 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7MultiCatchTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7MultiCatchTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** @@ -40,8 +38,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJava7MultiCatch.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7NumericalLiteralsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7NumericalLiteralsTest.java index bb38f450fbd..a889455204b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7NumericalLiteralsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7NumericalLiteralsTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** @@ -40,8 +38,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJava7NumericalLiterals.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7StringSwitchTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7StringSwitchTest.java index 4ba872f8dd9..0cc951a7e2f 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7StringSwitchTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7StringSwitchTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** @@ -40,8 +38,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJava7StringSwitch.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7TryWithResourcesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7TryWithResourcesTest.java index c8bcac2c470..eca707fe120 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7TryWithResourcesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7TryWithResourcesTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** @@ -40,8 +38,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJava7TryWithResources.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java9TryWithResourcesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java9TryWithResourcesTest.java index c99ee18029a..24169d9bf4d 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java9TryWithResourcesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java9TryWithResourcesTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** @@ -38,8 +36,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputJava9TryWithResources.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/LineCommentAtTheEndOfFileTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/LineCommentAtTheEndOfFileTest.java index 712f5be58eb..a686c066b1d 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/LineCommentAtTheEndOfFileTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/LineCommentAtTheEndOfFileTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** @@ -42,8 +40,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputLineCommentAtTheEndOfFile.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/MultiDimensionalArraysInGenericsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/MultiDimensionalArraysInGenericsTest.java index b51fd5183ea..a17453b4a36 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/MultiDimensionalArraysInGenericsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/MultiDimensionalArraysInGenericsTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class MultiDimensionalArraysInGenericsTest @@ -37,8 +35,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMultiDimensionalArraysInGenerics.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/UnicodeEscapeTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/UnicodeEscapeTest.java index 75b20cff08d..075de510c56 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/UnicodeEscapeTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/UnicodeEscapeTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** @@ -40,8 +38,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputUnicodeEscape.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/VarargTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/VarargTest.java index 6a0c2206901..1840a0da41b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/VarargTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/VarargTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** @@ -40,8 +38,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputVararg.java"), expected); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationTest.java index 706d10583ce..06ac2a411fd 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class AnnotationTest extends AbstractModuleTestSupport { @@ -36,8 +34,6 @@ protected String getPackageLocation() { @Test public void testSimpleTypeAnnotation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations1.java"), expected); } @@ -45,8 +41,6 @@ public void testSimpleTypeAnnotation() @Test public void testAnnotationOnClass() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations2.java"), expected); } @@ -54,8 +48,6 @@ public void testAnnotationOnClass() @Test public void testClassCastTypeAnnotation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations3.java"), expected); } @@ -63,8 +55,6 @@ public void testClassCastTypeAnnotation() @Test public void testMethodParametersTypeAnnotation() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations4.java"), expected); } @@ -72,8 +62,6 @@ public void testMethodParametersTypeAnnotation() @Test public void testAnnotationInThrows() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations5.java"), expected); } @@ -81,8 +69,6 @@ public void testAnnotationInThrows() @Test public void testAnnotationInGeneric() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations6.java"), expected); } @@ -90,8 +76,6 @@ public void testAnnotationInGeneric() @Test public void testAnnotationOnConstructorCall() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations7.java"), expected); } @@ -99,8 +83,6 @@ public void testAnnotationOnConstructorCall() @Test public void testAnnotationNestedCall() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations8.java"), expected); } @@ -108,8 +90,6 @@ public void testAnnotationNestedCall() @Test public void testAnnotationOnWildcards() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations9.java"), expected); } @@ -117,8 +97,6 @@ public void testAnnotationOnWildcards() @Test public void testAnnotationInCatchParameters() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations10.java"), expected); } @@ -126,8 +104,6 @@ public void testAnnotationInCatchParameters() @Test public void testAnnotationInTypeParameters() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations11.java"), expected); } @@ -135,8 +111,6 @@ public void testAnnotationInTypeParameters() @Test public void testAnnotationOnVarargs() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations12.java"), expected); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationsOnArrayTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationsOnArrayTest.java index 951cac37ab4..22cce9778ea 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationsOnArrayTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationsOnArrayTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class AnnotationsOnArrayTest extends AbstractModuleTestSupport { @@ -36,8 +34,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputAnnotationsOnArray.java"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/DefaultMethodsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/DefaultMethodsTest.java index a90fb84bb04..f5cca56d23b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/DefaultMethodsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/DefaultMethodsTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class DefaultMethodsTest extends AbstractModuleTestSupport { @@ -36,8 +34,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputDefaultMethods.java"), expected); @@ -46,8 +42,6 @@ public void testCanParse() @Test public void testSwitch() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputDefaultMethods2.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/LambdaTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/LambdaTest.java index b7e09d64010..dbbd91d0bd9 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/LambdaTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/LambdaTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class LambdaTest extends AbstractModuleTestSupport { @@ -36,8 +34,6 @@ protected String getPackageLocation() { @Test public void testLambdaInVariableInitialization() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda1.java"), expected); } @@ -45,8 +41,6 @@ public void testLambdaInVariableInitialization() @Test public void testWithoutArgsOneLineLambdaBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda2.java"), expected); } @@ -54,8 +48,6 @@ public void testWithoutArgsOneLineLambdaBody() @Test public void testWithoutArgsFullLambdaBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda3.java"), expected); } @@ -63,8 +55,6 @@ public void testWithoutArgsFullLambdaBody() @Test public void testWithOneArgWithOneLineBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda4.java"), expected); } @@ -72,8 +62,6 @@ public void testWithOneArgWithOneLineBody() @Test public void testWithOneArgWithFullBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda5.java"), expected); } @@ -81,8 +69,6 @@ public void testWithOneArgWithFullBody() @Test public void testWithOneArgWithoutTypeOneLineBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda6.java"), expected); } @@ -90,8 +76,6 @@ public void testWithOneArgWithoutTypeOneLineBody() @Test public void testWithOneArgWithoutTypeFullBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda7.java"), expected); } @@ -99,8 +83,6 @@ public void testWithOneArgWithoutTypeFullBody() @Test public void testWithFewArgsWithoutTypeOneLineBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda8.java"), expected); } @@ -108,8 +90,6 @@ public void testWithFewArgsWithoutTypeOneLineBody() @Test public void testWithFewArgsWithoutTypeFullBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda9.java"), expected); } @@ -117,8 +97,6 @@ public void testWithFewArgsWithoutTypeFullBody() @Test public void testWithOneArgWithoutParenthesesWithoutTypeOneLineBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda10.java"), expected); } @@ -126,8 +104,6 @@ public void testWithOneArgWithoutParenthesesWithoutTypeOneLineBody() @Test public void testWithOneArgWithoutParenthesesWithoutTypeFullBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda11.java"), expected); } @@ -135,8 +111,6 @@ public void testWithOneArgWithoutParenthesesWithoutTypeFullBody() @Test public void testWithFewArgWithTypeOneLine() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda12.java"), expected); } @@ -144,8 +118,6 @@ public void testWithFewArgWithTypeOneLine() @Test public void testWithFewArgWithTypeFullBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda13.java"), expected); } @@ -153,8 +125,6 @@ public void testWithFewArgWithTypeFullBody() @Test public void testWithMultilineBody() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda14.java"), expected); } @@ -162,8 +132,6 @@ public void testWithMultilineBody() @Test public void testCasesFromSpec() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda15.java"), expected); } @@ -171,8 +139,6 @@ public void testCasesFromSpec() @Test public void testWithTypecast() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda16.java"), expected); } @@ -180,8 +146,6 @@ public void testWithTypecast() @Test public void testInAssignment() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda17.java"), expected); } @@ -189,8 +153,6 @@ public void testInAssignment() @Test public void testInTernary() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda18.java"), expected); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/MethodReferencesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/MethodReferencesTest.java index e72beae73ff..abd46916f3b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/MethodReferencesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/MethodReferencesTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class MethodReferencesTest extends AbstractModuleTestSupport { @@ -36,8 +34,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMethodReferences.java"), expected); @@ -46,8 +42,6 @@ public void testCanParse() @Test public void testFromSpec() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMethodReferences2.java"), expected); @@ -56,8 +50,6 @@ public void testFromSpec() @Test public void testGenericInPostfixExpressionBeforeReference() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMethodReferences3.java"), expected); @@ -66,7 +58,6 @@ public void testGenericInPostfixExpressionBeforeReference() @Test public void testArrayAfterGeneric() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMethodReferences4.java"), expected); @@ -75,7 +66,6 @@ public void testArrayAfterGeneric() @Test public void testFromHibernate() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMethodReferences5.java"), expected); @@ -84,7 +74,6 @@ public void testFromHibernate() @Test public void testFromSpring() throws Exception { - final DefaultConfiguration checkConfig = createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMethodReferences6.java"), expected); @@ -93,8 +82,6 @@ public void testFromSpring() @Test public void testMethodReferences7() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMethodReferences7.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/ReceiverParameterTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/ReceiverParameterTest.java index 8e0c7b77423..466515712dd 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/ReceiverParameterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/ReceiverParameterTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class ReceiverParameterTest extends AbstractModuleTestSupport { @@ -36,8 +34,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputReceiverParameter.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/TypeUseAnnotationsOnQualifiedTypesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/TypeUseAnnotationsOnQualifiedTypesTest.java index bd57f49b206..d8f59130390 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/TypeUseAnnotationsOnQualifiedTypesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/TypeUseAnnotationsOnQualifiedTypesTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; -import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; public class TypeUseAnnotationsOnQualifiedTypesTest extends AbstractModuleTestSupport { @@ -36,8 +34,6 @@ protected String getPackageLocation() { @Test public void testCanParse() throws Exception { - final DefaultConfiguration checkConfig = - createModuleConfig(MemberNameCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputTypeUseAnnotationsOnQualifiedTypes.java"),