@Test public void test() { String filename = "metrics/lines_of_code.php"; PhpFile file = FileTestUtils.getFile(new File("src/test/resources/"+filename)); FileLinesContext fileLinesContext = mock(FileLinesContext.class); CompilationUnitTree ast = parse(filename); FileMeasures fileMeasures = new MetricsVisitor().getFileMeasures(file, ast, SymbolTableImpl.create(ast), fileLinesContext); assertThat(fileMeasures.getFileComplexity()).isEqualTo(1); assertThat(fileMeasures.getFileCognitiveComplexity()).isEqualTo(0); assertThat(fileMeasures.getFunctionNumber()).isEqualTo(1); assertThat(fileMeasures.getStatementNumber()).isEqualTo(2); assertThat(fileMeasures.getClassNumber()).isEqualTo(1); assertThat(fileMeasures.getLinesOfCodeNumber()).isEqualTo(7); assertThat(fileMeasures.getCommentLinesNumber()).isEqualTo(5); verify(fileLinesContext).setIntValue(CoreMetrics.EXECUTABLE_LINES_DATA_KEY, 21, 1); }
public FileMeasures getFileMeasures( PhpFile file, CompilationUnitTree tree, SymbolTable symbolTable, FileLinesContext fileLinesContext ) { this.fileMeasures = new FileMeasures(); this.fileLinesContext = fileLinesContext; super.analyze(file, tree, symbolTable); setCounterMeasures(); setLineAndCommentMeasures(); return this.fileMeasures; }
MetricsVisitor extends PHPSubscriptionCheck { public FileMeasures getFileMeasures( PhpFile file, CompilationUnitTree tree, SymbolTable symbolTable, FileLinesContext fileLinesContext ) { this.fileMeasures = new FileMeasures(); this.fileLinesContext = fileLinesContext; super.analyze(file, tree, symbolTable); setCounterMeasures(); setLineAndCommentMeasures(); return this.fileMeasures; } }
MetricsVisitor extends PHPSubscriptionCheck { public FileMeasures getFileMeasures( PhpFile file, CompilationUnitTree tree, SymbolTable symbolTable, FileLinesContext fileLinesContext ) { this.fileMeasures = new FileMeasures(); this.fileLinesContext = fileLinesContext; super.analyze(file, tree, symbolTable); setCounterMeasures(); setLineAndCommentMeasures(); return this.fileMeasures; }  }
MetricsVisitor extends PHPSubscriptionCheck { public FileMeasures getFileMeasures( PhpFile file, CompilationUnitTree tree, SymbolTable symbolTable, FileLinesContext fileLinesContext ) { this.fileMeasures = new FileMeasures(); this.fileLinesContext = fileLinesContext; super.analyze(file, tree, symbolTable); setCounterMeasures(); setLineAndCommentMeasures(); return this.fileMeasures; }  static Kind[] getClassNodes(); static Kind[] getFunctionNodes(); @Override List<Kind> nodesToVisit(); @Override void visitNode(Tree tree); FileMeasures getFileMeasures(
    PhpFile file,
    CompilationUnitTree tree,
    SymbolTable symbolTable,
    FileLinesContext fileLinesContext
  ); }
MetricsVisitor extends PHPSubscriptionCheck { public FileMeasures getFileMeasures( PhpFile file, CompilationUnitTree tree, SymbolTable symbolTable, FileLinesContext fileLinesContext ) { this.fileMeasures = new FileMeasures(); this.fileLinesContext = fileLinesContext; super.analyze(file, tree, symbolTable); setCounterMeasures(); setLineAndCommentMeasures(); return this.fileMeasures; }  static Kind[] getClassNodes(); static Kind[] getFunctionNodes(); @Override List<Kind> nodesToVisit(); @Override void visitNode(Tree tree); FileMeasures getFileMeasures(
    PhpFile file,
    CompilationUnitTree tree,
    SymbolTable symbolTable,
    FileLinesContext fileLinesContext
  );  }