@Override public void execute(SensorContext context) { File f = new File(context.settings().getString(SONAR_XOO_RANDOM_ACCESS_ISSUE_PATHS)); FileSystem fs = context.fileSystem(); FilePredicates p = fs.predicates(); try { for (String path : FileUtils.readLines(f)) { createIssues(fs.inputFile(p.and(p.hasPath(path), p.hasType(Type.MAIN), p.hasLanguage(Xoo.KEY))), context); } } catch (IOException e) { throw new IllegalStateException(e); } }
newIssue .forRule(ruleKey) .gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)) .at(newIssue.newLocation() .on(inputFile)
private void createIssues(InputFile file, SensorContext context, String repo) { RuleKey ruleKey = RuleKey.of(repo, RULE_KEY); String severity = context.settings().getString(FORCE_SEVERITY_PROPERTY); for (int line = 1; line <= file.lines(); line++) { NewIssue newIssue = context.newIssue(); newIssue .forRule(ruleKey) .at(newIssue.newLocation() .on(file) .at(file.selectLine(line)) .message("This issue is generated on each line")) .overrideSeverity(severity != null ? Severity.valueOf(severity) : null); if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(5, 5))) { newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)); } else { newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)); } newIssue.save(); } }
private static void createIssues(InputFile file, SensorContext context) { ActiveRule rule = context.activeRules().findByInternalKey(XooRulesDefinition.XOO_REPOSITORY, context.settings().getString(INTERNAL_KEY_PROPERTY)); if (rule != null) { NewIssue newIssue = context.newIssue(); newIssue .forRule(rule.ruleKey()) .at(newIssue.newLocation() .on(file) .message("This issue is generated on each file")) .save(); } } }
private List<String> getExcludedPath(SensorContext context) { String globalExcludedPath = context.settings().getString(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY); if (globalExcludedPath == null) { return new ArrayList<>(); } return Arrays.asList(globalExcludedPath.split(",")); }
private boolean isForceZeroCoverageActivated(SensorContext ctx) { return ctx.settings().getBoolean(TypeScriptPlugin.SETTING_FORCE_ZERO_COVERAGE); }
public CoverageParser(SensorContext context) { checkDtd = context.settings().getBoolean(GoProperties.DTD_VERIFICATION_KEY); }
private boolean isIgnoreNotFoundActivated(SensorContext ctx) { return ctx.settings().getBoolean(TypeScriptPlugin.SETTING_IGNORE_NOT_FOUND); }
@Override public String getPath(SensorContext context, String settingKey, String defaultValue) { // Prefer the specified path String toReturn = context.settings().getString(settingKey); // Fall back to a file system search if null or doesn't exist if (toReturn == null || toReturn.isEmpty()) { LOG.debug("Path {} not specified, falling back to {}", settingKey, defaultValue); toReturn = defaultValue; } else { LOG.debug("Found {} path to be '{}'", settingKey, toReturn); } return getAbsolutePath(context, toReturn); }
@Override public void execute(SensorContext context) { if (context.settings().getBoolean(HelloWorldProperties.HELLO_KEY)) { // print log only if property is set to true Loggers.get(getClass()).info("Hello World!"); } }
@Override public void execute(SensorContext ctx, Map<InputFile, Set<Integer>> nonCommentLineNumbersByFile) { Map<InputFile, Set<Integer>> nonCommentLineMap = nonCommentLineNumbersByFile; List<String> reportPaths = parseReportsProperty(ctx.settings().getString(TypeScriptPlugin.SETTING_LCOV_REPORT_PATH)); if (nonCommentLineMap == null) { nonCommentLineMap = new HashMap<>(); } if (!reportPaths.isEmpty()) { saveMeasureFromLCOVFile(ctx, nonCommentLineMap, reportPaths); } else if (isForceZeroCoverageActivated(ctx)) { saveZeroValueForAllFiles(ctx, nonCommentLineMap); } } }
@Override public void execute(SensorContext context) { if (!context.settings().getBoolean(GoProperties.HIGHLIGHTING_KEY)) { LOGGER.info("highlighting disabled"); return; } final List<InputFile> listFiles = ProjectExplorer.searchFileWithTypeMainOrTest(context); listFiles.forEach(i -> new Colorizer(context).colorize(i)); }
@Override public void execute(SensorContext context) { try (Stream<Path> paths = createStream(context)) { paths.forEach(filePath -> { LOGGER.debug("Path in stream" + filePath.toFile().getAbsolutePath()); if (filePath.toFile().isDirectory()) { final String reportPath = context.settings().getString(GoProperties.COVERAGE_REPORT_PATH_KEY); final File f = new File(filePath + File.separator + reportPath); if (f.exists()) { LOGGER.info("Analyse for " + f.getPath()); final CoverageParser coverParser = new CoverageParser(context); try { coverParser.parse(f.getPath()); save(context, coverParser.getCoveragePerFile()); } catch (ParserConfigurationException | IOException e) { LOGGER.error("Exception: ", e); } } else { LOGGER.info("no coverage file in package " + f.getPath()); } } }); ProjectExplorer.searchByType(context, InputFile.Type.MAIN).stream() .filter(i -> !inputFileWithCoverage.contains(i)).forEach(i -> saveForAllLine(context, i)); } catch (final IOException e) { LOGGER.error("IO Exception " + context.fileSystem().baseDir().getPath()); } }
@Override public void execute(SensorContext context) { File f = new File(context.settings().getString(SONAR_XOO_RANDOM_ACCESS_ISSUE_PATHS)); FileSystem fs = context.fileSystem(); FilePredicates p = fs.predicates(); try { for (String path : FileUtils.readLines(f)) { createIssues(fs.inputFile(p.and(p.hasPath(path), p.hasType(Type.MAIN), p.hasLanguage(Xoo.KEY))), context); } } catch (IOException e) { throw new IllegalStateException(e); } }
@Override public void execute(SensorContext context) { File f = new File(context.settings().getString(SONAR_XOO_RANDOM_ACCESS_ISSUE_PATHS)); FileSystem fs = context.fileSystem(); FilePredicates p = fs.predicates(); try { for (String path : FileUtils.readLines(f)) { createIssues(fs.inputFile(p.and(p.hasPath(path), p.hasType(Type.MAIN), p.hasLanguage(Xoo.KEY))), context); } } catch (IOException e) { throw new IllegalStateException(e); } }
@Override public void execute(SensorContext context) { String reportPath = context.settings().getString(GoProperties.JUNIT_REPORT_PATH_KEY); if (reportPath == null || !(new File(reportPath)).exists()) { LOGGER.info("no junit report"); return; } FunctionFinder ff; try { ff = new FunctionFinder(context); Map<String, String> nameFunction = ff.searchFunction(); LOGGER.debug(nameFunction.toString()); GoJunitParser junitParser = new GoJunitParser(nameFunction); junitParser.parse(reportPath); GoTestReportSaver.save(context, junitParser.getListTestSuite()); } catch (ParserConfigurationException | SAXException | IOException e) { LOGGER.error("Parse exception ", e); } }
private void createIssues(InputFile file, SensorContext context) { RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY); String severity = context.settings().getString(FORCE_SEVERITY_PROPERTY); for (int line = 1; line <= file.lines(); line++) { context.newIssue() .forRule(ruleKey) .onFile(file) .atLine(line) .effortToFix(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)) .overrideSeverity(severity != null ? Severity.valueOf(severity) : null) .message("This issue is generated on each line") .save(); } } }
private void createIssues(InputFile file, SensorContext context) { ActiveRule rule = context.activeRules().findByInternalKey(XooRulesDefinition.XOO_REPOSITORY, context.settings().getString(INTERNAL_KEY_PROPERTY)); if (rule != null) { context.newIssue() .forRule(rule.ruleKey()) .onFile(file) .message("This issue is generated on each file") .save(); } } }
private void createIssues(InputFile file, SensorContext context, String repo) { RuleKey ruleKey = RuleKey.of(repo, RULE_KEY); String severity = context.settings().getString(FORCE_SEVERITY_PROPERTY); for (int line = 1; line <= file.lines(); line++) { NewIssue newIssue = context.newIssue(); newIssue .forRule(ruleKey) .at(newIssue.newLocation() .on(file) .at(file.selectLine(line)) .message("This issue is generated on each line")) .overrideSeverity(severity != null ? Severity.valueOf(severity) : null); if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(5, 5))) { newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)); } else { newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)); } newIssue.save(); } }
private static void createIssues(InputFile file, SensorContext context) { ActiveRule rule = context.activeRules().findByInternalKey(XooRulesDefinition.XOO_REPOSITORY, context.settings().getString(INTERNAL_KEY_PROPERTY)); if (rule != null) { NewIssue newIssue = context.newIssue(); newIssue .forRule(rule.ruleKey()) .at(newIssue.newLocation() .on(file) .message("This issue is generated on each file")) .save(); } } }