org.sonar.api.batch.rule
Class Checks<C>
java.lang.Object
org.sonar.api.batch.rule.Checks<C>
public class Checks<C>
- extends 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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
of
@CheckForNull
public C of(RuleKey ruleKey)
all
public Collection<C> all()
ruleKey
@CheckForNull
public RuleKey ruleKey(C check)
addAnnotatedChecks
public Checks<C> addAnnotatedChecks(Object... checkClassesOrObjects)
addAnnotatedChecks
public Checks<C> addAnnotatedChecks(Collection checkClassesOrObjects)
Copyright © 2009–2015 SonarSource. All rights reserved.