}
public static List<Class> getChecks() {
- return ImmutableList.<Class>builder().addAll(getJavaChecks())
+ return ImmutableList.<Class>builder()
+ .addAll(getJavaChecks())
+ .addAll(getJavaTestChecks())
+ .addAll(getXmlChecks())
.build();
}
- public static List<Class<? extends JavaCheck>> getJavaChecks() {
- return ImmutableList.<Class<? extends JavaCheck>>builder()
- .add(HelloWorldCheck.class)
- .build();
- }
+ public static List<Class<? extends JavaCheck>> getJavaChecks() {
+ return ImmutableList.<Class<? extends JavaCheck>>builder()
+ .add(HelloWorldCheck.class)
+ .build();
+ }
+
+ public static List<Class<? extends JavaCheck>> getJavaTestChecks() {
+ return ImmutableList.<Class<? extends JavaCheck>>builder()
+ .build();
+ }
+ public static List<Class<? extends JavaCheck>> getXmlChecks() {
+ return ImmutableList.<Class<? extends JavaCheck>>builder()
+ .build();
+ }
+
+ private static List<Class<? extends JavaCheck>> getMavenChecks() {
+ return ImmutableList.<Class<? extends JavaCheck>>builder()
+ .build();
+ }
}
import java.util.List;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
import org.sonar.check.Rule;
import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;
import org.sonar.plugins.java.api.semantic.Symbol.MethodSymbol;
@Rule(key = "HELLOWORLD0001")
public class HelloWorldCheck extends IssuableSubscriptionVisitor {
+ private static final Logger LOG = Loggers.get(HelloWorldCheck.class);
+
@Override
public List<Kind> nodesToVisit() {
@Override
public void visitNode(Tree tree) {
+ LOG.info("Visiting Node");
+
MethodTree method = (MethodTree) tree;
if (method.parameters().size() == 1) {
ImmutableList.Builder<Object> builder = ImmutableList.builder();
builder.add(
- HelloWorldRulesDefinition.class);
+ HelloWorldRulesDefinition.class,
+ HelloWorldRulesCheckRegistrar.class);
+
context.addExtensions(builder.build());
-
}
}
--- /dev/null
+package de.example.plugins.helloworld;
+
+import org.sonar.plugins.java.api.CheckRegistrar;
+
+import de.example.helloworld.checks.CheckList;
+
+public class HelloWorldRulesCheckRegistrar implements CheckRegistrar {
+
+ @Override
+ public void register(RegistrarContext registrarContext) {
+ registrarContext.registerClassesForRepository(CheckList.REPOSITORY_KEY, CheckList.getJavaChecks(), CheckList.getJavaTestChecks());
+ }
+
+}
--- /dev/null
+package de.example.plugins.helloworld;
+
+import org.sonar.api.batch.sensor.Sensor;
+import org.sonar.api.batch.sensor.SensorContext;
+import org.sonar.api.batch.sensor.SensorDescriptor;
+import org.sonar.plugins.java.Java;
+
+public class HelloWorldSensor implements Sensor {
+
+ @Override
+ public void describe(SensorDescriptor descriptor) {
+ descriptor.onlyOnLanguage(Java.KEY);
+ descriptor.name("HelloWorld Sensor");
+ }
+
+ @Override
+ public void execute(SensorContext context) {
+
+ }
+
+}