Search in sources :

Example 11 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class WhitespaceAroundTest method whitespaceAroundEmptyTypesCyclesTest.

@Test
public void whitespaceAroundEmptyTypesCyclesTest() throws Exception {
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    final Configuration checkConfig = getCheckConfig("WhitespaceAround");
    final String filePath = getPath("InputWhitespaceAroundEmptyTypesAndCycles.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 12 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class VariableDeclarationUsageDistanceTest method arrayTypeStyleTest.

@Test
public void arrayTypeStyleTest() throws Exception {
    final String msgExt = "variable.declaration.usage.distance.extend";
    final Class<VariableDeclarationUsageDistanceCheck> clazz = VariableDeclarationUsageDistanceCheck.class;
    final String[] expected = { "71: " + getCheckMessage(clazz, msgExt, "count", 4, 3), "219: " + getCheckMessage(clazz, msgExt, "t", 5, 3), "479: " + getCheckMessage(clazz, msgExt, "myOption", 7, 3), "491: " + getCheckMessage(clazz, msgExt, "myOption", 6, 3) };
    final Configuration checkConfig = getCheckConfig("VariableDeclarationUsageDistance");
    final String filePath = getPath("InputVariableDeclarationUsageDistanceCheck.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : VariableDeclarationUsageDistanceCheck(com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck) Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 13 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class ArrayTypeStyleTest method arrayTypeStyleTest.

@Test
public void arrayTypeStyleTest() throws Exception {
    final String[] expected = { "9:23: " + getCheckMessage(ArrayTypeStyleCheck.class, MSG_KEY), "15:44: " + getCheckMessage(ArrayTypeStyleCheck.class, MSG_KEY), "21:20: " + getCheckMessage(ArrayTypeStyleCheck.class, MSG_KEY), "22:23: " + getCheckMessage(ArrayTypeStyleCheck.class, MSG_KEY), "41:16: " + getCheckMessage(ArrayTypeStyleCheck.class, MSG_KEY), "42:19: " + getCheckMessage(ArrayTypeStyleCheck.class, MSG_KEY) };
    final Configuration checkConfig = getCheckConfig("ArrayTypeStyle");
    final String filePath = getPath("InputArrayTypeStyle.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 14 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class EmptyBlockTest method emptyBlockTestCatch.

@Test
public void emptyBlockTestCatch() throws Exception {
    final String[] expected = { "29:17: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "finally"), "50:21: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "finally"), "72:21: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "finally") };
    final Configuration checkConfig = getCheckConfig("EmptyBlock");
    final String filePath = getPath("InputEmptyBlock.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 15 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class EmptyBlockTest method emptyBlockTest.

@Test
public void emptyBlockTest() throws Exception {
    final String[] expected = { "19:21: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "22:34: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "26:21: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "28:20: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "switch"), "68:25: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "71:38: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "75:25: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "77:24: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "switch"), "98:29: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "101:42: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "105:29: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "107:28: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "switch"), "126:16: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "else"), "172:28: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "173:14: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "else"), "175:21: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "179:14: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "else"), "181:21: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "182:26: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "195:20: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "else"), "241:32: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "242:18: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "else"), "244:25: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "248:18: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "else"), "250:25: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "251:30: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "264:24: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "else"), "310:36: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "311:22: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "else"), "313:29: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "317:22: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "else"), "319:29: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "320:34: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if") };
    final Configuration checkConfig = getCheckConfig("EmptyBlock");
    final String filePath = getPath("InputEmptyBlockBasic.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Aggregations

Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)307 Test (org.junit.jupiter.api.Test)179 Test (org.junit.Test)100 DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)34 Properties (java.util.Properties)21 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)16 File (java.io.File)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 PropertiesExpander (com.puppycrawl.tools.checkstyle.PropertiesExpander)11 Checker (com.puppycrawl.tools.checkstyle.Checker)9 HashSet (java.util.HashSet)8 InputSource (org.xml.sax.InputSource)7 OneTopLevelClassCheck (com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 ConfigurationLoader (com.puppycrawl.tools.checkstyle.ConfigurationLoader)5 URI (java.net.URI)5 MethodParamPadCheck (com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck)4 Set (java.util.Set)4 ModuleFactory (com.puppycrawl.tools.checkstyle.ModuleFactory)3