public static File getReport(Project project, MavenProject mavenProject, String file) {
    File report = getReportFromPluginConfiguration(project, mavenProject, file);
    if (report == null) {
      report = getReportFromDefaultPath(project, file);
    }

    if (report == null || !report.exists() || !report.isFile()) {
      Logs.INFO.warn("PomQuality report not found at {}", report);
      report = null;
    }
    return report;
  }
Ejemplo n.º 2
0
  public void analyse(Project project, SensorContext context) {
    if (project.getReuseExistingRulesConfig()) {
      Logs.INFO.warn("Reusing existing PMD configuration is not supported any more.");
    }
    try {
      File xmlReport = executor.execute();
      getStaxParser(project, context).parse(xmlReport);

    } catch (Exception e) {
      // TOFIX
      throw new XmlParserException(e);
    }
  }
Ejemplo n.º 3
0
  private void registerRepository(RuleRepository repository, DatabaseSession session) {
    Map<String, Rule> rulesByKey = Maps.newHashMap();
    for (Rule rule : repository.createRules()) {
      rule.setRepositoryKey(repository.getKey());
      rulesByKey.put(rule.getKey(), rule);
    }
    Logs.INFO.info(rulesByKey.size() + " rules");

    List<Rule> persistedRules = session.getResults(Rule.class, "pluginName", repository.getKey());
    for (Rule persistedRule : persistedRules) {
      Rule rule = rulesByKey.get(persistedRule.getKey());
      if (rule != null) {
        updateRule(persistedRule, rule, session);
        rulesByKey.remove(rule.getKey());
      }
    }

    saveNewRules(rulesByKey.values(), session);
  }