public String getRepositoryKey() { return rule.getRepositoryKey(); }
/** * @deprecated since 2.3 use {@link #getRepositoryKey()} instead */ @Deprecated public String getPluginName() { return rule.getRepositoryKey(); }
@Override public boolean equals(Object obj) { if (!(obj instanceof Rule)) { return false; } if (this == obj) { return true; } Rule other = (Rule) obj; return new EqualsBuilder() .append(pluginName, other.getRepositoryKey()) .append(key, other.getKey()) .isEquals(); }
/** * Note: disabled rules are excluded. */ @CheckForNull public ActiveRule getActiveRule(Rule rule) { return getActiveRule(rule.getRepositoryKey(), rule.getKey()); }
/** * @since 3.6 */ public RuleKey ruleKey() { return RuleKey.of(getRepositoryKey(), getKey()); }
@Override @CheckForNull public String getName(Rule rule) { String name = message(rule.getRepositoryKey(), rule.getKey(), NAME_SUFFIX); return name != null ? name : rule.getName(); }
/** * @param optionalSeverity if null, then the default rule severity is used */ public ActiveRule activateRule(final Rule rule, @Nullable RulePriority optionalSeverity) { if (activeRules.stream().anyMatch(ar -> ar.getRule().equals(rule))) { throw MessageException.of(String.format( "The definition of the profile '%s' (language '%s') contains multiple occurrences of the '%s:%s' rule. The plugin which declares this profile should fix this.", getName(), getLanguage(), rule.getRepositoryKey(), rule.getKey())); } ActiveRule activeRule = new ActiveRule(this, rule, optionalSeverity); activeRules.add(activeRule); return activeRule; }
private static RuleKey toRuleKey(Rule rule) { return RuleKey.of(rule.getRepositoryKey(), rule.getKey()); }
private void verifyRule(Rule rule, RuleDefinitionDto ruleDefinition, RuleParamDto ruleParam) { assertThat(rule).isNotNull(); assertThat(rule.getName()).isEqualTo(ruleDefinition.getName()); assertThat(rule.getLanguage()).isEqualTo(ruleDefinition.getLanguage()); assertThat(rule.getKey()).isEqualTo(ruleDefinition.getRuleKey()); assertThat(rule.getConfigKey()).isEqualTo(ruleDefinition.getConfigKey()); assertThat(rule.isTemplate()).isEqualTo(ruleDefinition.isTemplate()); assertThat(rule.getCreatedAt().getTime()).isEqualTo(ruleDefinition.getCreatedAt()); assertThat(rule.getUpdatedAt().getTime()).isEqualTo(ruleDefinition.getUpdatedAt()); assertThat(rule.getRepositoryKey()).isEqualTo(ruleDefinition.getRepositoryKey()); assertThat(rule.getSeverity().name()).isEqualTo(ruleDefinition.getSeverityString()); assertThat(rule.getSystemTags()).isEqualTo(ruleDefinition.getSystemTags().stream().toArray(String[]::new)); assertThat(rule.getTags()).isEmpty(); assertThat(rule.getId()).isEqualTo(ruleDefinition.getId()); assertThat(rule.getDescription()).isEqualTo(ruleDefinition.getDescription()); assertThat(rule.getParams()).hasSize(1); org.sonar.api.rules.RuleParam param = rule.getParams().iterator().next(); assertThat(param.getRule()).isSameAs(rule); assertThat(param.getKey()).isEqualTo(ruleParam.getName()); assertThat(param.getDescription()).isEqualTo(ruleParam.getDescription()); assertThat(param.getType()).isEqualTo(ruleParam.getType()); assertThat(param.getDefaultValue()).isEqualTo(ruleParam.getDefaultValue()); } }
/** * @deprecated since 2.3 use {@link #getRepositoryKey()} instead */ @Deprecated public String getPluginName() { return rule.getRepositoryKey(); }
/** * @deprecated since 2.3 use {@link #getRepositoryKey()} instead */ @Deprecated public String getPluginName() { return rule.getRepositoryKey(); }
@Override public boolean equals(Object obj) { if (!(obj instanceof Rule)) { return false; } if (this == obj) { return true; } Rule other = (Rule) obj; return new EqualsBuilder() .append(pluginName, other.getRepositoryKey()) .append(key, other.getKey()) .isEquals(); }
/** * Note: disabled rules are excluded. */ @CheckForNull public ActiveRule getActiveRule(Rule rule) { return getActiveRule(rule.getRepositoryKey(), rule.getKey()); }
/** * Note: disabled rules are excluded. */ @CheckForNull public ActiveRule getActiveRule(Rule rule) { return getActiveRule(rule.getRepositoryKey(), rule.getKey()); }
/** * @since 3.6 */ public RuleKey ruleKey() { return RuleKey.of(getRepositoryKey(), getKey()); }
/** * @since 3.6 */ public RuleKey ruleKey() { return RuleKey.of(getRepositoryKey(), getKey()); }
@Override @CheckForNull public String getName(Rule rule) { String name = message(rule.getRepositoryKey(), rule.getKey(), NAME_SUFFIX); return name != null ? name : rule.getName(); }
/** * @param optionalSeverity if null, then the default rule severity is used */ public ActiveRule activateRule(final Rule rule, @Nullable RulePriority optionalSeverity) { if (activeRules.stream().anyMatch(ar -> ar.getRule().equals(rule))) { throw MessageException.of(String.format( "The definition of the profile '%s' (language '%s') contains multiple occurrences of the '%s:%s' rule. The plugin which declares this profile should fix this.", getName(), getLanguage(), rule.getRepositoryKey(), rule.getKey())); } ActiveRule activeRule = new ActiveRule(this, rule, optionalSeverity); activeRules.add(activeRule); return activeRule; }
public String nameForHTML(Rule rule) { String name = nameFromDB(RuleKey.of(rule.getRepositoryKey(), rule.getKey())); return StringEscapeUtils.escapeHtml(name != null ? name : rule.getName()); }
private DefaultIssue newIssue(Violation violation) { return new DefaultIssueBuilder() .componentKey(violation.getResource().getEffectiveKey()) // Project can be null but Violation not used by scan2 .projectKey(project.getRoot().getEffectiveKey()) .ruleKey(RuleKey.of(violation.getRule().getRepositoryKey(), violation.getRule().getKey())) .effortToFix(violation.getCost()) .line(violation.getLineId()) .message(violation.getMessage()) .severity(violation.getSeverity() != null ? violation.getSeverity().name() : null) .build(); }