@Test public void analyse2() throws FileNotFoundException { DefaultFileSystem fs = new DefaultFileSystem(TEST_DIR); tester.setFileSystem(fs); DefaultInputFile inputFile = new DefaultInputFile("key", "timeFormatter.lua") .setType(InputFile.Type.MAIN) .setLanguage(Lua.KEY) .initMetadata(new FileMetadata().readMetadata(new FileReader(new File(TEST_DIR, "timeFormatter.lua")))); fs.add(inputFile); sensor.execute(tester); String componentKey = inputFile.key(); assertThat(tester.measure(componentKey, CoreMetrics.COMPLEXITY_IN_CLASSES).value()).isEqualTo(0); assertThat(tester.measure(componentKey, CoreMetrics.NCLOC).value()).isEqualTo(0); assertThat(tester.measure(componentKey, CoreMetrics.COMMENT_LINES).value()).isEqualTo(59); assertThat(tester.measure(componentKey, CoreMetrics.STATEMENTS).value()).isEqualTo(0); assertThat(tester.measure(componentKey, CoreMetrics.FUNCTIONS).value()).isEqualTo(0); assertThat(tester.measure(componentKey, CoreMetrics.COMPLEXITY).value()).isEqualTo(0); assertThat(tester.measure(componentKey, CoreMetrics.FILE_COMPLEXITY_DISTRIBUTION).value()).isEqualTo("0=1;5=0;10=0;20=0;30=0;60=0;90=0"); assertThat(tester.measure(componentKey, CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION).value()).isEqualTo("1=0;2=0;4=0;6=0;8=0;10=0;12=0"); assertThat(tester.allIssues()).hasSize(0); }
@Override public void execute(SensorContext context) { FileSystem fileSystem = context.fileSystem(); FilePredicates predicates = fileSystem.predicates(); List<SquidAstVisitor<LexerlessGrammar>> visitors = new ArrayList<>(checks.all()); visitors.add(new FileLinesVisitor(fileLinesContextFactory, fileSystem)); LuaConfiguration configuration = new LuaConfiguration(fileSystem.encoding()); scanner = LuaAstScanner.create(configuration, visitors); Iterable<java.io.File> files = fileSystem.files( predicates.and( predicates.hasType(InputFile.Type.MAIN), predicates.hasLanguage(Lua.KEY), inputFile -> !inputFile.absolutePath().endsWith("mxml") )); scanner.scanFiles(ImmutableList.copyOf(files)); Collection<SourceCode> squidSourceFiles = scanner.getIndex().search(new QueryByType(SourceFile.class)); save(context, squidSourceFiles); }
LuaSquidSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fileSystem = context.fileSystem(); FilePredicates predicates = fileSystem.predicates(); List<SquidAstVisitor<LexerlessGrammar>> visitors = new ArrayList<>(checks.all()); visitors.add(new FileLinesVisitor(fileLinesContextFactory, fileSystem)); LuaConfiguration configuration = new LuaConfiguration(fileSystem.encoding()); scanner = LuaAstScanner.create(configuration, visitors); Iterable<java.io.File> files = fileSystem.files( predicates.and( predicates.hasType(InputFile.Type.MAIN), predicates.hasLanguage(Lua.KEY), inputFile -> !inputFile.absolutePath().endsWith("mxml") )); scanner.scanFiles(ImmutableList.copyOf(files)); Collection<SourceCode> squidSourceFiles = scanner.getIndex().search(new QueryByType(SourceFile.class)); save(context, squidSourceFiles); } }
LuaSquidSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fileSystem = context.fileSystem(); FilePredicates predicates = fileSystem.predicates(); List<SquidAstVisitor<LexerlessGrammar>> visitors = new ArrayList<>(checks.all()); visitors.add(new FileLinesVisitor(fileLinesContextFactory, fileSystem)); LuaConfiguration configuration = new LuaConfiguration(fileSystem.encoding()); scanner = LuaAstScanner.create(configuration, visitors); Iterable<java.io.File> files = fileSystem.files( predicates.and( predicates.hasType(InputFile.Type.MAIN), predicates.hasLanguage(Lua.KEY), inputFile -> !inputFile.absolutePath().endsWith("mxml") )); scanner.scanFiles(ImmutableList.copyOf(files)); Collection<SourceCode> squidSourceFiles = scanner.getIndex().search(new QueryByType(SourceFile.class)); save(context, squidSourceFiles); } LuaSquidSensor(CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory); }
LuaSquidSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fileSystem = context.fileSystem(); FilePredicates predicates = fileSystem.predicates(); List<SquidAstVisitor<LexerlessGrammar>> visitors = new ArrayList<>(checks.all()); visitors.add(new FileLinesVisitor(fileLinesContextFactory, fileSystem)); LuaConfiguration configuration = new LuaConfiguration(fileSystem.encoding()); scanner = LuaAstScanner.create(configuration, visitors); Iterable<java.io.File> files = fileSystem.files( predicates.and( predicates.hasType(InputFile.Type.MAIN), predicates.hasLanguage(Lua.KEY), inputFile -> !inputFile.absolutePath().endsWith("mxml") )); scanner.scanFiles(ImmutableList.copyOf(files)); Collection<SourceCode> squidSourceFiles = scanner.getIndex().search(new QueryByType(SourceFile.class)); save(context, squidSourceFiles); } LuaSquidSensor(CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); }
LuaSquidSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fileSystem = context.fileSystem(); FilePredicates predicates = fileSystem.predicates(); List<SquidAstVisitor<LexerlessGrammar>> visitors = new ArrayList<>(checks.all()); visitors.add(new FileLinesVisitor(fileLinesContextFactory, fileSystem)); LuaConfiguration configuration = new LuaConfiguration(fileSystem.encoding()); scanner = LuaAstScanner.create(configuration, visitors); Iterable<java.io.File> files = fileSystem.files( predicates.and( predicates.hasType(InputFile.Type.MAIN), predicates.hasLanguage(Lua.KEY), inputFile -> !inputFile.absolutePath().endsWith("mxml") )); scanner.scanFiles(ImmutableList.copyOf(files)); Collection<SourceCode> squidSourceFiles = scanner.getIndex().search(new QueryByType(SourceFile.class)); save(context, squidSourceFiles); } LuaSquidSensor(CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context);  }