@Override public void execute(SensorContext context) { FileSystem fs = context.fileSystem(); FilePredicates p = fs.predicates(); for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(InputFile.Type.MAIN)))) { createIssues(file, context); } if (context.config().getBoolean(REGISTER_AD_HOC_RULE).orElse(false)) { context.newAdHocRule() .engineId(ENGINE_ID) .ruleId(RULE_ID) .name("An ad hoc rule") .description("blah blah") .severity(Severity.BLOCKER) .type(RuleType.BUG) .save(); } }
private String reportPath() { return context.config() .get(REPORT_PATH_KEY) .orElse(DEFAULT_REPORT_PATH); }
private String reportPath() { return context.config() .get(REPORT_PATH_KEY) .orElse(DEFAULT_REPORT_PATH); }
private String reportPath() { return context.config() .get(REPORT_PATH_KEY) .orElse(DEFAULT_REPORT_PATH); }
private String reportPath() { return context.config() .get(REPORT_PATH_KEY) .orElse(DEFAULT_REPORT_PATH); }
protected String reportPath() { return context.config() .get(REPORT_PATH_KEY) .orElse(DEFAULT_REPORT_PATH); }
private String reportPath() { return context.config() .get(REPORT_PATTERN_KEY) .orElse(DEFAULT_REPORT_PATTERN); }
private String reportPath() { return context.config() .get(REPORT_PATH_KEY) .orElse(DEFAULT_REPORT_PATH); }
private boolean isPropertyUsed(String legacyPathKey) { return context.config().get(legacyPathKey).isPresent(); } }
public boolean shouldFailAnalysisOnException() { return context.config().getBoolean(FAIL_ON_EXCEPTION_KEY).orElse(false); }
@Override public void execute(SensorContext context) { String[] reports = context.config().getStringArray(JavaScriptPlugin.LCOV_REPORT_PATHS); List<String> reportPaths = Lists.newArrayList(reports); if (!reportPaths.isEmpty()) { saveMeasureFromLCOVFile(context, reportPaths); } }
private Optional<String> getReportPath(SensorContext context) { Optional<String> reportPath = context.config().get(PerlCriticProperties.PERLCRITIC_REPORT_PATH_KEY); log.info("Configured report path: {}", reportPath); return reportPath; }
private Optional<String> getArchiveReportPath(SensorContext context) { Optional<String> reportPath = context.config().get(TestHarnessArchiveProperties.HARNESS_ARCHIVE_PATH_KEY); log.info("Configured archive report path: {}", reportPath); return reportPath; } private Optional<String> getJUnitReportPath(SensorContext context) {
/** * @return ServerID based on the SonarQube version */ public static String getServerId(SensorContext context) { String str = context.config().get(context.getSonarQubeVersion().isGreaterThanOrEqual(Version.parse("6.7")) ? CoreProperties.SERVER_ID : CoreProperties.PERMANENT_SERVER_ID).orElse(""); int dashIndex = str.indexOf('-'); return (dashIndex == 8) && (str.length() >= 20) ? str.substring(dashIndex + 1) : str; }
@Override public final void importReport(SensorContext context) { Optional<String> reportPath = context.config().get(reportPathKey); if (reportPath.isPresent()) { importReport(reportPath.get(), msg, context); } else { LOG.info("No PHPUnit {} report provided (see '{}' property)", msg, reportPathKey); } }
@Override public final void importReport(SensorContext context) { Optional<String> reportPath = context.config().get(reportPathKey); if (reportPath.isPresent()) { importReport(reportPath.get(), msg, context); } else { LOG.info("No PHPUnit {} report provided (see '{}' property)", msg, reportPathKey); } }
/** * Check if property consumed by SonarTS to import ESLint issues is set */ private static void checkDeprecatedEslintProperty(SensorContext context) { if (ArrayUtils.isNotEmpty(context.config().getStringArray(DEPRECATED_ESLINT_PROPERTY))) { LOG.warn("Property '{}' is deprecated, use '{}'.", DEPRECATED_ESLINT_PROPERTY, ESLINT_REPORT_PATHS); } }
static Stream<Path> getReportPaths(SensorContext sensorContext) { Configuration config = sensorContext.config(); Path baseDir = sensorContext.fileSystem().baseDir().toPath(); String[] reportPaths = config.getStringArray(REPORT_PATH_KEY); return Arrays.stream(reportPaths).flatMap(reportPath -> isWildcard(reportPath) ? getPatternPaths(baseDir, reportPath) : getRegularPath(baseDir, reportPath)); }
private void scanFile(SensorContext sensorContext, InputFile inputFile, ProductDependentExecutor executor, List<TreeVisitor> visitors, ScriptTree scriptTree) { JavaScriptVisitorContext context = new JavaScriptVisitorContext(scriptTree, inputFile, sensorContext.config()); List<Issue> fileIssues = new ArrayList<>(); for (TreeVisitor visitor : visitors) { if (visitor instanceof JavaScriptCheck) { fileIssues.addAll(((JavaScriptCheck) visitor).scanFile(context)); } else { visitor.scanTree(context); } } saveFileIssues(sensorContext, fileIssues, inputFile); executor.highlightSymbols(inputFile, context); }
private void scanFile(SensorContext sensorContext, InputFile inputFile, ProductDependentExecutor executor, List<TreeVisitor> visitors, ScriptTree scriptTree) { JavaScriptVisitorContext context = new JavaScriptVisitorContext(scriptTree, inputFile, sensorContext.config()); List<Issue> fileIssues = new ArrayList<>(); for (TreeVisitor visitor : visitors) { if (visitor instanceof JavaScriptCheck) { fileIssues.addAll(((JavaScriptCheck) visitor).scanFile(context)); } else { visitor.scanTree(context); } } saveFileIssues(sensorContext, fileIssues, inputFile); executor.highlightSymbols(inputFile, context); }