@Test public void should_send_file_content_if_context_is_sonarlint() throws IOException { String filePath = "copy-file-content-into-issue-message.css"; DefaultInputFile inputFile = new TestInputFileBuilder("moduleKey", filePath) .setLanguage(CssLanguage.KEY) .setCharset(StandardCharsets.UTF_8) .setContents("css content") .build(); context.fileSystem().add(inputFile); context.setRuntime(SonarRuntimeImpl.forSonarLint(Version.create(7, 9))); sensor.execute(context); assertThat(context.allIssues()).hasSize(1); assertThat(context.allIssues()).extracting("primaryLocation.message") .containsOnly("css content"); }
@Override public void execute(SensorContext context) { reportOldNodeProperty(context); List<InputFile> inputFiles = getInputFiles(context); if (inputFiles.isEmpty()) { LOG.info("No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped."); return; } File configFile = null; boolean serverRunning = false; try { serverRunning = cssAnalyzerBridgeServer.startServerLazily(context); configFile = createLinterConfig(context); } catch (Exception e) { String msg = "Failure during CSS analysis preparation, " + cssAnalyzerBridgeServer.getCommandInfo(); logErrorOrWarn(context, msg, e); throwFailFast(context, e); } if (serverRunning && configFile != null) { analyzeFiles(context, inputFiles, configFile); } }
CssRuleSensor implements Sensor { @Override public void execute(SensorContext context) { reportOldNodeProperty(context); List<InputFile> inputFiles = getInputFiles(context); if (inputFiles.isEmpty()) { LOG.info("No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped."); return; } File configFile = null; boolean serverRunning = false; try { serverRunning = cssAnalyzerBridgeServer.startServerLazily(context); configFile = createLinterConfig(context); } catch (Exception e) { String msg = "Failure during CSS analysis preparation, " + cssAnalyzerBridgeServer.getCommandInfo(); logErrorOrWarn(context, msg, e); throwFailFast(context, e); } if (serverRunning && configFile != null) { analyzeFiles(context, inputFiles, configFile); } } }
CssRuleSensor implements Sensor { @Override public void execute(SensorContext context) { reportOldNodeProperty(context); List<InputFile> inputFiles = getInputFiles(context); if (inputFiles.isEmpty()) { LOG.info("No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped."); return; } File configFile = null; boolean serverRunning = false; try { serverRunning = cssAnalyzerBridgeServer.startServerLazily(context); configFile = createLinterConfig(context); } catch (Exception e) { String msg = "Failure during CSS analysis preparation, " + cssAnalyzerBridgeServer.getCommandInfo(); logErrorOrWarn(context, msg, e); throwFailFast(context, e); } if (serverRunning && configFile != null) { analyzeFiles(context, inputFiles, configFile); } } CssRuleSensor(
    CheckFactory checkFactory,
    CssAnalyzerBridgeServer cssAnalyzerBridgeServer,
    @Nullable AnalysisWarnings analysisWarnings
  ); }
CssRuleSensor implements Sensor { @Override public void execute(SensorContext context) { reportOldNodeProperty(context); List<InputFile> inputFiles = getInputFiles(context); if (inputFiles.isEmpty()) { LOG.info("No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped."); return; } File configFile = null; boolean serverRunning = false; try { serverRunning = cssAnalyzerBridgeServer.startServerLazily(context); configFile = createLinterConfig(context); } catch (Exception e) { String msg = "Failure during CSS analysis preparation, " + cssAnalyzerBridgeServer.getCommandInfo(); logErrorOrWarn(context, msg, e); throwFailFast(context, e); } if (serverRunning && configFile != null) { analyzeFiles(context, inputFiles, configFile); } } CssRuleSensor(
    CheckFactory checkFactory,
    CssAnalyzerBridgeServer cssAnalyzerBridgeServer,
    @Nullable AnalysisWarnings analysisWarnings
  ); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); static void throwFailFast(SensorContext context, Exception e); static boolean hasCssFiles(SensorContext context); }
CssRuleSensor implements Sensor { @Override public void execute(SensorContext context) { reportOldNodeProperty(context); List<InputFile> inputFiles = getInputFiles(context); if (inputFiles.isEmpty()) { LOG.info("No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped."); return; } File configFile = null; boolean serverRunning = false; try { serverRunning = cssAnalyzerBridgeServer.startServerLazily(context); configFile = createLinterConfig(context); } catch (Exception e) { String msg = "Failure during CSS analysis preparation, " + cssAnalyzerBridgeServer.getCommandInfo(); logErrorOrWarn(context, msg, e); throwFailFast(context, e); } if (serverRunning && configFile != null) { analyzeFiles(context, inputFiles, configFile); } } CssRuleSensor(
    CheckFactory checkFactory,
    CssAnalyzerBridgeServer cssAnalyzerBridgeServer,
    @Nullable AnalysisWarnings analysisWarnings
  ); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); static void throwFailFast(SensorContext context, Exception e); static boolean hasCssFiles(SensorContext context);  }