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


Java DefaultConfiguration.addAttribute方法代码示例

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


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

示例1: 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

示例2: 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

示例3: testExcludedPackagesCommonPackages

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

    checkConfig.addAttribute("max", "0");
    checkConfig.addAttribute("excludedPackages",
        "com.puppycrawl.tools.checkstyle.checks.metrics.inputs.a");

    final String[] expected = {
        "8:1: " + getCheckMessage(MSG_KEY, 2, 0),
        "12:5: " + getCheckMessage(MSG_KEY, 2, 0),
        "18:1: " + getCheckMessage(MSG_KEY, 1, 0),
    };
    verify(checkConfig,
        getPath("InputClassFanOutComplexityExcludedPackagesCommonPackage.java"), expected);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:18,代码来源:ClassFanOutComplexityCheckTest.java

示例4: testIgnoreMethodNames

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void testIgnoreMethodNames() throws Exception {
    final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class);
    checkConfig.addAttribute("ignoredMethodNames", "table2");
    checkConfig.addAttribute("validateAbstractClassNames", "true");
    final String[] expected = {
        "6:13: " + getCheckMessage(MSG_KEY, "AbstractClass"),
        "9:13: " + getCheckMessage(MSG_KEY,
            "com.puppycrawl.tools.checkstyle.checks.coding.illegaltype."
                + "InputIllegalType.AbstractClass"),
        "16:13: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"),
        "25:36: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"),
    };

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

示例5: testVersionRegularExError

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void testVersionRegularExError()
        throws Exception {
    final DefaultConfiguration checkConfig =
        createModuleConfig(JavadocTypeCheck.class);
    checkConfig.addAttribute("versionFormat", "\\$Revision.*\\$");
    final String[] expected = {
        "13: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
        "22: " + getCheckMessage(MSG_MISSING_TAG, "@version"),
        "31: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
        "40: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
        "49: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
        "58: " + getCheckMessage(MSG_MISSING_TAG, "@version"),
        "67: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
        "76: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
        "85: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
        "94: " + getCheckMessage(MSG_MISSING_TAG, "@version"),
        "103: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
        "112: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
    };
    verify(checkConfig, getPath("InputJavadocTypeJavadoc.java"), expected);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:23,代码来源:JavadocTypeCheckTest.java

示例6: testInner

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void testInner()
        throws Exception {
    final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
    checkConfig.addAttribute("publicMemberPattern", "^f[A-Z][a-zA-Z0-9]*$");
    final String[] expected = {
        "30:24: " + getCheckMessage(MSG_KEY, "rData"),
        "33:27: " + getCheckMessage(MSG_KEY, "protectedVariable"),
        "36:17: " + getCheckMessage(MSG_KEY, "packageVariable"),
        "41:29: " + getCheckMessage(MSG_KEY, "sWeird"),
        "43:19: " + getCheckMessage(MSG_KEY, "sWeird2"),
        "77:20: " + getCheckMessage(MSG_KEY, "someValue"),
    };
    verify(checkConfig, getPath("InputVisibilityModifierInner.java"), expected);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:VisibilityModifierCheckTest.java

示例7: testInvalidCheckFormat

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void testInvalidCheckFormat() throws Exception {
    final DefaultConfiguration filterConfig =
        createModuleConfig(SuppressWithNearbyCommentFilter.class);
    filterConfig.addAttribute("checkFormat", "a[l");

    try {
        final String[] suppressed = CommonUtils.EMPTY_STRING_ARRAY;
        verifySuppressed(filterConfig, suppressed);
        fail("Exception is expected");
    }
    catch (CheckstyleException ex) {
        final IllegalArgumentException cause = (IllegalArgumentException) ex.getCause();
        assertEquals("Invalid exception message",
            "unable to parse expanded comment a[l", cause.getMessage());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:18,代码来源:SuppressWithNearbyCommentFilterTest.java

示例8: testInvalidInfluenceFormat

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void testInvalidInfluenceFormat() throws Exception {
    final DefaultConfiguration filterConfig =
        createModuleConfig(SuppressWithNearbyCommentFilter.class);
    filterConfig.addAttribute("influenceFormat", "a");

    try {
        final String[] suppressed = CommonUtils.EMPTY_STRING_ARRAY;
        verifySuppressed(filterConfig, suppressed);
        fail("Exception is expected");
    }
    catch (CheckstyleException ex) {
        final IllegalArgumentException cause = (IllegalArgumentException) ex.getCause();
        assertEquals("Invalid exception message", "unable to parse influence"
            + " from 'SUPPRESS CHECKSTYLE MemberNameCheck' using a", cause.getMessage());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:18,代码来源:SuppressWithNearbyCommentFilterTest.java

示例9: testEmptyFilename

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

示例10: testIgnoreFormat

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
public void testIgnoreFormat() throws Exception
{
    final DefaultConfiguration checkConfig =
        createCheckConfig(UnusedLocalVariableCheck.class);
    checkConfig.addAttribute("ignoreFormat", "Array$");
    final String[] expected = {
        "13:13: Unused local variable 'mUnreadPrimitive'.",
        "24:16: Unused local variable 'unreadObject'.",
        "45:13: Unused local variable 'java'.",
    };
    verify(checkConfig, getPath("usage/InputUnusedLocal.java"), expected);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:13,代码来源:UnusedLocalVariableCheckTest.java

示例11: testIgnoreFormat

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
public void testIgnoreFormat() throws Exception
{
    final DefaultConfiguration checkConfig =
        createCheckConfig(UnusedPrivateFieldCheck.class);
    checkConfig.addAttribute("ignoreFormat", "Array$");
    final String[] expected = {
        "10:17: Unused private field 'mUnreadPrimitive'.",
        "20:17: Unused private field 'mUnused2'.",
        "22:30: Unused private field 'SUNUSED'.",
        "64:17: Unused private field 'mUnused'.",
    };
    verify(checkConfig, getPath("usage/InputUnusedField.java"), expected);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:14,代码来源:UnusedPrivateFieldCheckTest.java

示例12: testException

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
public void testException() throws Exception
{
    final DefaultConfiguration checkConfig =
        createCheckConfig(UnusedParameterCheck.class);
    checkConfig.addAttribute("ignoreCatch", Boolean.FALSE.toString());
    final String[] expected = {
        "8:57: Unused parameter 'aUnreadPrimitive'.",
        "16:16: Unused parameter 'aUnreadObject'.",
        "25:26: Unused parameter 'unreadException'.",
        "29:66: Unused parameter 'aUnreadArray'.",            
    };
    verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:14,代码来源:UnusedParameterCheckTest.java

示例13: testIgnoreFormat

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
public void testIgnoreFormat() throws Exception
{
    final DefaultConfiguration checkConfig =
        createCheckConfig(UnusedParameterCheck.class);
    checkConfig.addAttribute("ignoreFormat", "Array$");
    final String[] expected = {
        "8:57: Unused parameter 'aUnreadPrimitive'.",
        "16:16: Unused parameter 'aUnreadObject'.",
    };
    verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:12,代码来源:UnusedParameterCheckTest.java

示例14: testIgnoreNonLocal

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
public void testIgnoreNonLocal() throws Exception
{
    final DefaultConfiguration checkConfig =
        createCheckConfig(UnusedParameterCheck.class);
    checkConfig.addAttribute("ignoreNonLocal", "true");
    final String[] expected = {
        "8:57: Unused parameter 'aUnreadPrimitive'.",
        "29:66: Unused parameter 'aUnreadArray'.",            
    };
    verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:12,代码来源:UnusedParameterCheckTest.java

示例15: CheckstyleRunner

import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
public CheckstyleRunner(String configLocation, String suppressionLocation)
        throws CheckstyleException {
    // create a configuration
    DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
            configLocation, new PropertiesExpander(System.getProperties()));

    // add the suppression file to the configuration
    DefaultConfiguration suppressions = new DefaultConfiguration("SuppressionFilter");
    suppressions.addAttribute("file", suppressionLocation);
    config.addChild(suppressions);

    this.config = config;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:CheckstyleRunner.java


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