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
This commit is contained in:
Tom Copeland
2005-06-23 03:17:34 +00:00
parent 95b63ac8e7
commit 31c8f775b2
3 changed files with 16 additions and 7 deletions

View File

@ -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 =
"<?xml version=\"1.0\"?>" + PMD.EOL +
"<ruleset name=\"test\">" + PMD.EOL +
" <description>testdesc</description>" + PMD.EOL +
" <rule " + PMD.EOL +
" ref=\"rulesets/unusedcode.xml/UnusedLocalVariable\" " + PMD.EOL +
" message=\"TestMessageOverride\"> " + PMD.EOL +
" ref=\"rulesets/unusedcode.xml/UnusedLocalVariable\" message=\"TestMessageOverride\"> " + PMD.EOL +
" </rule>" + PMD.EOL +
"</ruleset>";
private static final String REF_OVERRIDE_ORIGINAL_NAME_ONE_ELEM =
"<?xml version=\"1.0\"?>" + PMD.EOL +
"<ruleset name=\"test\">" + PMD.EOL +
" <description>testdesc</description>" + PMD.EOL +
" <rule ref=\"rulesets/unusedcode.xml/UnusedLocalVariable\" message=\"TestMessageOverride\"/> " + PMD.EOL +
"</ruleset>";
private static final String REF_OVERRIDE =
"<?xml version=\"1.0\"?>" + PMD.EOL +
"<ruleset name=\"test\">" + PMD.EOL +

View File

@ -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);
}

View File

@ -43,11 +43,11 @@
</subsection>
<subsection name="Contributors">
<ul>
<li>Wouter Zelle - Fixed a devious bug in RuleSetFactory, AvoidPrintStackTrace, initial implementation of SimplifyConditional</li>
<li>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</li>
<li>Dennis Klemann - reported fix for pmd.bat problem</li>
<li>Jeff Chamblee - bug report for CompareObjectsWithEquals</li>
<li>Tor Norbye - Suggested CompareObjectsWithEquals</li>
<li>Wouter Zelle - AvoidPrintStackTrace, initial implementation of SimplifyConditional</li>
<li>Thomas Skariah - bug reports for MethodArgumentCouldBeFinal and AvoidReassigningParameters</li>
<li>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</li>
<li>Bruno Juillet - bug report for missing package/class/method names, patch for Ant task's excludeMarker attribute, bug report on ruleset overrides</li>