From: Gustavo Martin Morcuende Date: Wed, 17 Aug 2016 16:42:26 +0000 (+0200) Subject: sonar custom java plugin: removing non required dependency X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=8bb8985ca2ece95b6983be9ace50d6470f65dee9;p=JavaForFun sonar custom java plugin: removing non required dependency --- 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());