Search in sources :

Example 36 with Configuration

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

the class AbbreviationAsWordInNameTest method abbreviationAsWordInNameTest.

@Test
public void abbreviationAsWordInNameTest() throws Exception {
    final int maxCapitalCount = 2;
    final String[] expected = { "50: " + getWarningMessage("newCustomerID", maxCapitalCount), "52: " + getWarningMessage("supportsIPv6OnIOS", maxCapitalCount), "54: " + getWarningMessage("XMLHTTPRequest", maxCapitalCount), "58: " + getWarningMessage("newCustomerID", maxCapitalCount), "60: " + getWarningMessage("supportsIPv6OnIOS", maxCapitalCount), "62: " + getWarningMessage("XMLHTTPRequest", maxCapitalCount), "67: " + getWarningMessage("newCustomerID", maxCapitalCount), "69: " + getWarningMessage("supportsIPv6OnIOS", maxCapitalCount), "71: " + getWarningMessage("XMLHTTPRequest", maxCapitalCount) };
    final String filePath = getPath("InputAbbreviationAsWordInTypeNameCheck.java");
    final Configuration checkConfig = getCheckConfig("AbbreviationAsWordInName");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 37 with Configuration

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

the class OverloadMethodsDeclarationOrderTest method overloadMethodsTest.

@Test
public void overloadMethodsTest() throws Exception {
    final Class<OverloadMethodsDeclarationOrderCheck> clazz = OverloadMethodsDeclarationOrderCheck.class;
    final String messageKey = "overload.methods.declaration";
    final String[] expected = { "26: " + getCheckMessage(clazz, messageKey, 15), "54: " + getCheckMessage(clazz, messageKey, 43), "66: " + getCheckMessage(clazz, messageKey, 64), "109: " + getCheckMessage(clazz, messageKey, 98) };
    final Configuration checkConfig = getCheckConfig("OverloadMethodsDeclarationOrder");
    final String filePath = getPath("InputOverloadMethodsDeclarationOrder.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) OverloadMethodsDeclarationOrderCheck(com.puppycrawl.tools.checkstyle.checks.coding.OverloadMethodsDeclarationOrderCheck) Test(org.junit.Test)

Example 38 with Configuration

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

the class NeedBracesTest method needBracesTest.

@Test
public void needBracesTest() throws Exception {
    final Class<NeedBracesCheck> clazz = NeedBracesCheck.class;
    final String messageKey = "needBraces";
    final String[] expected = { "29: " + getCheckMessage(clazz, messageKey, "do"), "41: " + getCheckMessage(clazz, messageKey, "while"), "42: " + getCheckMessage(clazz, messageKey, "while"), "44: " + getCheckMessage(clazz, messageKey, "while"), "45: " + getCheckMessage(clazz, messageKey, "if"), "58: " + getCheckMessage(clazz, messageKey, "for"), "59: " + getCheckMessage(clazz, messageKey, "for"), "61: " + getCheckMessage(clazz, messageKey, "for"), "63: " + getCheckMessage(clazz, messageKey, "if"), "82: " + getCheckMessage(clazz, messageKey, "if"), "83: " + getCheckMessage(clazz, messageKey, "if"), "85: " + getCheckMessage(clazz, messageKey, "if"), "87: " + getCheckMessage(clazz, messageKey, "else"), "89: " + getCheckMessage(clazz, messageKey, "if"), "97: " + getCheckMessage(clazz, messageKey, "else"), "99: " + getCheckMessage(clazz, messageKey, "if"), "100: " + getCheckMessage(clazz, messageKey, "if"), "126: " + getCheckMessage(clazz, messageKey, "while"), "129: " + getCheckMessage(clazz, messageKey, "do"), "135: " + getCheckMessage(clazz, messageKey, "if"), "138: " + getCheckMessage(clazz, messageKey, "if"), "139: " + getCheckMessage(clazz, messageKey, "else"), "144: " + getCheckMessage(clazz, messageKey, "for"), "147: " + getCheckMessage(clazz, messageKey, "for"), "157: " + getCheckMessage(clazz, messageKey, "while"), "160: " + getCheckMessage(clazz, messageKey, "do"), "166: " + getCheckMessage(clazz, messageKey, "if"), "169: " + getCheckMessage(clazz, messageKey, "if"), "170: " + getCheckMessage(clazz, messageKey, "else"), "175: " + getCheckMessage(clazz, messageKey, "for"), "178: " + getCheckMessage(clazz, messageKey, "for"), "189: " + getCheckMessage(clazz, messageKey, "while"), "192: " + getCheckMessage(clazz, messageKey, "do"), "198: " + getCheckMessage(clazz, messageKey, "if"), "201: " + getCheckMessage(clazz, messageKey, "if"), "202: " + getCheckMessage(clazz, messageKey, "else"), "207: " + getCheckMessage(clazz, messageKey, "for"), "210: " + getCheckMessage(clazz, messageKey, "for") };
    final Configuration checkConfig = getCheckConfig("NeedBraces");
    final String filePath = getPath("InputNeedBraces.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : NeedBracesCheck(com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck) Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 39 with Configuration

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

the class LeftCurlyTest method leftCurlyBracesTest.

@Test
public void leftCurlyBracesTest() throws Exception {
    final String[] expected = { "4:1: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 1), "7:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "13:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "26:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "43:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "61:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "97:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5) };
    final Configuration checkConfig = getCheckConfig("LeftCurly");
    final String filePath = getPath("InputLeftCurlyBraces.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 40 with Configuration

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

the class LeftCurlyTest method leftCurlyMethodsTest.

@Test
public void leftCurlyMethodsTest() throws Exception {
    final String[] expected = { "4:1: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 1), "9:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "16:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "19:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "23:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "31:1: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 1), "33:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "38:9: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 9), "41:9: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 9), "45:9: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 9), "57:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "61:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "69:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "72:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "76:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5) };
    final Configuration checkConfig = getCheckConfig("LeftCurly");
    final String filePath = getPath("InputLeftCurlyMethod.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