Package org.sonar.api.batch.rule

Examples of org.sonar.api.batch.rule.Rules.find()


    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);
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)));
  }

  @Test
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)));
  }

  @Test
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)));
  }

  @Test
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)));
  }

  @Test
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)));
  }

  @Test
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();
  }

  @Test
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();
  }

  @Test
View Full Code Here

    assertThat(rules.findAll()).hasSize(3);
    assertThat(rules.findByRepository("squid")).hasSize(2);
    assertThat(rules.findByRepository("findbugs")).hasSize(1);
    assertThat(rules.findByRepository("unknown")).isEmpty();

    Rule squid1 = rules.find(RuleKey.of("squid", "S0001"));
    assertThat(squid1.key().repository()).isEqualTo("squid");
    assertThat(squid1.key().rule()).isEqualTo("S0001");
    assertThat(squid1.name()).isEqualTo("Detect bug");
    assertThat(squid1.description()).isEqualTo("Detect potential bug");
    assertThat(squid1.internalKey()).isEqualTo("foo=bar");
View Full Code Here

    assertThat(squid1.param("min").key()).isEqualTo("min");
    assertThat(squid1.param("min").description()).isNull();
    assertThat(squid1.param("max").key()).isEqualTo("max");
    assertThat(squid1.param("max").description()).isEqualTo("Maximum");

    Rule squid2 = rules.find(RuleKey.of("squid", "S0002"));
    assertThat(squid2.key().repository()).isEqualTo("squid");
    assertThat(squid2.key().rule()).isEqualTo("S0002");
    assertThat(squid2.description()).isNull();
    assertThat(squid2.internalKey()).isNull();
    assertThat(squid2.status()).isEqualTo(RuleStatus.defaultStatus());
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.