@Test public void test_execute() throws IOException { addInputFile("file.css"); addInputFile("file-with-rule-id-message.css"); sensor.execute(context); assertThat(context.allIssues()).hasSize(2); assertThat(context.allIssues()).extracting("primaryLocation.message") .containsOnly("some message", "Unexpected empty block"); assertThat(String.join("\n", logTester.logs(LoggerLevel.DEBUG))) .matches("(?s).*Analyzing \\S*file\\.css.*") .matches("(?s).*Found 1 issue\\(s\\).*"); Path configPath = Paths.get(context.fileSystem().workDir().getAbsolutePath(), "css-bundle", "stylelintconfig.json"); assertThat(Files.readAllLines(configPath)).containsOnly( "{\"rules\":{" + "\"block-no-empty\":true," + "\"color-no-invalid-hex\":true," + "\"declaration-block-no-duplicate-properties\":[true,{\"ignore\":[\"consecutive-duplicates-with-different-values\"]}]" + "}}"); verifyZeroInteractions(analysisWarnings); }
@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);  }