Class ExternalRuleLoader

java.lang.Object
org.sonarsource.analyzer.commons.ExternalRuleLoader

public class ExternalRuleLoader extends Object
Creates external rule repository based on json file in the format [ { "key": "...", "name": "..." }, ... ]

"key" and "name" are required properties. Also could be provided:

  • url (link to rule page)
  • description (html description of rule)
  • constantDebtMinutes (e.g. 30, by default 5)
  • tags (array of strings, e.g. "tags": [ "foo", "bar" ])
  • severity (as in SQ API, e.g. "MAJOR")
  • type (as in SQ API, e.g. "BUG")
  • Field Details

    • API_VERSION_SUPPORTING_CLEAN_CODE_IMPACTS_AND_ATTRIBUTES

      public static final org.sonar.api.utils.Version API_VERSION_SUPPORTING_CLEAN_CODE_IMPACTS_AND_ATTRIBUTES
  • Constructor Details

    • ExternalRuleLoader

      @Deprecated(since="2.6") public ExternalRuleLoader(String linterKey, String linterName, String pathToMetadata, String languageKey)
      Deprecated.
      Use the constructor that also provide the SonarRuntime argument to determine if you can use the new Clean Code attributes and impacts API. Then you should test "isCleanCodeImpactsAndAttributesSupported()" before using codeAttribute and codeImpacts.
    • ExternalRuleLoader

      public ExternalRuleLoader(String linterKey, String linterName, String pathToMetadata, String languageKey, @Nullable org.sonar.api.SonarRuntime sonarRuntime)
  • Method Details

    • isCleanCodeImpactsAndAttributesSupported

      public boolean isCleanCodeImpactsAndAttributesSupported()
    • createExternalRuleRepository

      public void createExternalRuleRepository(org.sonar.api.server.rule.RulesDefinition.Context context)
    • ruleKeys

      public Set<String> ruleKeys()
    • ruleType

      public org.sonar.api.rules.RuleType ruleType(String ruleKey)
    • ruleSeverity

      public org.sonar.api.batch.rule.Severity ruleSeverity(String ruleKey)
    • ruleConstantDebtMinutes

      public Long ruleConstantDebtMinutes(String ruleKey)