Example #1
0
 /** {@inheritDoc} */
 public void setMeasure(Metric metric, int measure) {
   switch (metric) {
     case BLANK_LINES:
       blankLine = measure;
       break;
     case LINES_OF_CODE:
       lineOfCode = measure;
       break;
     case COMMENT_LINES:
       commentLine = measure;
       break;
     case COMMENTED_OUT_CODE_LINES:
       commentedOutCodeLine = measure;
       break;
     case COMMENT_BLANK_LINES:
       commentBlankLine = measure;
       break;
     case HEADER_COMMENT_LINES:
       headerCommentLine = measure;
       break;
     case PUBLIC_DOC_API:
       documentation = measure;
       break;
     case LINES:
       throw new IllegalStateException(
           "Metric LINES always equals 1 on a Line and you are not permitted to change this value.");
     default:
       throw new IllegalStateException(
           "Metric " + metric.name() + " is not suitable for Line object.");
   }
 }
 @Before
 public void setUp() {
   squid = new Squid(new JavaSquidConfiguration());
   EmptyFileCheck check = new EmptyFileCheck();
   squid.registerVisitor(check);
   JavaAstScanner scanner = squid.register(JavaAstScanner.class);
   scanner.scanDirectory(SquidTestUtils.getFile("/metrics/commentedCode"));
   squid.decorateSourceCodeTreeWith(Metric.values());
   squid.register(SquidScanner.class).scan();
 }
 @Before
 public void setUp() {
   squid = new Squid(new JavaSquidConfiguration());
   MethodComplexityCheck check = new MethodComplexityCheck();
   check.setMax(5);
   squid.registerVisitor(check);
   JavaAstScanner scanner = squid.register(JavaAstScanner.class);
   scanner.scanFile(SquidTestUtils.getInputFile("/metrics/branches/ComplexBranches.java"));
   squid.decorateSourceCodeTreeWith(Metric.values());
   squid.register(SquidScanner.class).scan();
 }
Example #4
0
 /** {@inheritDoc} */
 public int getInt(Metric metric) {
   switch (metric) {
     case BLANK_LINES:
       return blankLine;
     case LINES:
       return line;
     case LINES_OF_CODE:
       return lineOfCode;
     case COMMENT_LINES:
       return commentLine;
     case COMMENTED_OUT_CODE_LINES:
       return commentedOutCodeLine;
     case COMMENT_BLANK_LINES:
       return commentBlankLine;
     case HEADER_COMMENT_LINES:
       return headerCommentLine;
     case PUBLIC_DOC_API:
       return documentation;
     default:
       throw new IllegalStateException(
           "Metric " + metric.name() + " is not available on Line object.");
   }
 }