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 Deprecated Methods Modifier and Type Method Description booleanactivatedByDefault()Should this rule be enabled by default.CleanCodeAttributecleanCodeAttribute()DebtRemediationFunctiondebtRemediationFunction()java.util.Map<SoftwareQuality,Severity>defaultImpacts()java.util.Set<RuleKey>deprecatedRuleKeys()Deprecated rules keys for this rule.java.util.Set<java.lang.String>educationPrincipleKeys()booleanequals(java.lang.Object o)java.lang.StringgapDescription()inthashCode()java.lang.StringhtmlDescription()java.lang.StringinternalKey()java.lang.Stringkey()java.lang.StringmarkdownDescription()Deprecated, for removal: This API element is subject to removal in a future version.since 9.6 markdown support fur rule descriptions will be droppedjava.lang.Stringname()RulesDefinition.Paramparam(java.lang.String key)java.util.List<RulesDefinition.Param>params()java.lang.StringpluginKey()RulesDefinition.Repositoryrepository()java.util.List<RuleDescriptionSection>ruleDescriptionSections()SeeRulesDefinition.NewRule.addDescriptionSection(RuleDescriptionSection)to understand what are the requirements for a section.RuleScopescope()java.util.Set<java.lang.String>securityStandards()java.lang.Stringseverity()RuleStatusstatus()java.util.Set<java.lang.String>tags()booleantemplate()java.lang.StringtoString()RuleTypetype()
-
-
-
Method Detail
-
repository
public RulesDefinition.Repository repository()
- Specified by:
repositoryin classRulesDefinition.Rule
-
pluginKey
@CheckForNull public java.lang.String pluginKey()
- Specified by:
pluginKeyin classRulesDefinition.Rule
-
key
public java.lang.String key()
- Specified by:
keyin classRulesDefinition.Rule
-
name
public java.lang.String name()
- Specified by:
namein classRulesDefinition.Rule
-
scope
public RuleScope scope()
- Specified by:
scopein classRulesDefinition.Rule
-
type
public RuleType type()
- Specified by:
typein classRulesDefinition.Rule- See Also:
RulesDefinition.NewRule.setType(RuleType)
-
cleanCodeAttribute
@CheckForNull public CleanCodeAttribute cleanCodeAttribute()
- Specified by:
cleanCodeAttributein classRulesDefinition.Rule- See Also:
RulesDefinition.NewRule.setCleanCodeAttribute(CleanCodeAttribute)
-
severity
public java.lang.String severity()
- Specified by:
severityin classRulesDefinition.Rule
-
defaultImpacts
public java.util.Map<SoftwareQuality,Severity> defaultImpacts()
- Specified by:
defaultImpactsin classRulesDefinition.Rule- See Also:
RulesDefinition.NewRule.addDefaultImpact(SoftwareQuality, Severity)
-
ruleDescriptionSections
public java.util.List<RuleDescriptionSection> ruleDescriptionSections()
Description copied from class:RulesDefinition.RuleSeeRulesDefinition.NewRule.addDescriptionSection(RuleDescriptionSection)to understand what are the requirements for a section.- Specified by:
ruleDescriptionSectionsin classRulesDefinition.Rule
-
educationPrincipleKeys
public java.util.Set<java.lang.String> educationPrincipleKeys()
- Specified by:
educationPrincipleKeysin classRulesDefinition.Rule
-
htmlDescription
@CheckForNull public java.lang.String htmlDescription()
- Specified by:
htmlDescriptionin classRulesDefinition.Rule
-
markdownDescription
@CheckForNull @Deprecated(since="9.6", forRemoval=true) public java.lang.String markdownDescription()Deprecated, for removal: This API element is subject to removal in a future version.since 9.6 markdown support fur rule descriptions will be dropped- Specified by:
markdownDescriptionin classRulesDefinition.Rule
-
template
public boolean template()
- Specified by:
templatein classRulesDefinition.Rule
-
activatedByDefault
public boolean activatedByDefault()
Description copied from class:RulesDefinition.RuleShould this rule be enabled by default. For example in SonarLint standalone.- Specified by:
activatedByDefaultin classRulesDefinition.Rule
-
status
public RuleStatus status()
- Specified by:
statusin classRulesDefinition.Rule
-
debtRemediationFunction
@CheckForNull public DebtRemediationFunction debtRemediationFunction()
- Specified by:
debtRemediationFunctionin classRulesDefinition.Rule
-
gapDescription
@CheckForNull public java.lang.String gapDescription()
- Specified by:
gapDescriptionin classRulesDefinition.Rule
-
param
@CheckForNull public RulesDefinition.Param param(java.lang.String key)
- Specified by:
paramin classRulesDefinition.Rule
-
params
public java.util.List<RulesDefinition.Param> params()
- Specified by:
paramsin classRulesDefinition.Rule
-
tags
public java.util.Set<java.lang.String> tags()
- Specified by:
tagsin classRulesDefinition.Rule
-
securityStandards
public java.util.Set<java.lang.String> securityStandards()
- Specified by:
securityStandardsin classRulesDefinition.Rule
-
deprecatedRuleKeys
public java.util.Set<RuleKey> deprecatedRuleKeys()
Description copied from class:RulesDefinition.RuleDeprecated 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:Ais 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:
deprecatedRuleKeysin classRulesDefinition.Rule- See Also:
RulesDefinition.NewRule.addDeprecatedRuleKey(String, String)
- Rule
-
internalKey
@CheckForNull public java.lang.String internalKey()
- Specified by:
internalKeyin classRulesDefinition.Rule- See Also:
RulesDefinition.NewRule.setInternalKey(String)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-