From bb3122752e3bd98caf4dd7371dc9699a2a3a251f Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Mon, 3 Feb 2003 16:34:33 +0000 Subject: [PATCH] Updated to make custom ruleset error messages clearer git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1393 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/src/net/sourceforge/pmd/ExternalRuleID.java | 3 +++ pmd/src/net/sourceforge/pmd/RuleSetFactory.java | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/pmd/src/net/sourceforge/pmd/ExternalRuleID.java b/pmd/src/net/sourceforge/pmd/ExternalRuleID.java index a46919a8c8..74cb409660 100644 --- a/pmd/src/net/sourceforge/pmd/ExternalRuleID.java +++ b/pmd/src/net/sourceforge/pmd/ExternalRuleID.java @@ -12,6 +12,9 @@ public class ExternalRuleID { public ExternalRuleID(String id) { int afterXML = id.indexOf(".xml") + 5; + if (afterXML >= id.length()) { + throw new RuntimeException("Unable to parse reference to external rule " + id +". These references need to be in the form /, i.e., "); + } filename = id.substring(0, afterXML-1); ruleName = id.substring(afterXML); } diff --git a/pmd/src/net/sourceforge/pmd/RuleSetFactory.java b/pmd/src/net/sourceforge/pmd/RuleSetFactory.java index 6dc24c2b70..611a3476cf 100644 --- a/pmd/src/net/sourceforge/pmd/RuleSetFactory.java +++ b/pmd/src/net/sourceforge/pmd/RuleSetFactory.java @@ -40,6 +40,10 @@ public class RuleSetFactory { } } + /** + * Creates a ruleset. If passed a comma-delimited string (rulesets/basic.xml,rulesets/unusedcode.xml) + * it will parse that string and create a new ruleset for each item in the list. + */ public RuleSet createRuleSet(String name) throws RuleSetNotFoundException { if (name.indexOf(',') == -1) { return createRuleSet(tryToGetStreamTo(name));