@Test public void should_execute_and_compute_valid_measures_on_UTF8_file_with_BOM() { String relativePath = "sample.json"; inputFile(relativePath); createJSONSquidSensor().execute(context); assertMeasures("moduleKey:" + relativePath); }
@Override public void execute(SensorContext sensorContext) { List<TreeVisitor> treeVisitors = Lists.newArrayList(); treeVisitors.addAll(checks.visitorChecks()); treeVisitors.add(new SyntaxHighlighterVisitor(sensorContext)); treeVisitors.add(new MetricsVisitor(sensorContext)); setParsingErrorCheckIfActivated(treeVisitors); ProgressReport progressReport = new ProgressReport("Report about progress of JSON analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(Lists.newArrayList(fileSystem.files(mainFilePredicate))); issueSaver = new IssueSaver(sensorContext, checks); List<Issue> issues = new ArrayList<>(); boolean success = false; try { for (InputFile inputFile : fileSystem.inputFiles(mainFilePredicate)) { LOG.debug("Analyzing " + inputFile.absolutePath() + "..."); issues.addAll(analyzeFile(sensorContext, inputFile, treeVisitors)); progressReport.nextFile(); } saveSingleFileIssues(issues); success = true; } finally { stopProgressReport(progressReport, success); } }
JSONSquidSensor implements Sensor { @Override public void execute(SensorContext sensorContext) { List<TreeVisitor> treeVisitors = Lists.newArrayList(); treeVisitors.addAll(checks.visitorChecks()); treeVisitors.add(new SyntaxHighlighterVisitor(sensorContext)); treeVisitors.add(new MetricsVisitor(sensorContext)); setParsingErrorCheckIfActivated(treeVisitors); ProgressReport progressReport = new ProgressReport("Report about progress of JSON analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(Lists.newArrayList(fileSystem.files(mainFilePredicate))); issueSaver = new IssueSaver(sensorContext, checks); List<Issue> issues = new ArrayList<>(); boolean success = false; try { for (InputFile inputFile : fileSystem.inputFiles(mainFilePredicate)) { LOG.debug("Analyzing " + inputFile.absolutePath() + "..."); issues.addAll(analyzeFile(sensorContext, inputFile, treeVisitors)); progressReport.nextFile(); } saveSingleFileIssues(issues); success = true; } finally { stopProgressReport(progressReport, success); } } }
JSONSquidSensor implements Sensor { @Override public void execute(SensorContext sensorContext) { List<TreeVisitor> treeVisitors = Lists.newArrayList(); treeVisitors.addAll(checks.visitorChecks()); treeVisitors.add(new SyntaxHighlighterVisitor(sensorContext)); treeVisitors.add(new MetricsVisitor(sensorContext)); setParsingErrorCheckIfActivated(treeVisitors); ProgressReport progressReport = new ProgressReport("Report about progress of JSON analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(Lists.newArrayList(fileSystem.files(mainFilePredicate))); issueSaver = new IssueSaver(sensorContext, checks); List<Issue> issues = new ArrayList<>(); boolean success = false; try { for (InputFile inputFile : fileSystem.inputFiles(mainFilePredicate)) { LOG.debug("Analyzing " + inputFile.absolutePath() + "..."); issues.addAll(analyzeFile(sensorContext, inputFile, treeVisitors)); progressReport.nextFile(); } saveSingleFileIssues(issues); success = true; } finally { stopProgressReport(progressReport, success); } } JSONSquidSensor(FileSystem fileSystem, CheckFactory checkFactory);  JSONSquidSensor(FileSystem fileSystem, CheckFactory checkFactory, @Nullable CustomJSONRulesDefinition[] customRulesDefinition); }
JSONSquidSensor implements Sensor { @Override public void execute(SensorContext sensorContext) { List<TreeVisitor> treeVisitors = Lists.newArrayList(); treeVisitors.addAll(checks.visitorChecks()); treeVisitors.add(new SyntaxHighlighterVisitor(sensorContext)); treeVisitors.add(new MetricsVisitor(sensorContext)); setParsingErrorCheckIfActivated(treeVisitors); ProgressReport progressReport = new ProgressReport("Report about progress of JSON analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(Lists.newArrayList(fileSystem.files(mainFilePredicate))); issueSaver = new IssueSaver(sensorContext, checks); List<Issue> issues = new ArrayList<>(); boolean success = false; try { for (InputFile inputFile : fileSystem.inputFiles(mainFilePredicate)) { LOG.debug("Analyzing " + inputFile.absolutePath() + "..."); issues.addAll(analyzeFile(sensorContext, inputFile, treeVisitors)); progressReport.nextFile(); } saveSingleFileIssues(issues); success = true; } finally { stopProgressReport(progressReport, success); } } JSONSquidSensor(FileSystem fileSystem, CheckFactory checkFactory);  JSONSquidSensor(FileSystem fileSystem, CheckFactory checkFactory, @Nullable CustomJSONRulesDefinition[] customRulesDefinition); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext sensorContext); }
JSONSquidSensor implements Sensor { @Override public void execute(SensorContext sensorContext) { List<TreeVisitor> treeVisitors = Lists.newArrayList(); treeVisitors.addAll(checks.visitorChecks()); treeVisitors.add(new SyntaxHighlighterVisitor(sensorContext)); treeVisitors.add(new MetricsVisitor(sensorContext)); setParsingErrorCheckIfActivated(treeVisitors); ProgressReport progressReport = new ProgressReport("Report about progress of JSON analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(Lists.newArrayList(fileSystem.files(mainFilePredicate))); issueSaver = new IssueSaver(sensorContext, checks); List<Issue> issues = new ArrayList<>(); boolean success = false; try { for (InputFile inputFile : fileSystem.inputFiles(mainFilePredicate)) { LOG.debug("Analyzing " + inputFile.absolutePath() + "..."); issues.addAll(analyzeFile(sensorContext, inputFile, treeVisitors)); progressReport.nextFile(); } saveSingleFileIssues(issues); success = true; } finally { stopProgressReport(progressReport, success); } } JSONSquidSensor(FileSystem fileSystem, CheckFactory checkFactory);  JSONSquidSensor(FileSystem fileSystem, CheckFactory checkFactory, @Nullable CustomJSONRulesDefinition[] customRulesDefinition); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext sensorContext);  }