1 package com.puppycrawl.tools.checkstyle.checks.metrics; 20 21 import com.puppycrawl.tools.checkstyle.api.DetailAST; 22 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 23 24 35 public class CyclomaticComplexityCheck 36 extends AbstractComplexityCheck 37 { 38 39 private static final int DEFAULT_VALUE = 10; 40 41 42 public CyclomaticComplexityCheck() 43 { 44 super(DEFAULT_VALUE); 45 } 46 47 48 public int[] getDefaultTokens() 49 { 50 return new int[] { 51 TokenTypes.CTOR_DEF, 52 TokenTypes.METHOD_DEF, 53 TokenTypes.INSTANCE_INIT, 54 TokenTypes.STATIC_INIT, 55 TokenTypes.LITERAL_WHILE, 56 TokenTypes.LITERAL_DO, 57 TokenTypes.LITERAL_FOR, 58 TokenTypes.LITERAL_IF, 59 TokenTypes.LITERAL_CASE, 60 TokenTypes.LITERAL_CATCH, 61 TokenTypes.QUESTION, 62 TokenTypes.LAND, 63 TokenTypes.LOR, 64 }; 65 } 66 67 68 protected final void visitTokenHook(DetailAST aAST) 69 { 70 incrementCurrentValue(1); 71 } 72 73 74 protected final String getMessageID() 75 { 76 return "cyclomaticComplexity"; 77 } 78 } 79 | Popular Tags |