Interface CheckRegistrar


@Beta @SonarLintSide @ScannerSide public interface CheckRegistrar
This batch extension should be extended to provide the classes to be used to instantiate checks. The register method has to be implemented and the registrarContext should register the repository keys.
   
   public void register(RegistrarContext registrarContext) {
     registrarContext.registerClassesForRepository("RepositoryKey", listOfCheckClasses);
   }
   
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Context for checks registration.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    customRulesDefinition(org.sonar.api.server.rule.RulesDefinition.Context context, org.sonar.api.server.rule.RulesDefinition.NewRepository javaRepository)
    This method is called during the definition of the SonarJava rules, implementing it allows to register rules in the same rule repository as SonarJava while its being defined.
    void
    This method is called during an analysis to get the classes to use to instantiate checks.
    default void
    register(CheckRegistrar.RegistrarContext registrarContext, org.sonar.api.batch.rule.CheckFactory checkFactory)
    This method is called during an analysis to register instantiated checks using the CheckFactory
  • Method Details

    • register

      void register(CheckRegistrar.RegistrarContext registrarContext)
      This method is called during an analysis to get the classes to use to instantiate checks.
      Parameters:
      registrarContext - the context that will be used by the java-plugin to retrieve the classes for checks.
    • customRulesDefinition

      default void customRulesDefinition(org.sonar.api.server.rule.RulesDefinition.Context context, org.sonar.api.server.rule.RulesDefinition.NewRepository javaRepository)
      This method is called during the definition of the SonarJava rules, implementing it allows to register rules in the same rule repository as SonarJava while its being defined.
      Parameters:
      context - the context that will be used by the java-plugin to define the rules in its repository.
      javaRepository - the repository currently being defined
    • register

      default void register(CheckRegistrar.RegistrarContext registrarContext, org.sonar.api.batch.rule.CheckFactory checkFactory)
      This method is called during an analysis to register instantiated checks using the CheckFactory
      Parameters:
      registrarContext - the context that will be used by the java-plugin to retrieve the classes for checks.
      checkFactory - the factory to be used to instantiate checks