Class DefaultRule
- java.lang.Object
-
- org.sonar.api.server.rule.RulesDefinition.Rule
-
- org.sonar.api.server.rule.internal.DefaultRule
-
@Immutable public class DefaultRule extends RulesDefinition.Rule
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
activatedByDefault()
Should this rule be enabled by default.DebtRemediationFunction
debtRemediationFunction()
java.util.Set<RuleKey>
deprecatedRuleKeys()
Deprecated rules keys for this rule.boolean
equals(java.lang.Object o)
java.lang.String
gapDescription()
int
hashCode()
java.lang.String
htmlDescription()
java.lang.String
internalKey()
java.lang.String
key()
java.lang.String
markdownDescription()
java.lang.String
name()
RulesDefinition.Param
param(java.lang.String key)
java.util.List<RulesDefinition.Param>
params()
java.lang.String
pluginKey()
RulesDefinition.Repository
repository()
RuleScope
scope()
java.util.Set<java.lang.String>
securityStandards()
java.lang.String
severity()
RuleStatus
status()
java.util.Set<java.lang.String>
tags()
boolean
template()
java.lang.String
toString()
RuleType
type()
-
-
-
Method Detail
-
repository
public RulesDefinition.Repository repository()
- Specified by:
repository
in classRulesDefinition.Rule
-
pluginKey
@CheckForNull public java.lang.String pluginKey()
- Specified by:
pluginKey
in classRulesDefinition.Rule
-
key
public java.lang.String key()
- Specified by:
key
in classRulesDefinition.Rule
-
name
public java.lang.String name()
- Specified by:
name
in classRulesDefinition.Rule
-
scope
public RuleScope scope()
- Specified by:
scope
in classRulesDefinition.Rule
-
type
public RuleType type()
- Specified by:
type
in classRulesDefinition.Rule
- See Also:
RulesDefinition.NewRule.setType(RuleType)
-
severity
public java.lang.String severity()
- Specified by:
severity
in classRulesDefinition.Rule
-
htmlDescription
@CheckForNull public java.lang.String htmlDescription()
- Specified by:
htmlDescription
in classRulesDefinition.Rule
-
markdownDescription
@CheckForNull public java.lang.String markdownDescription()
- Specified by:
markdownDescription
in classRulesDefinition.Rule
-
template
public boolean template()
- Specified by:
template
in classRulesDefinition.Rule
-
activatedByDefault
public boolean activatedByDefault()
Description copied from class:RulesDefinition.Rule
Should this rule be enabled by default. For example in SonarLint standalone.- Specified by:
activatedByDefault
in classRulesDefinition.Rule
-
status
public RuleStatus status()
- Specified by:
status
in classRulesDefinition.Rule
-
debtRemediationFunction
@CheckForNull public DebtRemediationFunction debtRemediationFunction()
- Specified by:
debtRemediationFunction
in classRulesDefinition.Rule
-
gapDescription
@CheckForNull public java.lang.String gapDescription()
- Specified by:
gapDescription
in classRulesDefinition.Rule
-
param
@CheckForNull public RulesDefinition.Param param(java.lang.String key)
- Specified by:
param
in classRulesDefinition.Rule
-
params
public java.util.List<RulesDefinition.Param> params()
- Specified by:
params
in classRulesDefinition.Rule
-
tags
public java.util.Set<java.lang.String> tags()
- Specified by:
tags
in classRulesDefinition.Rule
-
securityStandards
public java.util.Set<java.lang.String> securityStandards()
- Specified by:
securityStandards
in classRulesDefinition.Rule
-
deprecatedRuleKeys
public java.util.Set<RuleKey> deprecatedRuleKeys()
Description copied from class:RulesDefinition.Rule
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.- Specified by:
deprecatedRuleKeys
in classRulesDefinition.Rule
- See Also:
RulesDefinition.NewRule.addDeprecatedRuleKey(String, String)
- Rule
-
internalKey
@CheckForNull public java.lang.String internalKey()
- Specified by:
internalKey
in classRulesDefinition.Rule
- See Also:
RulesDefinition.NewRule.setInternalKey(String)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-