From 31c8f775b2d56e396227d0f78183f6c97be3ee9c Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Thu, 23 Jun 2005 03:17:34 +0000 Subject: [PATCH] Wouter Zelle located a devious little bug... thanks Wouter! git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@3613 51baf565-9d33-0410-a72c-fc3788e3496d --- .../net/sourceforge/pmd/RuleSetFactoryTest.java | 15 +++++++++++++-- pmd/src/net/sourceforge/pmd/RuleSetFactory.java | 6 ++---- pmd/xdocs/credits.xml | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) 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 @@
    +
  • Wouter Zelle - Fixed a devious bug in RuleSetFactory, AvoidPrintStackTrace, initial implementation of SimplifyConditional
  • Wim Deblauwe - noted problems with web site rule index, bug report for JUnitTestsShouldContainAsserts, Clover license coordination and implementation, UseCorrectExceptionLogging, coordinated and coded a much nicer asXML() implementation, suggested cleanup of UnusedFormalParameter, Javadoc patch, SystemPrintln bug report, helped get Ant task and CLI squared away with JDK 1.5 params, JDK 1.5-specific bug reports, suggested improvements for ExceptionSignatureDeclaration
  • Dennis Klemann - reported fix for pmd.bat problem
  • Jeff Chamblee - bug report for CompareObjectsWithEquals
  • Tor Norbye - Suggested CompareObjectsWithEquals
  • -
  • Wouter Zelle - AvoidPrintStackTrace, initial implementation of SimplifyConditional
  • Thomas Skariah - bug reports for MethodArgumentCouldBeFinal and AvoidReassigningParameters
  • Tom Parker - bug report for MethodReturnsInternalArray, found missed case in NullAssignment, suggested addition to UnnecessaryBooleanAssertion, suggested splitting up AvoidThrowingCertainExceptionTypes, AvoidInstantiatingObjectsInLoops bug report, AtLeastOneConstructor bug report
  • Bruno Juillet - bug report for missing package/class/method names, patch for Ant task's excludeMarker attribute, bug report on ruleset overrides