Class RulesDefinition.Rule
- java.lang.Object
-
- org.sonar.api.server.rule.RulesDefinition.Rule
-
- Direct Known Subclasses:
DefaultRule
- Enclosing interface:
- RulesDefinition
@Immutable public abstract static class RulesDefinition.Rule extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Rule()
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description abstract boolean
activatedByDefault()
Should this rule be enabled by default.abstract DebtRemediationFunction
debtRemediationFunction()
abstract java.util.Set<RuleKey>
deprecatedRuleKeys()
Deprecated rules keys for this rule.abstract java.util.Set<java.lang.String>
educationPrincipleKeys()
abstract java.lang.String
gapDescription()
abstract java.lang.String
htmlDescription()
abstract java.lang.String
internalKey()
abstract java.lang.String
key()
abstract java.lang.String
markdownDescription()
Deprecated, for removal: This API element is subject to removal in a future version.use html format insteadabstract java.lang.String
name()
abstract RulesDefinition.Param
param(java.lang.String key)
abstract java.util.List<RulesDefinition.Param>
params()
abstract java.lang.String
pluginKey()
abstract RulesDefinition.Repository
repository()
abstract java.util.List<RuleDescriptionSection>
ruleDescriptionSections()
SeeRulesDefinition.NewRule.addDescriptionSection(RuleDescriptionSection)
to understand what are the requirements for a section.abstract RuleScope
scope()
abstract java.util.Set<java.lang.String>
securityStandards()
abstract java.lang.String
severity()
abstract RuleStatus
status()
abstract java.util.Set<java.lang.String>
tags()
abstract boolean
template()
abstract RuleType
type()
-
-
-
Method Detail
-
repository
public abstract RulesDefinition.Repository repository()
-
pluginKey
@CheckForNull public abstract java.lang.String pluginKey()
- Since:
- 6.6 the plugin the rule was declared in
-
key
public abstract java.lang.String key()
-
name
public abstract java.lang.String name()
-
scope
public abstract RuleScope scope()
- Since:
- 7.1
-
type
public abstract RuleType type()
- Since:
- 5.5
- See Also:
RulesDefinition.NewRule.setType(RuleType)
-
severity
public abstract java.lang.String severity()
-
ruleDescriptionSections
public abstract java.util.List<RuleDescriptionSection> ruleDescriptionSections()
SeeRulesDefinition.NewRule.addDescriptionSection(RuleDescriptionSection)
to understand what are the requirements for a section.- Since:
- 9.5
-
educationPrincipleKeys
public abstract java.util.Set<java.lang.String> educationPrincipleKeys()
- Since:
- 9.8
-
htmlDescription
@CheckForNull public abstract java.lang.String htmlDescription()
-
markdownDescription
@Deprecated(since="9.6", forRemoval=true) @CheckForNull public abstract java.lang.String markdownDescription()
Deprecated, for removal: This API element is subject to removal in a future version.use html format instead
-
template
public abstract boolean template()
-
activatedByDefault
public abstract boolean activatedByDefault()
Should this rule be enabled by default. For example in SonarLint standalone.- Since:
- 6.0
-
status
public abstract RuleStatus status()
-
debtRemediationFunction
@CheckForNull public abstract DebtRemediationFunction debtRemediationFunction()
-
gapDescription
@CheckForNull public abstract java.lang.String gapDescription()
-
param
@CheckForNull public abstract RulesDefinition.Param param(java.lang.String key)
-
params
public abstract java.util.List<RulesDefinition.Param> params()
-
tags
public abstract java.util.Set<java.lang.String> tags()
-
securityStandards
public abstract java.util.Set<java.lang.String> securityStandards()
-
deprecatedRuleKeys
public abstract java.util.Set<RuleKey> deprecatedRuleKeys()
Deprecated rules keys for this rule.If you want to rename the key of a rule or change its repository or both, register the rule's previous repository and key (see
addDeprecatedRuleKey
). This will allow SonarQube to support "issue re-keying" for this rule.If the repository and/or key of an existing rule is changed without declaring deprecated keys, existing issues for this rule, created under the rule's previous repository and/or key, will be closed and new ones will be created under the issue's new repository and/or key.
Several deprecated keys can be provided to allow SonarQube to support several key (and/or repository) changes across multiple versions of a plugin.
Consider the following use case scenario:- Rule
Foo:A
is defined in version 1 of the pluginNewRepository newRepository = context.createRepository("Foo", "my_language"); NewRule r = newRepository.createRule("A");
- Rule's key is renamed to B in version 2 of the plugin
NewRepository newRepository = context.createRepository("Foo", "my_language"); NewRule r = newRepository.createRule("B") .addDeprecatedRuleKey("Foo", "A");
- All rules, including
Foo:B
, are moved to a new repository Bar in version 3 of the pluginNewRepository newRepository = context.createRepository("Bar", "my_language"); NewRule r = newRepository.createRule("B") .addDeprecatedRuleKey("Foo", "A") .addDeprecatedRuleKey("Bar", "B");
- plugin upgrade from v1 to v2,
- plugin upgrade from v2 to v3
- AND plugin upgrade from v1 to v3
Finally, repository/key pairs must be unique across all rules and their deprecated keys.
This implies that no rule can use the same repository and key as the deprecated key of another rule. This uniqueness applies across plugins.Note that, even though this method returns a
Set
, its elements are ordered according to calls toaddDeprecatedRuleKey
. This allows to describe the history of a rule's repositories and keys over time. Oldest repository and key must be specified first.- Since:
- 7.1
- See Also:
RulesDefinition.NewRule.addDeprecatedRuleKey(String, String)
- Rule
-
internalKey
@CheckForNull public abstract java.lang.String internalKey()
-
-