use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class VariableDeclarationUsageDistanceCheckTest method testIgnoreFinalOption.
@Test
public void testIgnoreFinalOption() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(VariableDeclarationUsageDistanceCheck.class);
checkConfig.addAttribute("allowedDistance", "1");
checkConfig.addAttribute("ignoreVariablePattern", "");
checkConfig.addAttribute("validateBetweenScopes", "true");
checkConfig.addAttribute("ignoreFinal", "true");
final String[] expected = { "30: " + getCheckMessage(MSG_KEY_EXT, "a", 2, 1), "38: " + getCheckMessage(MSG_KEY_EXT, "temp", 2, 1), "44: " + getCheckMessage(MSG_KEY_EXT, "temp", 2, 1), "57: " + getCheckMessage(MSG_KEY_EXT, "count", 2, 1), "71: " + getCheckMessage(MSG_KEY_EXT, "count", 4, 1), "96: " + getCheckMessage(MSG_KEY_EXT, "arg", 2, 1), "144: " + getCheckMessage(MSG_KEY_EXT, "m", 3, 1), "145: " + getCheckMessage(MSG_KEY_EXT, "n", 2, 1), "184: " + getCheckMessage(MSG_KEY_EXT, "result", 2, 1), "219: " + getCheckMessage(MSG_KEY_EXT, "t", 5, 1), "222: " + getCheckMessage(MSG_KEY_EXT, "c", 3, 1), "223: " + getCheckMessage(MSG_KEY_EXT, "d2", 3, 1), "260: " + getCheckMessage(MSG_KEY_EXT, "selected", 2, 1), "261: " + getCheckMessage(MSG_KEY_EXT, "model", 2, 1), "287: " + getCheckMessage(MSG_KEY_EXT, "sw", 2, 1), "300: " + getCheckMessage(MSG_KEY_EXT, "wh", 2, 1), "343: " + getCheckMessage(MSG_KEY_EXT, "green", 2, 1), "344: " + getCheckMessage(MSG_KEY_EXT, "blue", 3, 1), "454: " + getCheckMessage(MSG_KEY_EXT, "aOpt", 3, 1), "455: " + getCheckMessage(MSG_KEY_EXT, "bOpt", 2, 1), "471: " + getCheckMessage(MSG_KEY_EXT, "l1", 3, 1), "471: " + getCheckMessage(MSG_KEY_EXT, "l2", 2, 1), "479: " + getCheckMessage(MSG_KEY_EXT, "myOption", 7, 1), "491: " + getCheckMessage(MSG_KEY_EXT, "myOption", 6, 1), "504: " + getCheckMessage(MSG_KEY_EXT, "count", 4, 1), "505: " + getCheckMessage(MSG_KEY_EXT, "files", 2, 1), "540: " + getCheckMessage(MSG_KEY_EXT, "id", 2, 1), "542: " + getCheckMessage(MSG_KEY_EXT, "parentId", 3, 1), "891: " + getCheckMessage(MSG_KEY_EXT, "a", 4, 1), "901: " + getCheckMessage(MSG_KEY_EXT, "a", 4, 1), "967: " + getCheckMessage(MSG_KEY_EXT, "a", 4, 1) };
verify(checkConfig, getPath("InputVariableDeclarationUsageDistance.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class DesignForExtensionCheckTest method testOverridableMethods.
@Test
public void testOverridableMethods() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(DesignForExtensionCheck.class);
final String[] expected = { "6:9: " + getCheckMessage(MSG_KEY, "A", "foo1"), "30:9: " + getCheckMessage(MSG_KEY, "A", "foo8"), "35:9: " + getCheckMessage(MSG_KEY, "A", "foo9"), "42:9: " + getCheckMessage(MSG_KEY, "A", "foo10"), "49:9: " + getCheckMessage(MSG_KEY, "A", "foo11"), "54:9: " + getCheckMessage(MSG_KEY, "A", "foo12"), "61:9: " + getCheckMessage(MSG_KEY, "A", "foo13"), "68:9: " + getCheckMessage(MSG_KEY, "A", "foo14"), "90:9: " + getCheckMessage(MSG_KEY, "A", "foo22"), "96:9: " + getCheckMessage(MSG_KEY, "A", "foo23"), "110:9: " + getCheckMessage(MSG_KEY, "A", "foo26"), "117:9: " + getCheckMessage(MSG_KEY, "A", "foo27") };
verify(checkConfig, getPath("InputDesignForExtensionOverridableMethods.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class DesignForExtensionCheckTest method testNativeMethods.
@Test
public void testNativeMethods() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(DesignForExtensionCheck.class);
checkConfig.addAttribute("ignoredAnnotations", "Deprecated");
final String[] expected = { "8:5: " + getCheckMessage(MSG_KEY, "InputDesignForExtensionNativeMethods", "foo1") };
verify(checkConfig, getPath("InputDesignForExtensionNativeMethods.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class DesignForExtensionCheckTest method testIt.
@Test
public void testIt() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(DesignForExtensionCheck.class);
final String[] expected = { "46:5: " + getCheckMessage(MSG_KEY, "InputDesignForExtension", "doh"), "100:9: " + getCheckMessage(MSG_KEY, "anotherNonFinalClass", "someMethod") };
verify(checkConfig, getPath("InputDesignForExtension.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class FinalClassCheckTest method testClassWithPrivateCtorAndNestedExtendingSubclassWithoutPackage.
@Test
public void testClassWithPrivateCtorAndNestedExtendingSubclassWithoutPackage() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(FinalClassCheck.class);
final String[] expected = { "7: " + getCheckMessage(MSG_KEY, "C") };
verify(checkConfig, getNonCompilablePath("InputClassWithPrivateCtorWithNestedExtendingClassWithoutPackage.java"), expected);
}
Aggregations