Expanded test input to include a constructor and initializers.

Added INSTANCE_INIT to CyclomaticComplexityCheck member tokens.
This commit is contained in:
Rick Giles 2003-08-30 20:37:49 +00:00
parent 1952077d3e
commit d1094efc1e
3 changed files with 33 additions and 2 deletions

View File

@ -51,6 +51,7 @@ public class CyclomaticComplexityCheck
return new int[] {
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.INSTANCE_INIT,
TokenTypes.STATIC_INIT,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_DO,

View File

@ -1,4 +1,4 @@
package au.com.redhillconsulting.jamaica.tools.checkstyle;
package com.puppycrawl.tools.checkstyle;
public class ComplexityCheckTestInput {
public void foo() {
@ -44,4 +44,31 @@ public class ComplexityCheckTestInput {
}
}
}
public ComplexityCheckTestInput()
{
int i = 1;
if (System.currentTimeMillis() == 0) {
} else if (System.currentTimeMillis() == 0) {
} else {
}
}
// STATIC_INIT
static {
int i = 1;
if (System.currentTimeMillis() == 0) {
} else if (System.currentTimeMillis() == 0) {
} else {
}
}
// INSTANCE_INIT
{
int i = 1;
if (System.currentTimeMillis() == 0) {
} else if (System.currentTimeMillis() == 0) {
} else {
}
}
}

View File

@ -19,7 +19,10 @@ public class CyclomaticComplexityCheckTest
"17:5: Cyclomatic Complexity is 6 (max allowed is 0).",
"27:5: Cyclomatic Complexity is 4 (max allowed is 0).",
"34:5: Cyclomatic Complexity is 6 (max allowed is 0).",
};
"48:5: Cyclomatic Complexity is 4 (max allowed is 0).",
"58:5: Cyclomatic Complexity is 4 (max allowed is 0).",
"67:5: Cyclomatic Complexity is 4 (max allowed is 0).",
};
verify(checkConfig, getPath("ComplexityCheckTestInput.java"), expected);
}