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
This commit is contained in:
@ -12,6 +12,9 @@ public class ExternalRuleID {
|
|||||||
|
|
||||||
public ExternalRuleID(String id) {
|
public ExternalRuleID(String id) {
|
||||||
int afterXML = id.indexOf(".xml") + 5;
|
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 <rulesetname>/<rulename>, i.e., <rule ref=\"rulesets/unusedcode.xml/UnusedPrivateField\"/>");
|
||||||
|
}
|
||||||
filename = id.substring(0, afterXML-1);
|
filename = id.substring(0, afterXML-1);
|
||||||
ruleName = id.substring(afterXML);
|
ruleName = id.substring(afterXML);
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
public RuleSet createRuleSet(String name) throws RuleSetNotFoundException {
|
||||||
if (name.indexOf(',') == -1) {
|
if (name.indexOf(',') == -1) {
|
||||||
return createRuleSet(tryToGetStreamTo(name));
|
return createRuleSet(tryToGetStreamTo(name));
|
||||||
|
Reference in New Issue
Block a user