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(); } } }
public PerlCriticParserExecutor(SensorContext context) { this.context = context; this.activeRules = context.activeRules(); this.fileSystem = context.fileSystem(); }
public void initializeChecks(SensorContext context) { if (initialized) return; String permId = (context.runtime().getProduct() == SonarProduct.SONARLINT ? "sonarlint-" : "") + OpenEdgeProjectHelper.getServerId(context); // Proparse and XREF rules for (ActiveRule rule : context.activeRules().findByLanguage(Constants.LANGUAGE_KEY)) { OpenEdgeCheck<?> lint = initializeCheck(context, rule, permId); if ((lint != null) && (lint.getCheckType() == CheckType.PROPARSE)) { ppChecksMap.put(rule, (OpenEdgeProparseCheck) lint); } } // DB rules for (ActiveRule rule : context.activeRules().findByLanguage(Constants.DB_LANGUAGE_KEY)) { OpenEdgeCheck<?> lint = initializeCheck(context, rule, permId); if ((lint != null) && (lint.getCheckType() == CheckType.DUMP_FILE)) { dfChecksMap.put(rule, (OpenEdgeDumpFileCheck) lint); } } initialized = true; }
private void reportViolations(SensorContext context, Map<InputFile, List<Violation>> violationsByFile) { for (Entry<InputFile, List<Violation>> violationsOnFile : violationsByFile.entrySet()) { InputFile groovyFile = violationsOnFile.getKey(); if (groovyFile == null) { continue; } for (Violation violation : violationsOnFile.getValue()) { String ruleKey = violation.getRule().getName(); ActiveRule activeRule = context.activeRules().findByInternalKey(CodeNarcRulesDefinition.REPOSITORY_KEY, ruleKey); if (activeRule != null) { insertIssue(context, activeRule.ruleKey(), violation.getLineNumber(), violation.getMessage(), groovyFile); } else { LOG.warn("No such rule in SonarQube, so violation from CodeNarc will be ignored: {}", ruleKey); } } } }
private void analyzeFile(SensorContext context, InputFile file, File out) throws IOException { FileSystem fileSystem = context.fileSystem(); List<Issue> issues = analyzer.analyze(file.absolutePath(), fileSystem.encoding(), out); for (Issue pylintIssue : issues) { ActiveRule rule = context.activeRules().find(RuleKey.of(PylintRuleRepository.REPOSITORY_KEY, pylintIssue.getRuleId())); PylintImportSensor.processRule(pylintIssue, file, rule, context); } }
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(); } } }
Collection<ActiveRule> allRules = ctx.activeRules().findByRepository(TsRulesDefinition.REPOSITORY_NAME); HashSet<String> ruleNames = new HashSet<>(); for (ActiveRule rule : allRules) {
private static void saveIssues(List<Issue> issues, SensorContext context) { FileSystem fileSystem = context.fileSystem(); for (Issue pylintIssue : issues) { String filepath = pylintIssue.getFilename(); InputFile pyfile = fileSystem.inputFile(fileSystem.predicates().hasPath(filepath)); if (pyfile != null) { ActiveRule rule = context.activeRules().find(RuleKey.of(PylintRuleRepository.REPOSITORY_KEY, pylintIssue.getRuleId())); processRule(pylintIssue, pyfile, rule, context); } else { LOG.warn("Cannot find the file '{}' in SonarQube, ignoring violation", filepath); } } }
private static void saveIssues(List<Issue> issues, SensorContext context) { FileSystem fileSystem = context.fileSystem(); for (Issue pylintIssue : issues) { String filepath = pylintIssue.getFilename(); InputFile pyfile = fileSystem.inputFile(fileSystem.predicates().hasPath(filepath)); if (pyfile != null) { ActiveRule rule = context.activeRules().find(RuleKey.of(PylintRuleRepository.REPOSITORY_KEY, pylintIssue.getRuleId())); processRule(pylintIssue, pyfile, rule, context); } else { LOG.warn("Cannot find the file '{}' in SonarQube, ignoring violation", filepath); } } }
private void parseReport(SensorContext context, List<File> reports) { for (File report : reports) { Collection<CodeNarcViolation> violations = CodeNarcXMLParser.parse(report, context.fileSystem()); for (CodeNarcViolation violation : violations) { ActiveRule activeRule = context.activeRules().findByInternalKey(CodeNarcRulesDefinition.REPOSITORY_KEY, violation.getRuleName()); if (activeRule != null) { InputFile inputFile = inputFileFor(context, violation.getFilename()); insertIssue(context, violation, activeRule.ruleKey(), inputFile); } else { LOG.warn("No such rule in SonarQube, so violation from CodeNarc will be ignored: {}", violation.getRuleName()); } } } }
private void analyzeFile(SensorContext context, InputFile file, File out) throws IOException { FileSystem fileSystem = context.fileSystem(); String pylintConfigPath = conf.getPylintConfigPath(fileSystem); String pylintPath = conf.getPylintPath(); PylintIssuesAnalyzer analyzer = new PylintIssuesAnalyzer(pylintPath, pylintConfigPath); List<Issue> issues = analyzer.analyze(file.absolutePath(), fileSystem.encoding(), out); for (Issue pylintIssue : issues) { ActiveRule rule = context.activeRules().find(RuleKey.of(PylintRuleRepository.REPOSITORY_KEY, pylintIssue.getRuleId())); PylintImportSensor.processRule(pylintIssue, file, rule, context); } }
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(); } } }
final RuleKey defaultWarningRuleKey = RuleKey.of(Constants.STD_REPOSITORY_KEY, OpenEdgeRulesDefinition.COMPILER_WARNING_RULEKEY); if (context.activeRules().find(defaultWarningRuleKey) == null) { LOG.info("'Compiler warning' rule is not activated in your profile - Warning files analysis skipped"); return; NewIssue issue = context.newIssue().forRule(context.activeRules().find(ruleKey) == null ? defaultWarningRuleKey : ruleKey); NewIssueLocation location = issue.newLocation().on(target); if (w.line > 0) {