100% test coverage for ParameterNumberCheck, OuterTypeNumberCheck, MethodLengthCheck, LineLengthCheck, FileLengthCheck, ExecutableStatementCountCheck, AnonInnerLengthCheck, issue #1024
This commit is contained in:
parent
5976084c38
commit
cb8d98fb43
7
pom.xml
7
pom.xml
|
|
@ -851,14 +851,7 @@
|
|||
<regex><pattern>.*.checks.regexp.RegexpSinglelineCheck</pattern><branchRate>100</branchRate><lineRate>76</lineRate></regex>
|
||||
<regex><pattern>.*.checks.regexp.SinglelineDetector</pattern><branchRate>93</branchRate><lineRate>96</lineRate></regex>
|
||||
|
||||
<regex><pattern>.*.checks.sizes.AnonInnerLengthCheck</pattern><branchRate>100</branchRate><lineRate>92</lineRate></regex>
|
||||
<regex><pattern>.*.checks.sizes.ExecutableStatementCountCheck</pattern><branchRate>81</branchRate><lineRate>95</lineRate></regex>
|
||||
<regex><pattern>.*.checks.sizes.LineLengthCheck</pattern><branchRate>100</branchRate><lineRate>89</lineRate></regex>
|
||||
<regex><pattern>.*.checks.sizes.MethodCountCheck</pattern><branchRate>31</branchRate><lineRate>23</lineRate></regex>
|
||||
<regex><pattern>.*.checks.sizes.MethodLengthCheck</pattern><branchRate>100</branchRate><lineRate>95</lineRate></regex>
|
||||
<regex><pattern>.*.checks.sizes.OuterTypeNumberCheck</pattern><branchRate>75</branchRate><lineRate>94</lineRate></regex>
|
||||
<regex><pattern>.*.checks.sizes.ParameterNumberCheck</pattern><branchRate>100</branchRate><lineRate>93</lineRate></regex>
|
||||
|
||||
|
||||
<regex><pattern>.*.checks.whitespace.AbstractParenPadCheck</pattern><branchRate>88</branchRate><lineRate>100</lineRate></regex>
|
||||
<regex><pattern>.*.checks.whitespace.EmptyForInitializerPadCheck</pattern><branchRate>91</branchRate><lineRate>93</lineRate></regex>
|
||||
|
|
|
|||
|
|
@ -172,18 +172,17 @@ public final class ExecutableStatementCountCheck
|
|||
// find member AST for the statement list
|
||||
final DetailAST contextAST = context.getAST();
|
||||
DetailAST parent = ast.getParent();
|
||||
while (parent != null) {
|
||||
final int type = parent.getType();
|
||||
if (type == TokenTypes.CTOR_DEF
|
||||
|| type == TokenTypes.METHOD_DEF
|
||||
|| type == TokenTypes.INSTANCE_INIT
|
||||
|| type == TokenTypes.STATIC_INIT) {
|
||||
if (parent == contextAST) {
|
||||
context.addCount(ast.getChildCount() / 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
int type = parent.getType();
|
||||
while (type != TokenTypes.CTOR_DEF
|
||||
&& type != TokenTypes.METHOD_DEF
|
||||
&& type != TokenTypes.INSTANCE_INIT
|
||||
&& type != TokenTypes.STATIC_INIT) {
|
||||
|
||||
parent = parent.getParent();
|
||||
type = parent.getType();
|
||||
}
|
||||
if (parent == contextAST) {
|
||||
context.addCount(ast.getChildCount() / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,4 +60,14 @@ public class OuterTypeNumberCheckTest extends BaseCheckTestSupport {
|
|||
};
|
||||
verify(checkConfig, getPath("InputSimple.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithInnerClass() throws Exception {
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(OuterTypeNumberCheck.class);
|
||||
checkConfig.addAttribute("max", "1");
|
||||
final String[] expected = {
|
||||
};
|
||||
verify(checkConfig, getPath("OuterTypeNumberCheckInput.java"), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
/**Contains empty inner class for OuterTypeNumberCheckTest*/
|
||||
public class OuterTypeNumberCheckInput {
|
||||
|
||||
/** Just empty inner class*/
|
||||
private class InnerClass {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue