@Test public void should_execute_on_file_with_chars_before_prolog() throws Exception { init(false); fs.add(createInputFile("src/pom_with_chars_before_prolog_and_missing_new_line.xml")); sensor.execute(context); assertThat(context.allIssues()).extracting("ruleKey").containsOnly(NEW_LINE_RULE_KEY); }
@Override public void execute(SensorContext context) { List<InputFile> inputFiles = new ArrayList<>(); fileSystem.inputFiles(mainFilesPredicate).forEach(inputFiles::add); if (inputFiles.isEmpty()) { return; } boolean isSonarLintContext = context.runtime().getProduct() == SonarProduct.SONARLINT; ProgressReport progressReport = new ProgressReport("Report about progress of XML analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(inputFiles.stream().map(InputFile::toString).collect(Collectors.toList())); boolean cancelled = false; try { for (InputFile inputFile : inputFiles) { if (context.isCancelled()) { cancelled = true; break; } scanFile(context, inputFile, isSonarLintContext); progressReport.nextFile(); } } finally { if (!cancelled) { progressReport.stop(); } else { progressReport.cancel(); } } }
XmlSensor implements Sensor { @Override public void execute(SensorContext context) { List<InputFile> inputFiles = new ArrayList<>(); fileSystem.inputFiles(mainFilesPredicate).forEach(inputFiles::add); if (inputFiles.isEmpty()) { return; } boolean isSonarLintContext = context.runtime().getProduct() == SonarProduct.SONARLINT; ProgressReport progressReport = new ProgressReport("Report about progress of XML analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(inputFiles.stream().map(InputFile::toString).collect(Collectors.toList())); boolean cancelled = false; try { for (InputFile inputFile : inputFiles) { if (context.isCancelled()) { cancelled = true; break; } scanFile(context, inputFile, isSonarLintContext); progressReport.nextFile(); } } finally { if (!cancelled) { progressReport.stop(); } else { progressReport.cancel(); } } } }
XmlSensor implements Sensor { @Override public void execute(SensorContext context) { List<InputFile> inputFiles = new ArrayList<>(); fileSystem.inputFiles(mainFilesPredicate).forEach(inputFiles::add); if (inputFiles.isEmpty()) { return; } boolean isSonarLintContext = context.runtime().getProduct() == SonarProduct.SONARLINT; ProgressReport progressReport = new ProgressReport("Report about progress of XML analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(inputFiles.stream().map(InputFile::toString).collect(Collectors.toList())); boolean cancelled = false; try { for (InputFile inputFile : inputFiles) { if (context.isCancelled()) { cancelled = true; break; } scanFile(context, inputFile, isSonarLintContext); progressReport.nextFile(); } } finally { if (!cancelled) { progressReport.stop(); } else { progressReport.cancel(); } } } XmlSensor(FileSystem fileSystem, CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory); }
XmlSensor implements Sensor { @Override public void execute(SensorContext context) { List<InputFile> inputFiles = new ArrayList<>(); fileSystem.inputFiles(mainFilesPredicate).forEach(inputFiles::add); if (inputFiles.isEmpty()) { return; } boolean isSonarLintContext = context.runtime().getProduct() == SonarProduct.SONARLINT; ProgressReport progressReport = new ProgressReport("Report about progress of XML analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(inputFiles.stream().map(InputFile::toString).collect(Collectors.toList())); boolean cancelled = false; try { for (InputFile inputFile : inputFiles) { if (context.isCancelled()) { cancelled = true; break; } scanFile(context, inputFile, isSonarLintContext); progressReport.nextFile(); } } finally { if (!cancelled) { progressReport.stop(); } else { progressReport.cancel(); } } } XmlSensor(FileSystem fileSystem, CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory); @Override void execute(SensorContext context); @Override String toString(); @Override void describe(SensorDescriptor descriptor); }
XmlSensor implements Sensor { @Override public void execute(SensorContext context) { List<InputFile> inputFiles = new ArrayList<>(); fileSystem.inputFiles(mainFilesPredicate).forEach(inputFiles::add); if (inputFiles.isEmpty()) { return; } boolean isSonarLintContext = context.runtime().getProduct() == SonarProduct.SONARLINT; ProgressReport progressReport = new ProgressReport("Report about progress of XML analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(inputFiles.stream().map(InputFile::toString).collect(Collectors.toList())); boolean cancelled = false; try { for (InputFile inputFile : inputFiles) { if (context.isCancelled()) { cancelled = true; break; } scanFile(context, inputFile, isSonarLintContext); progressReport.nextFile(); } } finally { if (!cancelled) { progressReport.stop(); } else { progressReport.cancel(); } } } XmlSensor(FileSystem fileSystem, CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory); @Override void execute(SensorContext context); @Override String toString(); @Override void describe(SensorDescriptor descriptor);  }