diff options
-rw-r--r-- | sonar-deprecated/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java (renamed from sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java) | 0 | ||||
-rw-r--r-- | sonar-deprecated/src/main/java/org/sonar/api/checks/CheckFactory.java (renamed from sonar-plugin-api/src/main/java/org/sonar/api/checks/CheckFactory.java) | 0 | ||||
-rw-r--r-- | sonar-deprecated/src/test/java/org/sonar/api/checks/AbstractCheck.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/checks/AbstractCheck.java) | 0 | ||||
-rw-r--r-- | sonar-deprecated/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java) | 0 | ||||
-rw-r--r-- | sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java) | 0 | ||||
-rw-r--r-- | sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithKey.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java) | 0 | ||||
-rw-r--r-- | sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java) | 0 | ||||
-rw-r--r-- | sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java) | 0 | ||||
-rw-r--r-- | sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java) | 0 | ||||
-rw-r--r-- | sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java) | 0 | ||||
-rw-r--r-- | sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java) | 0 | ||||
-rw-r--r-- | sonar-deprecated/src/test/java/org/sonar/api/checks/ImplementedCheck.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/checks/ImplementedCheck.java) | 0 | ||||
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/CheckFactory.java | 7 | ||||
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java | 41 |
14 files changed, 46 insertions, 2 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java index e706da53015..e706da53015 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/checks/CheckFactory.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/CheckFactory.java index a819b3c4918..a819b3c4918 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/checks/CheckFactory.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/checks/CheckFactory.java diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AbstractCheck.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/AbstractCheck.java index abf1347d55f..abf1347d55f 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AbstractCheck.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/checks/AbstractCheck.java diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java index a58cb83c499..a58cb83c499 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java index 60a4096940c..60a4096940c 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithKey.java index 3b048a6b651..3b048a6b651 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithKey.java diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java index 868027f7a46..868027f7a46 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java index 0d6a1d41c85..0d6a1d41c85 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java index 6f10f76dec2..6f10f76dec2 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java index 3401884e63d..3401884e63d 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java index aaa8f0b299d..aaa8f0b299d 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/ImplementedCheck.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/ImplementedCheck.java index 09c673570a2..09c673570a2 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/ImplementedCheck.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/checks/ImplementedCheck.java diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/CheckFactory.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/CheckFactory.java index 69e8df67191..d3aff4890c5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/CheckFactory.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/CheckFactory.java @@ -22,6 +22,9 @@ package org.sonar.api.batch.rule; import org.sonar.api.BatchComponent; /** + * Creates {@link org.sonar.api.batch.rule.Checks}. This class is available + * by dependency injection. It must not be extended by plugins. + * * @since 4.2 */ public class CheckFactory implements BatchComponent { @@ -32,7 +35,7 @@ public class CheckFactory implements BatchComponent { this.moduleRules = moduleRules; } - public Checks create(String repository) { - return new Checks(moduleRules, repository); + public <C> Checks<C> create(String repository) { + return new Checks<C>(moduleRules, repository); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java index a52d4d345e8..fa338989062 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java @@ -36,6 +36,47 @@ import java.util.List; import java.util.Map; /** + * 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. + * <p/> + * Example of check class: + * <pre> + * @Rule(key = "S001") + * public class CheckS001 { + * @RuleProperty + * private String pattern; + * + * public String getPattern() { + * return pattern; + * } + * } + * </pre> + * How to use: + * <pre> + * 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 detected + * // issues. + * } + * } + * </pre> + * <p/> + * It replaces org.sonar.api.checks.AnnotationCheckFactory * @since 4.2 */ public class Checks<C> { |