Issue #1287: 'AbstractClassCouplingCheck' refactored, UT coverage improved
This commit is contained in:
parent
ae170e4575
commit
60eacf91e6
3
pom.xml
3
pom.xml
|
|
@ -1120,9 +1120,6 @@
|
|||
|
||||
<regex><pattern>.*.checks.header.AbstractHeaderCheck</pattern><branchRate>90</branchRate><lineRate>87</lineRate></regex>
|
||||
|
||||
<regex><pattern>.*.checks.metrics.AbstractClassCouplingCheck</pattern><branchRate>87</branchRate><lineRate>97</lineRate></regex>
|
||||
<regex><pattern>.*.checks.metrics.AbstractClassCouplingCheck\$.*</pattern><branchRate>78</branchRate><lineRate>100</lineRate></regex>
|
||||
|
||||
<regex><pattern>.*.checks.regexp.CommentSuppressor</pattern><branchRate>75</branchRate><lineRate>100</lineRate></regex>
|
||||
<regex><pattern>.*.checks.regexp.DetectorOptions</pattern><branchRate>100</branchRate><lineRate>96</lineRate></regex>
|
||||
<regex><pattern>.*.checks.regexp.MultilineDetector</pattern><branchRate>58</branchRate><lineRate>87</lineRate></regex>
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ public abstract class AbstractClassCouplingCheck extends Check {
|
|||
context.visitLiteralThrows(ast);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException(ast.toString());
|
||||
throw new IllegalArgumentException("Unknown type: " + ast);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -284,8 +284,7 @@ public abstract class AbstractClassCouplingCheck extends Check {
|
|||
* @return true if we should count this class.
|
||||
*/
|
||||
private boolean isSignificant(String className) {
|
||||
return className.length() > 0
|
||||
&& !excludedClasses.contains(className)
|
||||
return !excludedClasses.contains(className)
|
||||
&& !className.startsWith("java.lang.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,12 @@ import java.io.File;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import antlr.CommonHiddenStreamToken;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
|
||||
public class ClassDataAbstractionCouplingCheckTest extends BaseCheckTestSupport {
|
||||
@Test
|
||||
|
|
@ -67,4 +71,12 @@ public class ClassDataAbstractionCouplingCheckTest extends BaseCheckTestSupport
|
|||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testWrongToken() {
|
||||
ClassDataAbstractionCouplingCheck classDataAbstractionCouplingCheckObj = new ClassDataAbstractionCouplingCheck();
|
||||
DetailAST ast = new DetailAST();
|
||||
ast.initialize(new CommonHiddenStreamToken(TokenTypes.CTOR_DEF, "ctor"));
|
||||
classDataAbstractionCouplingCheckObj.visitToken(ast);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public class ClassFanOutComplexityCheckTest extends BaseCheckTestSupport {
|
|||
|
||||
String[] expected = {
|
||||
"6:1: " + getCheckMessage(MSG_KEY, 3, 0),
|
||||
"38:1: " + getCheckMessage(MSG_KEY, 1, 0),
|
||||
};
|
||||
|
||||
verify(checkConfig,
|
||||
|
|
|
|||
|
|
@ -34,3 +34,10 @@ enum InnerEnum {
|
|||
private Set map1 = new HashSet();
|
||||
private Map map2;
|
||||
}
|
||||
|
||||
class InputThrows {
|
||||
|
||||
public void get() throws NamingException, IllegalArgumentException {
|
||||
new java.lang.ref.ReferenceQueue<Integer>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue