Class CheckRegistrar.RegistrarContext
java.lang.Object
org.sonar.plugins.java.api.CheckRegistrar.RegistrarContext
- Direct Known Subclasses:
SonarComponents
- Enclosing interface:
CheckRegistrar
Context for checks registration.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDeprecated, for removal: This API element is subject to removal in a future version.RegistrarContext should just forward the registration and not have any gettersvoidregisterAutoScanCompatibleRules(Collection<org.sonar.api.rule.RuleKey> ruleKeys) Cannot be used outside of Sonar Products.voidregisterClassesForRepository(String repositoryKey, Iterable<Class<? extends JavaCheck>> checkClasses, Iterable<Class<? extends JavaCheck>> testCheckClasses) Registers java checks for a given repository.voidregisterCustomFileScanner(org.sonar.api.rule.RuleScope ruleScope, JavaFileScanner scanner) Registers a custom file scanner not related to any rule or repository.voidregisterMainChecks(String repositoryKey, Collection<?> javaCheckClassesAndInstances) Registers main code java checks for a given repository.voidregisterMainChecks(org.sonar.api.batch.rule.Checks<JavaCheck> checks, Collection<?> javaCheckClassesAndInstances) Register main code java checks which have already been initialized by a CheckFactory.voidregisterMainSharedCheck(JavaCheck check, Collection<org.sonar.api.rule.RuleKey> ruleKeys) Registers one main code check related to not one but a list of rules.voidregisterTestChecks(String repositoryKey, Collection<?> javaCheckClassesAndInstances) Registers test code java checks for a given repository.voidregisterTestChecks(org.sonar.api.batch.rule.Checks<JavaCheck> checks, Collection<?> javaCheckClassesAndInstances) Register test code java checks which have already been initialized by a CheckFactory.voidregisterTestSharedCheck(JavaCheck check, Collection<org.sonar.api.rule.RuleKey> ruleKeys) Registers one test code check related to not one but a list of rules.Deprecated, for removal: This API element is subject to removal in a future version.RegistrarContext should just forward the registration and not have any gettersDeprecated, for removal: This API element is subject to removal in a future version.RegistrarContext should just forward the registration and not have any getters
-
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 repositorycheckClasses- classes of checks for main sourcestestCheckClasses- classes of checks for test sources
-
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 gettersgetter 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 gettersget 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 gettersget test source check classes- Returns:
- iterable of test checks classes
-
registerMainChecks
Registers main code java checks for a given repository.- Parameters:
repositoryKey- key of rule repositoryjavaCheckClassesAndInstances- a collection ofClassinvalid input: '<'? extends JavaCheck>andJavaCheck>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
Registers test code java checks for a given repository.- Parameters:
repositoryKey- key of rule repositoryjavaCheckClassesAndInstances- a collection ofClassinvalid input: '<'? extends JavaCheck>andJavaCheck>instances
-
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. -
registerAutoScanCompatibleRules
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))
-