Class CheckRegistrar.RegistrarContext

java.lang.Object
org.sonar.plugins.java.api.CheckRegistrar.RegistrarContext
Direct Known Subclasses:
SonarComponents
Enclosing interface:
CheckRegistrar

public static class CheckRegistrar.RegistrarContext extends Object
Context for checks registration.
  • Constructor Details

    • RegistrarContext

      public RegistrarContext()
  • Method Details

    • registerClassesForRepository

      public void registerClassesForRepository(String repositoryKey, Iterable<Class<? extends JavaCheck>> checkClasses, Iterable<Class<? extends JavaCheck>> testCheckClasses)
      Registers java checks for a given repository.
      Parameters:
      repositoryKey - key of rule repository
      checkClasses - classes of checks for main sources
      testCheckClasses - classes of checks for test sources
    • repositoryKey

      @Deprecated(since="7.25", forRemoval=true) public String repositoryKey()
      Deprecated, for removal: This API element is subject to removal in a future version.
      RegistrarContext should just forward the registration and not have any getters
      getter for repository key.
      Returns:
      the repository key.
    • checkClasses

      @Deprecated(since="7.25", forRemoval=true) public Iterable<Class<? extends JavaCheck>> checkClasses()
      Deprecated, for removal: This API element is subject to removal in a future version.
      RegistrarContext should just forward the registration and not have any getters
      get main source check classes
      Returns:
      iterable of main checks classes
    • testCheckClasses

      @Deprecated(since="7.25", forRemoval=true) public Iterable<Class<? extends JavaCheck>> testCheckClasses()
      Deprecated, for removal: This API element is subject to removal in a future version.
      RegistrarContext should just forward the registration and not have any getters
      get test source check classes
      Returns:
      iterable of test checks classes
    • registerMainChecks

      public void registerMainChecks(String repositoryKey, Collection<?> javaCheckClassesAndInstances)
      Registers main code java checks for a given repository.
      Parameters:
      repositoryKey - key of rule repository
      javaCheckClassesAndInstances - a collection of Classinvalid input: '<'? extends JavaCheck> and JavaCheck> instances
    • registerMainChecks

      @Beta public void registerMainChecks(org.sonar.api.batch.rule.Checks<JavaCheck> checks, Collection<?> javaCheckClassesAndInstances)
      Register main code java checks which have already been initialized by a CheckFactory.
    • registerTestChecks

      @Beta public void registerTestChecks(org.sonar.api.batch.rule.Checks<JavaCheck> checks, Collection<?> javaCheckClassesAndInstances)
      Register test code java checks which have already been initialized by a CheckFactory.
    • registerTestChecks

      public void registerTestChecks(String repositoryKey, Collection<?> javaCheckClassesAndInstances)
      Registers test code java checks for a given repository.
      Parameters:
      repositoryKey - key of rule repository
      javaCheckClassesAndInstances - a collection of Classinvalid input: '<'? extends JavaCheck> and JavaCheck> instances
    • registerMainSharedCheck

      public void registerMainSharedCheck(JavaCheck check, Collection<org.sonar.api.rule.RuleKey> ruleKeys)
      Registers one main code check related to not one but a list of rules. The check will be active if at least one of the given rule key is active. In this context injection of @RuleProperty and auto instantiation of rules defined as template in RulesDefinition will not work. And the reportIssue mechanism will not be able to find the RuleKey automatically.
    • registerCustomFileScanner

      public void registerCustomFileScanner(org.sonar.api.rule.RuleScope ruleScope, JavaFileScanner scanner)
      Registers a custom file scanner not related to any rule or repository. CheckRegistrars call this function to register a custom file scanner for execution during the analysis on all source files that match the given rule scope (MAIN, TEST or ALL). Custom file scanners reporting an issue will have no effect, since no rule is associated.
    • registerTestSharedCheck

      public void registerTestSharedCheck(JavaCheck check, Collection<org.sonar.api.rule.RuleKey> ruleKeys)
      Registers one test code check related to not one but a list of rules. The check will be active if at least one of the given rule key is active. In this context injection of @RuleProperty and auto instantiation of rules defined as template in RulesDefinition will not work.
    • registerAutoScanCompatibleRules

      public void registerAutoScanCompatibleRules(Collection<org.sonar.api.rule.RuleKey> ruleKeys)
      Cannot be used outside of Sonar Products. Registers rules compatible with the autoscan context. Note: It's possible to convert checkClass to RuleKey using:
        RuleKey.of(repositoryKey, RuleAnnotationUtils.getRuleKey(checkClass))