Package org.sonar.api.server.rule
Class RulesDefinition.NewRule
- java.lang.Object
-
- org.sonar.api.server.rule.RulesDefinition.NewRule
-
- Enclosing interface:
- RulesDefinition
public static class RulesDefinition.NewRule extends java.lang.Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RulesDefinition.NewRuleaddCwe(int... nums)RulesDefinition.NewRuleaddDeprecatedRuleKey(java.lang.String repository, java.lang.String key)Register a repository and key under which this rule used to be known (seeRulesDefinition.Rule.deprecatedRuleKeysfor details).RulesDefinition.NewRuleaddOwaspTop10(RulesDefinition.OwaspTop10... standards)RulesDefinition.NewRuleaddTags(java.lang.String... list)RulesDefinition.NewParamcreateParam(java.lang.String paramKey)Create a parameter with given unique key.RulesDefinition.DebtRemediationFunctionsdebtRemediationFunctions()Factory ofDebtRemediationFunctionjava.lang.Stringkey()RulesDefinition.NewParamparam(java.lang.String paramKey)java.util.Collection<RulesDefinition.NewParam>params()RuleScopescope()RulesDefinition.NewRulesetActivatedByDefault(boolean activatedByDefault)Should this rule be enabled by default.RulesDefinition.NewRulesetDebtRemediationFunction(DebtRemediationFunction fn)RulesDefinition.NewRulesetDebtSubCharacteristic(java.lang.String s)Deprecated.in 5.5.RulesDefinition.NewRulesetEffortToFixDescription(java.lang.String s)Deprecated.since 5.5, replaced bysetGapDescription(String)RulesDefinition.NewRulesetGapDescription(java.lang.String s)For rules that use LINEAR or LINEAR_OFFSET remediation functions, the meaning of the function parameter (= "gap") must be set.RulesDefinition.NewRulesetHtmlDescription(java.lang.String s)The optional description, in HTML format, has no max length.RulesDefinition.NewRulesetHtmlDescription(java.net.URL classpathUrl)Load description from a file available in classpath.RulesDefinition.NewRulesetInternalKey(java.lang.String s)Optional key that can be used by the rule engine.RulesDefinition.NewRulesetMarkdownDescription(java.lang.String s)The optional description, in a restricted Markdown format, has no max length.RulesDefinition.NewRulesetMarkdownDescription(java.net.URL classpathUrl)Load description from a file available in classpath.RulesDefinition.NewRulesetName(java.lang.String s)Required rule nameRulesDefinition.NewRulesetScope(RuleScope scope)RulesDefinition.NewRulesetSeverity(java.lang.String s)RulesDefinition.NewRulesetStatus(RuleStatus status)Default value isRuleStatus.READY.RulesDefinition.NewRulesetTags(java.lang.String... list)RulesDefinition.NewRulesetTemplate(boolean template)RulesDefinition.NewRulesetType(RuleType t)The type as defined by the SonarQube Quality Model.java.lang.StringtoString()
-
-
-
Method Detail
-
key
public java.lang.String key()
-
scope
@CheckForNull public RuleScope scope()
- Since:
- 7.1
-
setScope
public RulesDefinition.NewRule setScope(RuleScope scope)
- Since:
- 7.1
-
setName
public RulesDefinition.NewRule setName(java.lang.String s)
Required rule name
-
setTemplate
public RulesDefinition.NewRule setTemplate(boolean template)
-
setActivatedByDefault
public RulesDefinition.NewRule setActivatedByDefault(boolean activatedByDefault)
Should this rule be enabled by default. For example in SonarLint standalone.- Since:
- 6.0
-
setSeverity
public RulesDefinition.NewRule setSeverity(java.lang.String s)
-
setType
public RulesDefinition.NewRule setType(RuleType t)
The type as defined by the SonarQube Quality Model.
When a plugin does not define rule type, then it is deduced from tags:- if the rule has the "bug" tag then type is
RuleType.BUG - if the rule has the "security" tag then type is
RuleType.VULNERABILITY - if the rule has both tags "bug" and "security", then type is
RuleType.BUG - default type is
RuleType.CODE_SMELL
- Since:
- 5.5
- if the rule has the "bug" tag then type is
-
setHtmlDescription
public RulesDefinition.NewRule setHtmlDescription(@Nullable java.lang.String s)
The optional description, in HTML format, has no max length. It's exclusive with markdown description (seesetMarkdownDescription(String))
-
setHtmlDescription
public RulesDefinition.NewRule setHtmlDescription(@Nullable java.net.URL classpathUrl)
Load description from a file available in classpath. Example :setHtmlDescription(getClass().getResource("/myrepo/Rule1234.html")
-
setMarkdownDescription
public RulesDefinition.NewRule setMarkdownDescription(@Nullable java.lang.String s)
The optional description, in a restricted Markdown format, has no max length. It's exclusive with HTML description (seesetHtmlDescription(String))
-
setMarkdownDescription
public RulesDefinition.NewRule setMarkdownDescription(@Nullable java.net.URL classpathUrl)
Load description from a file available in classpath. Example :setMarkdownDescription(getClass().getResource("/myrepo/Rule1234.md")
-
setStatus
public RulesDefinition.NewRule setStatus(RuleStatus status)
Default value isRuleStatus.READY. The valueRuleStatus.REMOVEDis not accepted and raises anIllegalArgumentException.
-
setDebtSubCharacteristic
public RulesDefinition.NewRule setDebtSubCharacteristic(@Nullable java.lang.String s)
Deprecated.in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. This method does nothing. See https://jira.sonarsource.com/browse/MMF-184SQALE sub-characteristic. See http://www.sqale.org- See Also:
for constant values,setType(RuleType)
-
debtRemediationFunctions
public RulesDefinition.DebtRemediationFunctions debtRemediationFunctions()
Factory ofDebtRemediationFunction
-
setDebtRemediationFunction
public RulesDefinition.NewRule setDebtRemediationFunction(@Nullable DebtRemediationFunction fn)
- See Also:
debtRemediationFunctions()
-
setEffortToFixDescription
@Deprecated public RulesDefinition.NewRule setEffortToFixDescription(@Nullable java.lang.String s)
Deprecated.since 5.5, replaced bysetGapDescription(String)
-
setGapDescription
public RulesDefinition.NewRule setGapDescription(@Nullable java.lang.String s)
For rules that use LINEAR or LINEAR_OFFSET remediation functions, the meaning of the function parameter (= "gap") must be set. This description explains what 1 point of "gap" represents for the rule.
Example: for the "Insufficient condition coverage", this description for the remediation function gap multiplier/base effort would be something like "Effort to test one uncovered condition".
-
createParam
public RulesDefinition.NewParam createParam(java.lang.String paramKey)
Create a parameter with given unique key. Max length of key is 128 characters.
-
param
@CheckForNull public RulesDefinition.NewParam param(java.lang.String paramKey)
-
params
public java.util.Collection<RulesDefinition.NewParam> params()
-
addTags
public RulesDefinition.NewRule addTags(java.lang.String... list)
- See Also:
RuleTagFormat
-
setTags
public RulesDefinition.NewRule setTags(java.lang.String... list)
- See Also:
RuleTagFormat
-
addOwaspTop10
public RulesDefinition.NewRule addOwaspTop10(RulesDefinition.OwaspTop10... standards)
- Since:
- 7.3
-
addCwe
public RulesDefinition.NewRule addCwe(int... nums)
- Since:
- 7.3
-
setInternalKey
public RulesDefinition.NewRule setInternalKey(@Nullable java.lang.String s)
Optional key that can be used by the rule engine. Not displayed in webapp. For example the Java Checkstyle plugin feeds this field with the internal path ("Checker/TreeWalker/AnnotationUseStyle").
-
addDeprecatedRuleKey
public RulesDefinition.NewRule addDeprecatedRuleKey(java.lang.String repository, java.lang.String key)
Register a repository and key under which this rule used to be known (seeRulesDefinition.Rule.deprecatedRuleKeysfor details).Deprecated keys should be added with this method in order, oldest first, for documentation purpose.
- Throws:
java.lang.IllegalArgumentException- ifrepositoryorkeyisnullor empty.- Since:
- 7.1
- See Also:
RulesDefinition.Rule.deprecatedRuleKeys
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-