From 77048f16ea84606a1ffec3f5d24fd49b88241b8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Tue, 21 Nov 2017 17:33:29 +0100 Subject: [PATCH] Fix another few things --- .../src/main/java/net/sourceforge/pmd/rules/RuleBuilder.java | 5 +++-- .../src/main/java/net/sourceforge/pmd/rules/RuleFactory.java | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleBuilder.java index 5794341df3..1b61e4aedb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleBuilder.java @@ -25,7 +25,7 @@ import net.sourceforge.pmd.properties.PropertyDescriptor; * @author Clément Fournier * @since 6.0.0 */ -class RuleBuilder { +/* default */ class RuleBuilder { private List> definedProperties = new ArrayList<>(); private String name; @@ -70,8 +70,9 @@ class RuleBuilder { private void language(String languageName) { if (StringUtils.isBlank(languageName)) { + // Some languages don't need the attribute because the rule's + // constructor calls setLanguage, see e.g. AbstractJavaRule return; - // throw new IllegalArgumentException("Blank language attribute"); } Language lang = LanguageRegistry.findLanguageByTerseName(languageName); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleFactory.java index 5f35faee5d..46c23d3bd9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleFactory.java @@ -16,6 +16,7 @@ import java.util.Map.Entry; import java.util.logging.Logger; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -55,7 +56,7 @@ public class RuleFactory { private static final String PROPERTY = "property"; private static final String CLASS = "class"; - public static final List REQUIRED_ATTRIBUTES = Collections.unmodifiableList(Arrays.asList(NAME, CLASS)); + private static final List REQUIRED_ATTRIBUTES = Collections.unmodifiableList(Arrays.asList(NAME, CLASS)); /** @@ -196,6 +197,7 @@ public class RuleFactory { rule = builder.build(); } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { LOG.severe(e.getMessage()); + LOG.severe(ExceptionUtils.getStackTrace(e)); throw new RuntimeException(e); }