Examples of RuleKey


Examples of org.sonar.api.rule.RuleKey

    return matched.get(issue);
  }

  void addUnmatched(IssueDto i) {
    unmatchedByKey.put(i.getKee(), i);
    RuleKey ruleKey = RuleKey.of(i.getRuleRepo(), i.getRule());
    if (!unmatchedByRuleAndKey.containsKey(ruleKey)) {
      unmatchedByRuleAndKey.put(ruleKey, new HashMap<String, IssueDto>());
      unmatchedByRuleAndLineAndChecksum.put(ruleKey, new HashMap<Integer, Multimap<String, IssueDto>>());
    }
    unmatchedByRuleAndKey.get(ruleKey).put(i.getKee(), i);
View Full Code Here

Examples of org.sonar.api.rule.RuleKey

    return lineNotNull;
  }

  void setMatch(DefaultIssue issue, IssueDto matching) {
    matched.put(issue, matching);
    RuleKey ruleKey = RuleKey.of(matching.getRuleRepo(), matching.getRule());
    unmatchedByRuleAndKey.get(ruleKey).remove(matching.getKee());
    unmatchedByKey.remove(matching.getKee());
    Integer lineNotNull = lineNotNull(matching);
    String checksumNotNull = StringUtils.defaultString(matching.getChecksum(), "");
    unmatchedByRuleAndLineAndChecksum.get(ruleKey).get(lineNotNull).get(checksumNotNull).remove(matching);
View Full Code Here

Examples of org.sonar.api.rule.RuleKey

    ListMultimap<Integer, RuleParamDto> paramDtosByRuleId = ArrayListMultimap.create();
    for (RuleParamDto dto : ruleParamDtos) {
      paramDtosByRuleId.put(dto.getRuleId(), dto);
    }
    for (RuleDto ruleDto : ruleDao.selectEnablesAndNonManual()) {
      RuleKey ruleKey = RuleKey.of(ruleDto.getRepositoryKey(), ruleDto.getRuleKey());
      NewRule newRule = rulesBuilder.add(ruleKey)
        .setId(ruleDto.getId())
        .setName(ruleDto.getName())
        .setSeverity(ruleDto.getSeverityString())
        .setDescription(ruleDto.getDescription())
View Full Code Here

Examples of org.sonar.api.rule.RuleKey

      .severity(violation.getSeverity() != null ? violation.getSeverity().name() : null)
      .build();
  }

  private boolean initAndAddIssue(DefaultIssue issue, @Nullable Violation violation) {
    RuleKey ruleKey = issue.ruleKey();
    Rule rule = rules.find(ruleKey);
    validateRule(issue, rule);
    ActiveRule activeRule = activeRules.find(ruleKey);
    if (activeRule == null) {
      // rule does not exist or is not enabled -> ignore the issue
View Full Code Here

Examples of org.sonar.api.rule.RuleKey

    }
    return false;
  }

  private void validateRule(DefaultIssue issue, Rule rule) {
    RuleKey ruleKey = issue.ruleKey();
    if (rule == null) {
      throw MessageException.of(String.format("The rule '%s' does not exist.", ruleKey));
    }
    if (Strings.isNullOrEmpty(rule.name()) && Strings.isNullOrEmpty(issue.message())) {
      throw MessageException.of(String.format("The rule '%s' has no name and the related issue has no message.", ruleKey));
View Full Code Here

Examples of org.sonar.api.rule.RuleKey

  public void insert_new_rules() {
    execute(new FakeRepositoryV1());

    // verify db
    assertThat(dbClient.ruleDao().findAll(dbSession)).hasSize(2);
    RuleKey ruleKey1 = RuleKey.of("fake", "rule1");
    RuleDto rule1 = dbClient.ruleDao().getNullableByKey(dbSession, ruleKey1);
    assertThat(rule1.getName()).isEqualTo("One");
    assertThat(rule1.getDescription()).isEqualTo("Description of One");
    assertThat(rule1.getSeverityString()).isEqualTo(Severity.BLOCKER);
    assertThat(rule1.getTags()).isEmpty();
View Full Code Here

Examples of org.sonar.api.rule.RuleKey

    assertThat(dbClient.ruleDao().findAll(dbSession)).hasSize(2);

    when(system.now()).thenReturn(DATE2.getTime());
    execute(new FakeRepositoryV1());

    RuleKey ruleKey1 = RuleKey.of("fake", "rule1");
    RuleDto rule1 = dbClient.ruleDao().getNullableByKey(dbSession, ruleKey1);
    assertThat(rule1.getCreatedAt()).isEqualTo(DATE1);
    assertThat(rule1.getUpdatedAt()).isEqualTo(DATE1);
  }
View Full Code Here

Examples of org.sonar.api.rule.RuleKey

  public void update_and_remove_rules_on_changes() {
    execute(new FakeRepositoryV1());
    assertThat(dbClient.ruleDao().findAll(dbSession)).hasSize(2);

    // user adds tags and sets markdown note
    RuleKey ruleKey1 = RuleKey.of("fake", "rule1");
    RuleDto rule1 = dbClient.ruleDao().getNullableByKey(dbSession, ruleKey1);
    rule1.setTags(Sets.newHashSet("usertag1", "usertag2"));
    rule1.setNoteData("user *note*");
    rule1.setNoteUserLogin("marius");
    dbClient.ruleDao().update(dbSession, rule1);
View Full Code Here

Examples of org.sonar.api.rule.RuleKey

  }

  @Test
  public void fail_to_delete_if_not_custom_or_not_manual() throws Exception {
    // Create rule
    RuleKey ruleKey = RuleKey.of("java", "S001");
    dao.insert(dbSession, RuleTesting.newDto(ruleKey));
    dbSession.commit();

    try {
      // Delete rule
View Full Code Here

Examples of org.sonar.api.rule.RuleKey

    JSONAssert.assertEquals(expected, writer.toString(), false);
  }

  @Test
  public void should_exclude_resolved_issues() throws Exception {
    RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles");
    DefaultIssue issue = new DefaultIssue()
      .setKey("200")
      .setComponentKey("struts:src/main/java/org/apache/struts/Action.java")
      .setRuleKey(ruleKey)
      .setStatus(Issue.STATUS_CLOSED)
      .setResolution(Issue.RESOLUTION_FIXED)
      .setCreationDate(SIMPLE_DATE_FORMAT.parse("2013-04-24"))
      .setUpdateDate(SIMPLE_DATE_FORMAT.parse("2013-04-25"))
      .setCloseDate(SIMPLE_DATE_FORMAT.parse("2013-04-26"))
      .setNew(false);
    when(ruleFinder.findByKey(ruleKey)).thenReturn(Rule.create(ruleKey.repository(), ruleKey.rule()).setName("Avoid Cycles"));
    when(jsonReport.getIssues()).thenReturn(Lists.newArrayList(issue));

    StringWriter writer = new StringWriter();
    jsonReport.writeJson(writer);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.