Class RulesDefinition.NewRule

  • Enclosing interface:
    RulesDefinition

    public abstract static class RulesDefinition.NewRule
    extends java.lang.Object
    • Constructor Detail

      • NewRule

        public NewRule()
    • Method Detail

      • key

        public abstract java.lang.String key()
      • scope

        @CheckForNull
        public abstract RuleScope scope()
        Since:
        7.1
      • setActivatedByDefault

        public abstract RulesDefinition.NewRule setActivatedByDefault​(boolean activatedByDefault)
        Should this rule be enabled by default. For example in SonarLint standalone.
        Since:
        6.0
      • setType

        public abstract 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: Finally the "bug" and "security" tags are considered as reserved. They are silently removed from the final state of definition.
        Since:
        5.5
      • addDescriptionSection

        public abstract RulesDefinition.NewRule addDescriptionSection​(RuleDescriptionSection ruleDescriptionSection)
        Add a rule description section. The sections must be added in the right order. For backward compatibility, one of the old method setHtmlDescription(String) or setHtmlDescription(URL) still need to be called on top of that one. Each section must have a different section key when they are non-contextual. As soon as one section is contextual for a section key, all sections with that key must be contextual. The pair "section key, context key" pair must still be unique. If several sections provide contexts, the provided context keys must be the same between sections.
        Since:
        9.5
      • setHtmlDescription

        public abstract RulesDefinition.NewRule setHtmlDescription​(@Nullable
                                                                   java.net.URL classpathUrl)
        Load description from a file available in classpath. Example : setHtmlDescription(getClass().getResource("/myrepo/Rule1234.html")
      • setMarkdownDescription

        @Deprecated(since="9.6",
                    forRemoval=true)
        public abstract RulesDefinition.NewRule setMarkdownDescription​(@Nullable
                                                                       java.net.URL classpathUrl)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Load description from a file available in classpath. Example : setMarkdownDescription(getClass().getResource("/myrepo/Rule1234.md")
      • setGapDescription

        public abstract 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 abstract RulesDefinition.NewParam createParam​(java.lang.String paramKey)
        Create a parameter with given unique key. Max length of key is 128 characters.
      • addOwaspTop10

        @Deprecated
        public abstract RulesDefinition.NewRule addOwaspTop10​(RulesDefinition.OwaspTop10... standards)
        Deprecated.
        since 9.3 Supports only OWASP Top 10 2017 standard, use addOwaspTop10(OwaspTop10Version, OwaspTop10...) for 2017,2021...
        Since:
        7.3
      • setInternalKey

        public abstract 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").
      • addEducationPrincipleKeys

        public abstract RulesDefinition.NewRule addEducationPrincipleKeys​(java.lang.String... list)
        Since:
        9.8 Register a list of education principle keys to attach to the given rule. Education principles must follow the format defined in EducationPrincipleKeyFormat Examples of education principle keys: "defense_in_depth", "least_trust_principle"