diff --git a/pmd/regress/test/net/sourceforge/pmd/RuleSetFactoryTest.java b/pmd/regress/test/net/sourceforge/pmd/RuleSetFactoryTest.java index 01addab111..204771ab35 100644 --- a/pmd/regress/test/net/sourceforge/pmd/RuleSetFactoryTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/RuleSetFactoryTest.java @@ -140,16 +140,27 @@ public class RuleSetFactoryTest extends TestCase { assertEquals("TestMessageOverride", r.getMessage()); } + public void testOverrideMessageOneElem() { + Rule r = loadFirstRule(REF_OVERRIDE_ORIGINAL_NAME_ONE_ELEM); + assertEquals("TestMessageOverride", r.getMessage()); + } + private static final String REF_OVERRIDE_ORIGINAL_NAME = "" + PMD.EOL + "" + PMD.EOL + " testdesc" + PMD.EOL + " " + PMD.EOL + + " ref=\"rulesets/unusedcode.xml/UnusedLocalVariable\" message=\"TestMessageOverride\"> " + PMD.EOL + " " + PMD.EOL + ""; + private static final String REF_OVERRIDE_ORIGINAL_NAME_ONE_ELEM = + "" + PMD.EOL + + "" + PMD.EOL + + " testdesc" + PMD.EOL + + " " + PMD.EOL + + ""; + private static final String REF_OVERRIDE = "" + PMD.EOL + "" + PMD.EOL + diff --git a/pmd/src/net/sourceforge/pmd/RuleSetFactory.java b/pmd/src/net/sourceforge/pmd/RuleSetFactory.java index 2ce9664535..812e6b045a 100644 --- a/pmd/src/net/sourceforge/pmd/RuleSetFactory.java +++ b/pmd/src/net/sourceforge/pmd/RuleSetFactory.java @@ -260,10 +260,8 @@ public class RuleSetFactory { RuleSet externalRuleSet = rsf.createRuleSet(ResourceLoader.loadResourceAsStream(externalRuleID.getFilename())); Rule externalRule = externalRuleSet.getRuleByName(externalRuleID.getRuleName()); - if (ruleNode.getFirstChild() != null) { - OverrideParser p = new OverrideParser((Element)ruleNode); - p.overrideAsNecessary(externalRule); - } + OverrideParser p = new OverrideParser((Element)ruleNode); + p.overrideAsNecessary(externalRule); ruleSet.addRule(externalRule); } diff --git a/pmd/xdocs/credits.xml b/pmd/xdocs/credits.xml index 41a781c892..3f307b0127 100644 --- a/pmd/xdocs/credits.xml +++ b/pmd/xdocs/credits.xml @@ -43,11 +43,11 @@