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.NewRule
addCwe(int... nums)
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.deprecatedRuleKeys
for details).RulesDefinition.NewRule
addOwaspTop10(RulesDefinition.OwaspTop10... standards)
RulesDefinition.NewRule
addTags(java.lang.String... list)
RulesDefinition.NewParam
createParam(java.lang.String paramKey)
Create a parameter with given unique key.RulesDefinition.DebtRemediationFunctions
debtRemediationFunctions()
Factory ofDebtRemediationFunction
java.lang.String
key()
RulesDefinition.NewParam
param(java.lang.String paramKey)
java.util.Collection<RulesDefinition.NewParam>
params()
RuleScope
scope()
RulesDefinition.NewRule
setActivatedByDefault(boolean activatedByDefault)
Should this rule be enabled by default.RulesDefinition.NewRule
setDebtRemediationFunction(DebtRemediationFunction fn)
RulesDefinition.NewRule
setDebtSubCharacteristic(java.lang.String s)
Deprecated.in 5.5.RulesDefinition.NewRule
setEffortToFixDescription(java.lang.String s)
Deprecated.since 5.5, replaced bysetGapDescription(String)
RulesDefinition.NewRule
setGapDescription(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.NewRule
setHtmlDescription(java.lang.String s)
The optional description, in HTML format, has no max length.RulesDefinition.NewRule
setHtmlDescription(java.net.URL classpathUrl)
Load description from a file available in classpath.RulesDefinition.NewRule
setInternalKey(java.lang.String s)
Optional key that can be used by the rule engine.RulesDefinition.NewRule
setMarkdownDescription(java.lang.String s)
The optional description, in a restricted Markdown format, has no max length.RulesDefinition.NewRule
setMarkdownDescription(java.net.URL classpathUrl)
Load description from a file available in classpath.RulesDefinition.NewRule
setName(java.lang.String s)
Required rule nameRulesDefinition.NewRule
setScope(RuleScope scope)
RulesDefinition.NewRule
setSeverity(java.lang.String s)
RulesDefinition.NewRule
setStatus(RuleStatus status)
Default value isRuleStatus.READY
.RulesDefinition.NewRule
setTags(java.lang.String... list)
RulesDefinition.NewRule
setTemplate(boolean template)
RulesDefinition.NewRule
setType(RuleType t)
The type as defined by the SonarQube Quality Model.java.lang.String
toString()
-
-
-
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.REMOVED
is 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.deprecatedRuleKeys
for details).Deprecated keys should be added with this method in order, oldest first, for documentation purpose.
- Throws:
java.lang.IllegalArgumentException
- ifrepository
orkey
isnull
or empty.- Since:
- 7.1
- See Also:
RulesDefinition.Rule.deprecatedRuleKeys
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-