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