Package org.sonar.api.rule

Examples of org.sonar.api.rule.RuleKey


      .setHtmlDescription("Some description")
      .setSeverity(Severity.MAJOR)
      .setStatus(RuleStatus.READY)
      .setParameters(ImmutableMap.of("regex", ""));

    RuleKey customRuleKey = creator.create(newRule);
    dbSession.clearCache();

    List<RuleParamDto> params = db.ruleDao().findRuleParamsByRuleKey(dbSession, customRuleKey);
    assertThat(params).hasSize(1);
View Full Code Here


      .setName("My custom")
      .setHtmlDescription("Some description")
      .setSeverity(Severity.MAJOR)
      .setStatus(RuleStatus.READY);

    RuleKey customRuleKey = creator.create(newRule);
    dbSession.clearCache();

    List<RuleParamDto> params = db.ruleDao().findRuleParamsByRuleKey(dbSession, customRuleKey);
    assertThat(params).hasSize(1);
View Full Code Here

      .setName("New name")
      .setMarkdownDescription("New description")
      .setSeverity(Severity.MAJOR)
      .setStatus(RuleStatus.READY)
      .setParameters(ImmutableMap.of("regex", "c.*"));
    RuleKey customRuleKey = creator.create(newRule);

    dbSession.clearCache();

    Rule result = ruleIndex.getByKey(customRuleKey);
    assertThat(result.key()).isEqualTo(RuleKey.of("java", key));
View Full Code Here

  @Test
  public void create_manual_rule() throws Exception {
    NewRule newRule = NewRule.createForManualRule("MANUAL_RULE")
      .setName("My manual")
      .setMarkdownDescription("Some description");
    RuleKey ruleKey = creator.create(newRule);

    dbSession.clearCache();

    Rule rule = ruleIndex.getByKey(ruleKey);
    assertThat(rule).isNotNull();
View Full Code Here

  public void create_manual_rule_with_severity() throws Exception {
    NewRule newRule = NewRule.createForManualRule("MANUAL_RULE")
      .setName("My manual")
      .setMarkdownDescription("Some description")
      .setSeverity(Severity.BLOCKER);
    RuleKey ruleKey = creator.create(newRule);

    dbSession.clearCache();

    Rule rule = ruleIndex.getByKey(ruleKey);
    assertThat(rule).isNotNull();
View Full Code Here

    // Create a rule with the same key and with another name, description and severity
    NewRule newRule = NewRule.createForManualRule(key)
      .setName("New name")
      .setMarkdownDescription("New description");
    RuleKey ruleKey = creator.create(newRule);

    dbSession.clearCache();

    Rule result = ruleIndex.getByKey(ruleKey);
    assertThat(result.key()).isEqualTo(RuleKey.of("manual", key));
View Full Code Here

    model.setPersonId(measure.getPersonId());
    model.setValue(measure.getValue());
    if (measure instanceof RuleMeasure) {
      RuleMeasure ruleMeasure = (RuleMeasure) measure;
      model.setRulePriority(ruleMeasure.getSeverity());
      RuleKey ruleKey = ruleMeasure.ruleKey();
      if (ruleKey != null) {
        Rule ruleWithId = ruleFinder.findByKey(ruleKey);
        if (ruleWithId == null) {
          throw new IllegalStateException("Can not save a measure with unknown rule " + ruleMeasure);
        }
View Full Code Here

    assertThat(((CheckWithPrimitiveProperties) check).getMax()).isEqualTo(300);
  }

  @Test
  public void use_engine_key() {
    RuleKey ruleKey = RuleKey.of("squid", "One");
    builder.create(ruleKey).setInternalKey("S0001").activate();

    CheckFactory checkFactory = new CheckFactory(builder.build());
    Checks checks = checkFactory.create("squid").addAnnotatedChecks(CheckWithKey.class);
View Full Code Here

  @Test
  public void fail_if_field_type_is_not_supported() {
    thrown.expect(SonarException.class);

    RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithUnsupportedPropertyType");
    builder.create(ruleKey).setParam("max", "300").activate();

    CheckFactory checkFactory = new CheckFactory(builder.build());
    checkFactory.create("squid").addAnnotatedChecks(CheckWithUnsupportedPropertyType.class);
  }
View Full Code Here

    checkFactory.create("squid").addAnnotatedChecks(CheckWithUnsupportedPropertyType.class);
  }

  @Test
  public void override_field_key() {
    RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithOverriddenPropertyKey");
    builder.create(ruleKey).setParam("maximum", "300").activate();

    CheckFactory checkFactory = new CheckFactory(builder.build());
    Checks checks = checkFactory.create("squid").addAnnotatedChecks(CheckWithOverriddenPropertyKey.class);
View Full Code Here

TOP

Related Classes of org.sonar.api.rule.RuleKey

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.