当前位置: 首页>>代码示例>>Java>>正文


Java DefaultConfiguration类代码示例

本文整理汇总了Java中com.puppycrawl.tools.checkstyle.DefaultConfiguration的典型用法代码示例。如果您正苦于以下问题:Java DefaultConfiguration类的具体用法?Java DefaultConfiguration怎么用?Java DefaultConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultConfiguration类属于com.puppycrawl.tools.checkstyle包,在下文中一共展示了DefaultConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDefault

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
public void testDefault() throws Exception
{
    final DefaultConfiguration checkConfig =
        createCheckConfig(UnusedPrivateMethodCheck.class);
    final String[] expected = {
        "7:18: Unused private method 'methodUnused0'.",
        "66:18: Unused private method 'writeObject'.",
        "71:18: Unused private method 'readObject'.",
        "76:20: Unused private method 'writeReplace'.",
        "82:20: Unused private method 'readResolve'.",
        "91:18: Unused private method 'writeObject'.",
        "95:18: Unused private method 'writeObject'.",
        "99:18: Unused private method 'writeObject'.",
        "103:18: Unused private method 'readObject'.",
        "107:18: Unused private method 'readObject'.",
        "111:17: Unused private method 'writeReplace'.",
        "116:20: Unused private method 'writeReplace'.",
        "121:17: Unused private method 'readResolve'.",
        "126:20: Unused private method 'readResolve'.",
        "134:17: Unused private method 'writeObject'.",
        "139:18: Unused private method 'readObject'.",
        "143:20: Unused private method 'readResolve'.",
        "151:17: Unused private method 'readObject'.",
    };
    verify(checkConfig, getPath("usage/InputUnusedMethod.java"), expected);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:UnusedPrivateMethodCheckTest.java

示例2: testAllowSerializationMethods

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
public void testAllowSerializationMethods() throws Exception
{
    final DefaultConfiguration checkConfig =
        createCheckConfig(UnusedPrivateMethodCheck.class);
    checkConfig.addAttribute("allowSerializationMethods", "true");

    final String[] expected = {
        "7:18: Unused private method 'methodUnused0'.",
        "91:18: Unused private method 'writeObject'.",
        "95:18: Unused private method 'writeObject'.",
        "99:18: Unused private method 'writeObject'.",
        "103:18: Unused private method 'readObject'.",
        "107:18: Unused private method 'readObject'.",
        "111:17: Unused private method 'writeReplace'.",
        "116:20: Unused private method 'writeReplace'.",
        "121:17: Unused private method 'readResolve'.",
        "126:20: Unused private method 'readResolve'.",
        "134:17: Unused private method 'writeObject'.",
        "139:18: Unused private method 'readObject'.",
        "143:20: Unused private method 'readResolve'.",
        "151:17: Unused private method 'readObject'.",
    };
    verify(checkConfig, getPath("usage/InputUnusedMethod.java"), expected);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:UnusedPrivateMethodCheckTest.java

示例3: testDefault

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
public void testDefault() throws Exception
{
    final DefaultConfiguration checkConfig =
        createCheckConfig(OneMethodPrivateFieldCheck.class);
    final String[] expected = {
        "6:24: Field 'SFIELD0' is used in only one method.",
        "7:24: Field 'SFIELD1' is used in only one method.",
        "8:24: Field 'SFIELD2' is used in only one method.",
        "9:24: Field 'SFIELD3' is used in only one method.",
        "11:17: Field 'mField0' is used in only one method.",
        "12:17: Field 'mField1' is used in only one method.",
        "13:17: Field 'mField2' is used in only one method.",
        "47:17: Field 'mField0' is used in only one method.",
        "48:17: Field 'mField1' is used in only one method.",
        "49:17: Field 'mField2' is used in only one method.",
        "105:19: Field 'mField' is used in only one method.",
    };
    verify(checkConfig, getPath("usage/InputOneMethodPrivateField.java"), expected);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:OneMethodPrivateFieldCheckTest.java

示例4: testIgnoreFormat

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
public void testIgnoreFormat() throws Exception
{
    final DefaultConfiguration checkConfig =
        createCheckConfig(OneMethodPrivateFieldCheck.class);
    checkConfig.addAttribute("ignoreFormat", "2$");
    final String[] expected = {
        "6:24: Field 'SFIELD0' is used in only one method.",
        "7:24: Field 'SFIELD1' is used in only one method.",
        "9:24: Field 'SFIELD3' is used in only one method.",
        "11:17: Field 'mField0' is used in only one method.",
        "12:17: Field 'mField1' is used in only one method.",
        "47:17: Field 'mField0' is used in only one method.",
        "48:17: Field 'mField1' is used in only one method.",
        "105:19: Field 'mField' is used in only one method.",
     };
    verify(checkConfig, getPath("usage/InputOneMethodPrivateField.java"), expected);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:OneMethodPrivateFieldCheckTest.java

示例5: testNestedClassConsInPublicInterfaceHasValidPublicModifier

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testNestedClassConsInPublicInterfaceHasValidPublicModifier() throws Exception {
    final DefaultConfiguration checkConfig =
            createModuleConfig(RedundantModifierCheck.class);

    final String[] expected = {
        "18:33: " + getCheckMessage(MSG_KEY, "public"),
        "22:41: " + getCheckMessage(MSG_KEY, "public"),
        "33:33: " + getCheckMessage(MSG_KEY, "public"),
        "41:33: " + getCheckMessage(MSG_KEY, "public"),
    };

    verify(checkConfig,
        getPath("InputRedundantModifierNestedClassInPublicInterfaceRedundantModifiers.java"),
        expected);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:RedundantModifierCheckTest.java

示例6: testInvalidOption

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testInvalidOption() throws Exception {
    final DefaultConfiguration checkConfig = createModuleConfig(EmptyForIteratorPadCheck.class);
    checkConfig.addAttribute("option", "invalid_option");

    try {
        final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;

        verify(checkConfig, getPath("InputEmptyForIteratorPad.java"), expected);
        fail("exception expected");
    }
    catch (CheckstyleException ex) {
        final String messageStart = "cannot initialize module "
            + "com.puppycrawl.tools.checkstyle.TreeWalker - Cannot set property 'option' to "
            + "'invalid_option' in module";
        assertTrue("Invalid exception message, should start with: ",
            ex.getMessage().startsWith(messageStart));
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:EmptyForIteratorPadCheckTest.java

示例7: testLegalAbstractClassNames

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testLegalAbstractClassNames() throws Exception {
    final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class);
    checkConfig.addAttribute("validateAbstractClassNames", "true");
    checkConfig.addAttribute("legalAbstractClassNames", "AbstractClass");

    final String[] expected = {
        "9:13: " + getCheckMessage(MSG_KEY,
            "com.puppycrawl.tools.checkstyle.checks.coding.illegaltype."
                + "InputIllegalType.AbstractClass"),
        "16:13: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"),
        "17:13: " + getCheckMessage(MSG_KEY, "TreeSet"),
    };

    verify(checkConfig, getPath("InputIllegalType.java"), expected);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:IllegalTypeCheckTest.java

示例8: testLineBreakAfter

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testLineBreakAfter() throws Exception {
    final DefaultConfiguration checkConfig = createModuleConfig(LeftCurlyCheck.class);
    checkConfig.addAttribute("option", LeftCurlyOption.EOL.toString());
    final String[] expected = {
        "9:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1),
        "12:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
        "16:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 9),
        "18:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 13),
        "20:17: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 17),
        "26:22: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 22),
        "28:17: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 17),
        "35:33: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 33),
        "36:21: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 21),
        "39:29: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 29),
        "39:34: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 34),
        "45:37: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 37),
        "51:12: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 12),
        "54:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
        "56:19: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 19),
        "66:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1),
    };
    verify(checkConfig, getPath("InputLeftCurlyLineBreakAfter.java"), expected);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:25,代码来源:LeftCurlyCheckTest.java

示例9: testSpaceErrorsAroundComments

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testSpaceErrorsAroundComments() throws Exception {
    final DefaultConfiguration checkConfig =
            createModuleConfig(SingleSpaceSeparatorCheck.class);
    checkConfig.addAttribute("validateComments", "true");
    final String[] expected = {
        "5:10: " + getCheckMessage(MSG_KEY),
        "5:42: " + getCheckMessage(MSG_KEY),
        "6:13: " + getCheckMessage(MSG_KEY),
        "13:13: " + getCheckMessage(MSG_KEY),
        "13:20: " + getCheckMessage(MSG_KEY),
        "14:7: " + getCheckMessage(MSG_KEY),
    };

    verify(checkConfig, getPath("InputSingleSpaceSeparatorComments.java"), expected);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:SingleSpaceSeparatorCheckTest.java

示例10: testValidIfWithChecker

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testValidIfWithChecker() throws Exception {
    final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);

    checkConfig.addAttribute("arrayInitIndent", "4");
    checkConfig.addAttribute("basicOffset", "4");
    checkConfig.addAttribute("braceAdjustment", "0");
    checkConfig.addAttribute("caseIndent", "4");
    checkConfig.addAttribute("forceStrictCondition", "false");
    checkConfig.addAttribute("lineWrappingIndentation", "4");
    checkConfig.addAttribute("tabWidth", "4");
    checkConfig.addAttribute("throwsIndent", "4");
    final String fileName = getPath("InputIndentationValidIfIndent.java");
    final String[] expected = {
        "231: " + getCheckMessage(MSG_ERROR, "(", 8, 12),
    };
    verifyWarns(checkConfig, fileName, expected);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:IndentationCheckTest.java

示例11: testSamePackageDepthNegative

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testSamePackageDepthNegative() throws Exception {
    final DefaultConfiguration checkConfig =
            createModuleConfig(CustomImportOrderCheck.class);
    checkConfig.addAttribute("sortImportsInGroupAlphabetically", "false");
    checkConfig.addAttribute("separateLineBetweenGroups", "false");
    checkConfig.addAttribute("customImportOrderRules",
            "SAME_PACKAGE(-1)");

    try {
        final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;

        verify(checkConfig, getPath("InputCustomImportOrderDefault.java"), expected);
        fail("exception expected");
    }
    catch (CheckstyleException ex) {
        final String messageStart =
            "cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
                + "Cannot set property 'customImportOrderRules' to "
                + "'SAME_PACKAGE(-1)' in module";
        assertTrue("Invalid exception message, should start with: " + messageStart,
            ex.getMessage().startsWith(messageStart));
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:25,代码来源:CustomImportOrderCheckTest.java

示例12: testSpecified

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testSpecified()
        throws Exception {
    final DefaultConfiguration checkConfig =
        createModuleConfig(ParameterNameCheck.class);
    checkConfig.addAttribute("format", "^a[A-Z][a-zA-Z0-9]*$");

    final String pattern = "^a[A-Z][a-zA-Z0-9]*$";

    final String[] expected = {
        "71:19: " + getCheckMessage(MSG_INVALID_PATTERN, "badFormat1", pattern),
        "71:34: " + getCheckMessage(MSG_INVALID_PATTERN, "badFormat2", pattern),
        "72:25: " + getCheckMessage(MSG_INVALID_PATTERN, "badFormat3", pattern),
    };
    verify(checkConfig, getPath("InputParameterName.java"), expected);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:ParameterNameCheckTest.java

示例13: testPossibleIndexOutOfBoundsException

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testPossibleIndexOutOfBoundsException() throws Exception {
    final DefaultConfiguration checkConfig =
            createModuleConfig(CustomImportOrderCheck.class);
    checkConfig.addAttribute("thirdPartyPackageRegExp", ".*");
    checkConfig.addAttribute("specialImportsRegExp", "com.google");
    checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true");
    checkConfig.addAttribute("customImportOrderRules",
            "STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE");
    final String[] expected = {
        "5: " + getCheckMessage(MSG_NONGROUP_EXPECTED, THIRD, "org.w3c.dom.Node"),
    };

    verify(checkConfig,
        getPath("InputCustomImportOrderPossibleIndexOutOfBoundsException.java"), expected);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:CustomImportOrderCheckTest.java

示例14: testNullFilename

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testNullFilename() throws Exception {
    final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class);
    checkConfig.addAttribute("headerFile", null);
    try {
        createChecker(checkConfig);
        fail("Checker creation should not succeed with null headerFile");
    }
    catch (CheckstyleException ex) {
        assertEquals("Invalid exception message", "cannot initialize module"
                + " com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"
                + " - Cannot set property 'headerFile' to 'null' in module"
                + " com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck",
                ex.getMessage());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:HeaderCheckTest.java

示例15: testArgumentSuppression

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testArgumentSuppression() throws Exception {
    final DefaultConfiguration filterConfig =
        createModuleConfig(SuppressionCommentFilter.class);
    filterConfig.addAttribute("offCommentFormat", "IllegalCatchCheck OFF\\: (\\w+)");
    filterConfig.addAttribute("onCommentFormat", "IllegalCatchCheck ON\\: (\\w+)");
    filterConfig.addAttribute("checkFormat", "IllegalCatchCheck");
    // [email protected][CheckstyleTestMakeup] need to test dynamic property
    filterConfig.addAttribute("messageFormat",
            "^" + getCheckMessage(IllegalCatchCheck.class, IllegalCatchCheck.MSG_KEY, "$1")
                    + "*$");
    final String[] suppressed = {
        "78:11: "
            + getCheckMessage(IllegalCatchCheck.class, IllegalCatchCheck.MSG_KEY, "Exception"),
    };
    verifySuppressed(filterConfig, suppressed);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:18,代码来源:SuppressionCommentFilterTest.java


注:本文中的com.puppycrawl.tools.checkstyle.DefaultConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。