From 8bb8985ca2ece95b6983be9ace50d6470f65dee9 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Wed, 17 Aug 2016 18:42:26 +0200 Subject: [PATCH] sonar custom java plugin: removing non required dependency --- Sonar/Plugins/sonar-custom-java-plugin/pom.xml | 24 +--------------------- .../plugins/custom/java/CustomRulesDefinition.java | 9 +++----- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/Sonar/Plugins/sonar-custom-java-plugin/pom.xml b/Sonar/Plugins/sonar-custom-java-plugin/pom.xml index 3f10d86..2514114 100644 --- a/Sonar/Plugins/sonar-custom-java-plugin/pom.xml +++ b/Sonar/Plugins/sonar-custom-java-plugin/pom.xml @@ -52,29 +52,7 @@ commons-lang 2.6 - - org.sonarsource.sslr-squid-bridge - sslr-squid-bridge - 2.6.1 - - - org.codehaus.sonar.sslr - sslr-core - - - org.codehaus.sonar - sonar-plugin-api - - - org.codehaus.sonar.sslr - sslr-xpath - - - org.slf4j - jcl-over-slf4j - - - + org.sonarsource.java java-frontend diff --git a/Sonar/Plugins/sonar-custom-java-plugin/src/main/java/de/example/plugins/custom/java/CustomRulesDefinition.java b/Sonar/Plugins/sonar-custom-java-plugin/src/main/java/de/example/plugins/custom/java/CustomRulesDefinition.java index 3b783d0..dd1fbd3 100644 --- a/Sonar/Plugins/sonar-custom-java-plugin/src/main/java/de/example/plugins/custom/java/CustomRulesDefinition.java +++ b/Sonar/Plugins/sonar-custom-java-plugin/src/main/java/de/example/plugins/custom/java/CustomRulesDefinition.java @@ -12,10 +12,8 @@ import org.sonar.api.server.debt.DebtRemediationFunction; import org.sonar.api.server.rule.RulesDefinition; import org.sonar.api.server.rule.RulesDefinitionAnnotationLoader; import org.sonar.api.utils.AnnotationUtils; -import org.sonar.check.Cardinality; import org.sonar.plugins.java.Java; import org.sonar.squidbridge.annotations.RuleTemplate; -import org.sonar.squidbridge.rules.ExternalDescriptionLoader; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Charsets; @@ -61,10 +59,9 @@ public class CustomRulesDefinition implements RulesDefinition { if (rule == null) { throw new IllegalStateException("No rule was created for " + ruleClass + " in " + repository.key()); } + + // Check whether it is a Rule Template. rule.setTemplate(AnnotationUtils.getAnnotation(ruleClass, RuleTemplate.class) != null); - if (ruleAnnotation.cardinality() == Cardinality.MULTIPLE) { - throw new IllegalArgumentException("Cardinality is not supported, use the RuleTemplate annotation instead for " + ruleClass); - } ruleMetadata(ruleClass, rule); } @@ -81,7 +78,7 @@ public class CustomRulesDefinition implements RulesDefinition { } private void addMetadata(NewRule rule, String metadataKey) { - URL resource = ExternalDescriptionLoader.class.getResource(RESOURCE_BASE_PATH + "/" + metadataKey + "_java.json"); + URL resource = CustomRulesDefinition.class.getResource(RESOURCE_BASE_PATH + "/" + metadataKey + "_java.json"); if (resource != null) { RuleMetatada metatada = gson.fromJson(readResource(resource), RuleMetatada.class); rule.setSeverity(metatada.defaultSeverity.toUpperCase()); -- 2.1.4