@Test public void should_disable_unnecessary_features_for_sonarlint() throws Exception { context.settings().setProperty(PhpPlugin.PHPUNIT_TESTS_REPORT_PATH_KEY, PhpTestUtils.PHPUNIT_REPORT_NAME); context.settings().setProperty(PhpPlugin.PHPUNIT_COVERAGE_REPORT_PATHS_KEY, PhpTestUtils.PHPUNIT_COVERAGE_REPORT); DefaultInputFile inputFile = inputFile(ANALYZED_FILE); DefaultInputFile testFile = TestInputFileBuilder.create("moduleKey", "src/AppTest.php") .setModuleBaseDir(context.fileSystem().baseDirPath()) .setType(InputFile.Type.TEST) .setLanguage(Php.KEY).build(); String testFileKey = testFile.key(); String mainFileKey = inputFile.key(); context.fileSystem().add(inputFile); context.fileSystem().add(testFile); context.setRuntime(SONARLINT_RUNTIME); createSensor().execute(context); assertThat(context.cpdTokens(mainFileKey)).isNull(); assertThat(context.highlightingTypeAt(mainFileKey, 1, 0)).isEmpty(); assertThat(context.measure(testFileKey, CoreMetrics.TESTS)).isNull(); assertThat(context.measure(testFileKey, CoreMetrics.LINES_TO_COVER)).isNull(); assertThat(context.measure(mainFileKey, CoreMetrics.NCLOC)).isNull(); assertThat(context.referencesForSymbolAt(mainFileKey, 6, 7)).isNull(); context.setRuntime(NOT_SONARLINT_RUNTIME); createSensor().execute(context); assertThat(context.cpdTokens(mainFileKey)).isNotEmpty(); assertThat(context.highlightingTypeAt(mainFileKey, 2, 0)).isNotEmpty(); assertThat(context.measure(testFileKey, CoreMetrics.TESTS)).isNotNull(); assertThat(context.measure(mainFileKey, CoreMetrics.NCLOC)).isNotNull(); assertThat(context.referencesForSymbolAt(mainFileKey, 6, 7)).isNotNull(); }
@Override public void execute(SensorContext context) { FileSystem fileSystem = context.fileSystem(); FilePredicate phpFilePredicate = fileSystem.predicates().hasLanguage(Php.KEY); List<InputFile> inputFiles = new ArrayList<>(); fileSystem.inputFiles(phpFilePredicate).forEach(inputFiles::add); SymbolScanner symbolScanner = new SymbolScanner(context); try { symbolScanner.execute(inputFiles); ProjectSymbolData projectSymbolData = symbolScanner.getProjectSymbolData(); new AnalysisScanner(context, projectSymbolData).execute(inputFiles); if (!inSonarLint(context)) { processTestsAndCoverage(context); } } catch (CancellationException e) { LOG.info(e.getMessage()); } }
PHPSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fileSystem = context.fileSystem(); FilePredicate phpFilePredicate = fileSystem.predicates().hasLanguage(Php.KEY); List<InputFile> inputFiles = new ArrayList<>(); fileSystem.inputFiles(phpFilePredicate).forEach(inputFiles::add); SymbolScanner symbolScanner = new SymbolScanner(context); try { symbolScanner.execute(inputFiles); ProjectSymbolData projectSymbolData = symbolScanner.getProjectSymbolData(); new AnalysisScanner(context, projectSymbolData).execute(inputFiles); if (!inSonarLint(context)) { processTestsAndCoverage(context); } } catch (CancellationException e) { LOG.info(e.getMessage()); } } }
PHPSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fileSystem = context.fileSystem(); FilePredicate phpFilePredicate = fileSystem.predicates().hasLanguage(Php.KEY); List<InputFile> inputFiles = new ArrayList<>(); fileSystem.inputFiles(phpFilePredicate).forEach(inputFiles::add); SymbolScanner symbolScanner = new SymbolScanner(context); try { symbolScanner.execute(inputFiles); ProjectSymbolData projectSymbolData = symbolScanner.getProjectSymbolData(); new AnalysisScanner(context, projectSymbolData).execute(inputFiles); if (!inSonarLint(context)) { processTestsAndCoverage(context); } } catch (CancellationException e) { LOG.info(e.getMessage()); } } PHPSensor(FileLinesContextFactory fileLinesContextFactory,
    CheckFactory checkFactory, NoSonarFilter noSonarFilter);  PHPSensor(FileLinesContextFactory fileLinesContextFactory,
    CheckFactory checkFactory, NoSonarFilter noSonarFilter, @Nullable PHPCustomRuleRepository[] customRuleRepositories);   PHPSensor(FileLinesContextFactory fileLinesContextFactory, PHPChecks checks, NoSonarFilter noSonarFilter); }
PHPSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fileSystem = context.fileSystem(); FilePredicate phpFilePredicate = fileSystem.predicates().hasLanguage(Php.KEY); List<InputFile> inputFiles = new ArrayList<>(); fileSystem.inputFiles(phpFilePredicate).forEach(inputFiles::add); SymbolScanner symbolScanner = new SymbolScanner(context); try { symbolScanner.execute(inputFiles); ProjectSymbolData projectSymbolData = symbolScanner.getProjectSymbolData(); new AnalysisScanner(context, projectSymbolData).execute(inputFiles); if (!inSonarLint(context)) { processTestsAndCoverage(context); } } catch (CancellationException e) { LOG.info(e.getMessage()); } } PHPSensor(FileLinesContextFactory fileLinesContextFactory,
    CheckFactory checkFactory, NoSonarFilter noSonarFilter);  PHPSensor(FileLinesContextFactory fileLinesContextFactory,
    CheckFactory checkFactory, NoSonarFilter noSonarFilter, @Nullable PHPCustomRuleRepository[] customRuleRepositories);   PHPSensor(FileLinesContextFactory fileLinesContextFactory, PHPChecks checks, NoSonarFilter noSonarFilter); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); @Override String toString(); }
PHPSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fileSystem = context.fileSystem(); FilePredicate phpFilePredicate = fileSystem.predicates().hasLanguage(Php.KEY); List<InputFile> inputFiles = new ArrayList<>(); fileSystem.inputFiles(phpFilePredicate).forEach(inputFiles::add); SymbolScanner symbolScanner = new SymbolScanner(context); try { symbolScanner.execute(inputFiles); ProjectSymbolData projectSymbolData = symbolScanner.getProjectSymbolData(); new AnalysisScanner(context, projectSymbolData).execute(inputFiles); if (!inSonarLint(context)) { processTestsAndCoverage(context); } } catch (CancellationException e) { LOG.info(e.getMessage()); } } PHPSensor(FileLinesContextFactory fileLinesContextFactory,
    CheckFactory checkFactory, NoSonarFilter noSonarFilter);  PHPSensor(FileLinesContextFactory fileLinesContextFactory,
    CheckFactory checkFactory, NoSonarFilter noSonarFilter, @Nullable PHPCustomRuleRepository[] customRuleRepositories);   PHPSensor(FileLinesContextFactory fileLinesContextFactory, PHPChecks checks, NoSonarFilter noSonarFilter); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); @Override String toString();  }