@Test public void sonarlint() throws Exception { tester.setRuntime(SonarRuntimeImpl.forSonarLint(Version.create(6, 7))); DefaultInputFile inputFile = createInputFile(TEST_DIR, "user-properties.jsp"); tester.fileSystem().add(inputFile); sensor.execute(tester); String componentKey = inputFile.key(); assertThat(tester.allIssues()).isNotEmpty(); assertThat(tester.cpdTokens(componentKey)).isNull(); assertThat(tester.highlightingTypeAt(componentKey, 1, 0)).isEmpty(); }
@Override public void execute(SensorContext sensorContext) { FileSystem fileSystem = sensorContext.fileSystem(); final HtmlAstScanner scanner = setupScanner(sensorContext); FilePredicates predicates = fileSystem.predicates(); Iterable<InputFile> inputFiles = fileSystem.inputFiles( predicates.and( predicates.hasType(InputFile.Type.MAIN), predicates.or( predicates.hasLanguages(HtmlConstants.LANGUAGE_KEY, HtmlConstants.JSP_LANGUAGE_KEY), predicates.or(Stream.of(OTHER_FILE_SUFFIXES).map(predicates::hasExtension).toArray(FilePredicate[]::new)) ) )); for (InputFile inputFile : inputFiles) { if (sensorContext.isCancelled()) { return; } HtmlSourceCode sourceCode = new HtmlSourceCode(inputFile); try (Reader reader = new InputStreamReader(inputFile.inputStream(), inputFile.charset())) { PageLexer lexer = inputFile.filename().endsWith(".vue") ? new VueLexer() : new PageLexer(); scanner.scan(lexer.parse(reader), sourceCode); saveMetrics(sensorContext, sourceCode); saveLineLevelMeasures(inputFile, sourceCode); } catch (Exception e) { LOG.error("Cannot analyze file " + inputFile, e); sensorContext.newAnalysisError() .onFile(inputFile) .message(e.getMessage()) .save(); } } }
HtmlSensor implements Sensor { @Override public void execute(SensorContext sensorContext) { FileSystem fileSystem = sensorContext.fileSystem(); final HtmlAstScanner scanner = setupScanner(sensorContext); FilePredicates predicates = fileSystem.predicates(); Iterable<InputFile> inputFiles = fileSystem.inputFiles( predicates.and( predicates.hasType(InputFile.Type.MAIN), predicates.or( predicates.hasLanguages(HtmlConstants.LANGUAGE_KEY, HtmlConstants.JSP_LANGUAGE_KEY), predicates.or(Stream.of(OTHER_FILE_SUFFIXES).map(predicates::hasExtension).toArray(FilePredicate[]::new)) ) )); for (InputFile inputFile : inputFiles) { if (sensorContext.isCancelled()) { return; } HtmlSourceCode sourceCode = new HtmlSourceCode(inputFile); try (Reader reader = new InputStreamReader(inputFile.inputStream(), inputFile.charset())) { PageLexer lexer = inputFile.filename().endsWith(".vue") ? new VueLexer() : new PageLexer(); scanner.scan(lexer.parse(reader), sourceCode); saveMetrics(sensorContext, sourceCode); saveLineLevelMeasures(inputFile, sourceCode); } catch (Exception e) { LOG.error("Cannot analyze file " + inputFile, e); sensorContext.newAnalysisError() .onFile(inputFile) .message(e.getMessage()) .save(); } } } }
HtmlSensor implements Sensor { @Override public void execute(SensorContext sensorContext) { FileSystem fileSystem = sensorContext.fileSystem(); final HtmlAstScanner scanner = setupScanner(sensorContext); FilePredicates predicates = fileSystem.predicates(); Iterable<InputFile> inputFiles = fileSystem.inputFiles( predicates.and( predicates.hasType(InputFile.Type.MAIN), predicates.or( predicates.hasLanguages(HtmlConstants.LANGUAGE_KEY, HtmlConstants.JSP_LANGUAGE_KEY), predicates.or(Stream.of(OTHER_FILE_SUFFIXES).map(predicates::hasExtension).toArray(FilePredicate[]::new)) ) )); for (InputFile inputFile : inputFiles) { if (sensorContext.isCancelled()) { return; } HtmlSourceCode sourceCode = new HtmlSourceCode(inputFile); try (Reader reader = new InputStreamReader(inputFile.inputStream(), inputFile.charset())) { PageLexer lexer = inputFile.filename().endsWith(".vue") ? new VueLexer() : new PageLexer(); scanner.scan(lexer.parse(reader), sourceCode); saveMetrics(sensorContext, sourceCode); saveLineLevelMeasures(inputFile, sourceCode); } catch (Exception e) { LOG.error("Cannot analyze file " + inputFile, e); sensorContext.newAnalysisError() .onFile(inputFile) .message(e.getMessage()) .save(); } } } HtmlSensor(NoSonarFilter noSonarFilter, FileLinesContextFactory fileLinesContextFactory, CheckFactory checkFactory); }
HtmlSensor implements Sensor { @Override public void execute(SensorContext sensorContext) { FileSystem fileSystem = sensorContext.fileSystem(); final HtmlAstScanner scanner = setupScanner(sensorContext); FilePredicates predicates = fileSystem.predicates(); Iterable<InputFile> inputFiles = fileSystem.inputFiles( predicates.and( predicates.hasType(InputFile.Type.MAIN), predicates.or( predicates.hasLanguages(HtmlConstants.LANGUAGE_KEY, HtmlConstants.JSP_LANGUAGE_KEY), predicates.or(Stream.of(OTHER_FILE_SUFFIXES).map(predicates::hasExtension).toArray(FilePredicate[]::new)) ) )); for (InputFile inputFile : inputFiles) { if (sensorContext.isCancelled()) { return; } HtmlSourceCode sourceCode = new HtmlSourceCode(inputFile); try (Reader reader = new InputStreamReader(inputFile.inputStream(), inputFile.charset())) { PageLexer lexer = inputFile.filename().endsWith(".vue") ? new VueLexer() : new PageLexer(); scanner.scan(lexer.parse(reader), sourceCode); saveMetrics(sensorContext, sourceCode); saveLineLevelMeasures(inputFile, sourceCode); } catch (Exception e) { LOG.error("Cannot analyze file " + inputFile, e); sensorContext.newAnalysisError() .onFile(inputFile) .message(e.getMessage()) .save(); } } } HtmlSensor(NoSonarFilter noSonarFilter, FileLinesContextFactory fileLinesContextFactory, CheckFactory checkFactory); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext sensorContext); }
HtmlSensor implements Sensor { @Override public void execute(SensorContext sensorContext) { FileSystem fileSystem = sensorContext.fileSystem(); final HtmlAstScanner scanner = setupScanner(sensorContext); FilePredicates predicates = fileSystem.predicates(); Iterable<InputFile> inputFiles = fileSystem.inputFiles( predicates.and( predicates.hasType(InputFile.Type.MAIN), predicates.or( predicates.hasLanguages(HtmlConstants.LANGUAGE_KEY, HtmlConstants.JSP_LANGUAGE_KEY), predicates.or(Stream.of(OTHER_FILE_SUFFIXES).map(predicates::hasExtension).toArray(FilePredicate[]::new)) ) )); for (InputFile inputFile : inputFiles) { if (sensorContext.isCancelled()) { return; } HtmlSourceCode sourceCode = new HtmlSourceCode(inputFile); try (Reader reader = new InputStreamReader(inputFile.inputStream(), inputFile.charset())) { PageLexer lexer = inputFile.filename().endsWith(".vue") ? new VueLexer() : new PageLexer(); scanner.scan(lexer.parse(reader), sourceCode); saveMetrics(sensorContext, sourceCode); saveLineLevelMeasures(inputFile, sourceCode); } catch (Exception e) { LOG.error("Cannot analyze file " + inputFile, e); sensorContext.newAnalysisError() .onFile(inputFile) .message(e.getMessage()) .save(); } } } HtmlSensor(NoSonarFilter noSonarFilter, FileLinesContextFactory fileLinesContextFactory, CheckFactory checkFactory); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext sensorContext);  }