Package org.sonar.api.batch.rule
Class Checks<C>
- java.lang.Object
-
- org.sonar.api.batch.rule.Checks<C>
-
public class Checks<C> extends java.lang.Object
Instantiates checks (objects that provide implementation of coding rules) that use sonar-check-api annotations. Checks are selected and configured from the Quality profiles enabled on the current module.
Example of check class:@org.sonar.check.Rule(key = "S001") public class CheckS001 { @org.sonar.check.RuleProperty private String pattern; public String getPattern() { return pattern; } }
How to use:public class MyRuleEngine extends BatchExtension { private final CheckFactory checkFactory; public MyRuleEngine(CheckFactory checkFactory) { this.checkFactory = checkFactory; } public void execute() { Checks checks = checkFactory.create("my-rule-repository"); checks.addAnnotatedChecks(CheckS001.class); // checks.all() contains an instance of CheckS001 // with field "pattern" set to the value specified in // the Quality profile // Checks are used to detect issues on source code // checks.ruleKey(obj) can be used to create the related issues } }
It replaces org.sonar.api.checks.AnnotationCheckFactory- Since:
- 4.2
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Checks<C>
addAnnotatedChecks(java.lang.Iterable checkClassesOrObjects)
Checks<C>
addAnnotatedChecks(java.lang.Object... checkClassesOrObjects)
Checks<C>
addAnnotatedChecks(java.util.Collection checkClassesOrObjects)
Deprecated.since 5.2 useaddAnnotatedChecks(Iterable)
java.util.Collection<C>
all()
C
of(RuleKey ruleKey)
RuleKey
ruleKey(C check)
-
-
-
Method Detail
-
all
public java.util.Collection<C> all()
-
addAnnotatedChecks
@Deprecated public Checks<C> addAnnotatedChecks(java.util.Collection checkClassesOrObjects)
Deprecated.since 5.2 useaddAnnotatedChecks(Iterable)
-
-