use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class CyclomaticComplexityCheckTest method testSwitchBlockAsSingleDecisionPointSetToTrue.
@Test
public void testSwitchBlockAsSingleDecisionPointSetToTrue() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(CyclomaticComplexityCheck.class);
checkConfig.addAttribute("max", "0");
checkConfig.addAttribute("switchBlockAsSingleDecisionPoint", "true");
final String[] expected = { "4:5: " + getCheckMessage(MSG_KEY, 2, 0) };
verify(checkConfig, getPath("InputComplexitySwitchBlocks.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class CyclomaticComplexityCheckTest method test.
@Test
public void test() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(CyclomaticComplexityCheck.class);
checkConfig.addAttribute("max", "0");
final String[] expected = { "4:5: " + getCheckMessage(MSG_KEY, 2, 0), "7:17: " + getCheckMessage(MSG_KEY, 2, 0), "17:5: " + getCheckMessage(MSG_KEY, 6, 0), "27:5: " + getCheckMessage(MSG_KEY, 3, 0), "34:5: " + getCheckMessage(MSG_KEY, 5, 0), "48:5: " + getCheckMessage(MSG_KEY, 3, 0), "58:5: " + getCheckMessage(MSG_KEY, 3, 0), "67:5: " + getCheckMessage(MSG_KEY, 3, 0), "76:5: " + getCheckMessage(MSG_KEY, 1, 0), "79:13: " + getCheckMessage(MSG_KEY, 2, 0) };
verify(checkConfig, getPath("InputComplexity.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class JavaNCSSCheckTest method test.
@Test
public void test() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(JavaNCSSCheck.class);
checkConfig.addAttribute("methodMaximum", "0");
checkConfig.addAttribute("classMaximum", "1");
checkConfig.addAttribute("fileMaximum", "2");
final String[] expected = { "2:1: " + getCheckMessage(MSG_FILE, 39, 2), "9:1: " + getCheckMessage(MSG_CLASS, 22, 1), "14:5: " + getCheckMessage(MSG_METHOD, 2, 0), "21:5: " + getCheckMessage(MSG_METHOD, 4, 0), "30:5: " + getCheckMessage(MSG_METHOD, 12, 0), "42:13: " + getCheckMessage(MSG_METHOD, 2, 0), "49:5: " + getCheckMessage(MSG_CLASS, 2, 1), "56:1: " + getCheckMessage(MSG_CLASS, 10, 1), "61:5: " + getCheckMessage(MSG_METHOD, 8, 0), "80:1: " + getCheckMessage(MSG_CLASS, 4, 1), "81:5: " + getCheckMessage(MSG_METHOD, 1, 0), "82:5: " + getCheckMessage(MSG_METHOD, 1, 0), "83:5: " + getCheckMessage(MSG_METHOD, 1, 0) };
verify(checkConfig, getPath("InputJavaNCSS.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class NPathComplexityCheckTest method testCalculation.
@Test
public void testCalculation() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(NPathComplexityCheck.class);
checkConfig.addAttribute("max", "0");
final String[] expected = { "4:5: " + getCheckMessage(MSG_KEY, 2, 0), "7:17: " + getCheckMessage(MSG_KEY, 2, 0), "17:5: " + getCheckMessage(MSG_KEY, 5, 0), "27:5: " + getCheckMessage(MSG_KEY, 3, 0), "34:5: " + getCheckMessage(MSG_KEY, 7, 0), "48:5: " + getCheckMessage(MSG_KEY, 3, 0), "58:5: " + getCheckMessage(MSG_KEY, 3, 0), "67:5: " + getCheckMessage(MSG_KEY, 3, 0), "76:5: " + getCheckMessage(MSG_KEY, 1, 0), "79:13: " + getCheckMessage(MSG_KEY, 2, 0) };
verify(checkConfig, getPath("InputComplexity.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class NPathComplexityCheckTest method testIntegerOverflow.
@Test
public void testIntegerOverflow() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(NPathComplexityCheck.class);
checkConfig.addAttribute("max", "0");
final long largerThanMaxInt = 3_486_784_401L;
final String[] expected = { "9:5: " + getCheckMessage(MSG_KEY, largerThanMaxInt, 0) };
verify(checkConfig, getPath("InputComplexityOverflow.java"), expected);
}
Aggregations