Package org.sonar.api.batch.rule

Examples of org.sonar.api.batch.rule.Rule


      .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
      return false;
View Full Code Here


    }
  }

  private Long computeDebt(@Nullable Long debt, RuleKey ruleKey, SumMap<RuleKey> ruleDebts, SumMap<Characteristic> characteristicDebts) {
    if (debt != null) {
      Rule rule = rules.find(ruleKey);
      if (rule != null) {
        String characteristicKey = rule.debtSubCharacteristic();
        if (characteristicKey != null) {
          Characteristic characteristic = model.characteristicByKey(characteristicKey);
          if (characteristic != null) {
            ruleDebts.add(ruleKey, debt);
            characteristicDebts.add(characteristic, debt);
View Full Code Here

    assertThat(rules.findAll()).hasSize(1);
    assertThat(rules.findByRepository("checkstyle")).hasSize(1);
    assertThat(rules.findByRepository("unknown")).isEmpty();

    Rule rule = rules.find(RuleKey.of("checkstyle", "AvoidNull"));
    assertThat(rule).isNotNull();
    assertThat(rule.key()).isEqualTo(RuleKey.of("checkstyle", "AvoidNull"));
    assertThat(rule.name()).isEqualTo("Avoid Null");
    assertThat(rule.description()).isEqualTo("Should avoid NULL");
    assertThat(rule.severity()).isEqualTo(Severity.MINOR);
    assertThat(rule.internalKey()).isNull();
    assertThat(rule.params()).hasSize(1);

    RuleParam param = rule.param("myParameter");
    assertThat(param).isNotNull();
    assertThat(param.description()).isEqualTo("My Parameter");
  }
View Full Code Here

  public void build_rules_with_default_debt_definitions() throws Exception {
    setupData("build_rules_with_default_debt_definitions");

    Rules rules = provider.provide(ruleDao, debtModel, durations);

    Rule rule = rules.find(RuleKey.of("checkstyle", "AvoidNull"));
    assertThat(rule.debtSubCharacteristic()).isEqualTo("EFFICIENCY");
    assertThat(rule.debtRemediationFunction()).isEqualTo(DebtRemediationFunction.createLinearWithOffset(Duration.decode("5d", 8), Duration.decode("10h", 8)));
  }
View Full Code Here

  public void build_rules_with_overridden_debt_definitions() throws Exception {
    setupData("build_rules_with_overridden_debt_definitions");

    Rules rules = provider.provide(ruleDao, debtModel, durations);

    Rule rule = rules.find(RuleKey.of("checkstyle", "AvoidNull"));
    assertThat(rule.debtSubCharacteristic()).isEqualTo("PORTABILITY");
    assertThat(rule.debtRemediationFunction()).isEqualTo(DebtRemediationFunction.createLinear(Duration.decode("2h", 8)));
  }
View Full Code Here

    setupData("build_rules_with_default_and_overridden_debt_definitions");

    Rules rules = provider.provide(ruleDao, debtModel, durations);

    // As both default columns and user columns on debt are set, user debt columns should be used
    Rule rule = rules.find(RuleKey.of("checkstyle", "AvoidNull"));
    assertThat(rule.debtSubCharacteristic()).isEqualTo("PORTABILITY");
    assertThat(rule.debtRemediationFunction()).isEqualTo(DebtRemediationFunction.createLinear(Duration.decode("2h", 8)));
  }
View Full Code Here

    setupData("build_rules_with_default_characteristic_and_overridden_function");

    Rules rules = provider.provide(ruleDao, debtModel, durations);

    // As both default columns and user columns on debt are set, user debt columns should be used
    Rule rule = rules.find(RuleKey.of("checkstyle", "AvoidNull"));
    assertThat(rule.debtSubCharacteristic()).isEqualTo("PORTABILITY");
    assertThat(rule.debtRemediationFunction()).isEqualTo(DebtRemediationFunction.createLinear(Duration.decode("2h", 8)));
  }
View Full Code Here

    setupData("build_rules_with_overridden_characteristic_and_default_function");

    Rules rules = provider.provide(ruleDao, debtModel, durations);

    // As both default columns and user columns on debt are set, user debt columns should be used
    Rule rule = rules.find(RuleKey.of("checkstyle", "AvoidNull"));
    assertThat(rule.debtSubCharacteristic()).isEqualTo("PORTABILITY");
    assertThat(rule.debtRemediationFunction()).isEqualTo(DebtRemediationFunction.createLinear(Duration.decode("2h", 8)));
  }
View Full Code Here

  public void build_rules_with_disable_characteristic() throws Exception {
    setupData("build_rules_with_disable_characteristic");

    Rules rules = provider.provide(ruleDao, debtModel, durations);

    Rule rule = rules.find(RuleKey.of("checkstyle", "AvoidNull"));
    assertThat(rule.debtSubCharacteristic()).isNull();
    assertThat(rule.debtRemediationFunction()).isNull();
  }
View Full Code Here

  public void build_rules_with_default_characteristic_and_disable_characteristic() throws Exception {
    setupData("build_rules_with_default_characteristic_and_disable_characteristic");

    Rules rules = provider.provide(ruleDao, debtModel, durations);

    Rule rule = rules.find(RuleKey.of("checkstyle", "AvoidNull"));
    assertThat(rule.debtSubCharacteristic()).isNull();
    assertThat(rule.debtRemediationFunction()).isNull();
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.batch.rule.Rule

Copyright © 2018 www.massapicom. 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.