forked from phoedos/pmd
Revert "Update changelog, keep backwards compatible createRuleSets methods by overloading"
This reverts commit b753cc5ec5d2240e907b60f78925f78c2f682bf5.
This commit is contained in:
@ -271,22 +271,22 @@ public class PMDConfiguration extends AbstractConfiguration {
|
||||
/**
|
||||
* Get the RuleSets.
|
||||
*
|
||||
* @return the pmdRuleSets
|
||||
*/
|
||||
public RuleSets getPmdRuleSets() {
|
||||
return pmdRuleSets;
|
||||
}
|
||||
* @return the pmdRuleSets
|
||||
*/
|
||||
public RuleSets getPmdRuleSets() {
|
||||
return pmdRuleSets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the RuleSets
|
||||
*
|
||||
* @param pmdRuleSets the pmdRuleSets to set
|
||||
*/
|
||||
public void setPmdRuleSets(RuleSets pmdRuleSets) {
|
||||
this.pmdRuleSets = pmdRuleSets;
|
||||
}
|
||||
/**
|
||||
* Set the RuleSets
|
||||
*
|
||||
* @param pmdRuleSets the pmdRuleSets to set
|
||||
*/
|
||||
public void setPmdRuleSets(RuleSets pmdRuleSets) {
|
||||
this.pmdRuleSets = pmdRuleSets;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the minimum priority threshold when loading Rules from RuleSets.
|
||||
*
|
||||
* @return The minimum priority threshold.
|
||||
|
@ -104,21 +104,6 @@ public class RuleSetFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a RuleSets from a comma separated list of RuleSet reference IDs
|
||||
* when the parameter ruleSets is null. This is a convenience method which
|
||||
* calls {@link RuleSetReferenceId#parse(String)}, and then calls
|
||||
* {@link #createRuleSets(List)}. The currently configured ClassLoader is
|
||||
* used.
|
||||
*
|
||||
* @param referenceString A comma separated list of RuleSet reference IDs.
|
||||
* @return The new RuleSets.
|
||||
* @throws RuleSetNotFoundException if unable to find a resource.
|
||||
*/
|
||||
public synchronized RuleSets createRuleSets(String referenceString) throws RuleSetNotFoundException {
|
||||
return createRuleSets(referenceString, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a RuleSets from a comma separated list of RuleSet reference IDs when the parameter ruleSets is null.
|
||||
* This is a convenience method which calls
|
||||
@ -128,13 +113,12 @@ public class RuleSetFactory {
|
||||
*
|
||||
* @param referenceString A comma separated list of RuleSet reference IDs.
|
||||
* @param ruleSets RuleSets initialized in PMDConfiguration.
|
||||
* @return The new RuleSets or the rulesets from PMDConfiguration if not null
|
||||
* @return The new RuleSets.
|
||||
* @throws RuleSetNotFoundException if unable to find a resource.
|
||||
*/
|
||||
public synchronized RuleSets createRuleSets(String referenceString, RuleSets ruleSets) throws RuleSetNotFoundException {
|
||||
if (ruleSets != null) {
|
||||
return ruleSets;
|
||||
}
|
||||
if(ruleSets != null)
|
||||
return ruleSets;
|
||||
return createRuleSets(RuleSetReferenceId.parse(referenceString));
|
||||
}
|
||||
|
||||
|
@ -15,19 +15,6 @@ public final class RulesetsFactoryUtils {
|
||||
|
||||
private RulesetsFactoryUtils() {}
|
||||
|
||||
/**
|
||||
* Creates a new rulesets with the given string. The resulting rulesets will contain
|
||||
* all referenced rulesets.
|
||||
* @param rulesets the string with the rulesets to load
|
||||
* @param factory the ruleset factory
|
||||
* @return the rulesets
|
||||
* @throws IllegalArgumentException if rulesets is empty (means, no rules have been found) or if a
|
||||
* ruleset couldn't be found.
|
||||
*/
|
||||
public static RuleSets getRuleSets(String rulesets, RuleSetFactory factory) {
|
||||
return getRuleSets(rulesets, null, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new rulesets with the given string. The resulting rulesets will contain
|
||||
* all referenced rulesets.
|
||||
@ -66,30 +53,15 @@ public final class RulesetsFactoryUtils {
|
||||
* @throws IllegalArgumentException if rulesets is empty (means, no rules have been found) or if a
|
||||
* ruleset couldn't be found.
|
||||
*/
|
||||
public static RuleSets getRuleSetsWithBenchmark(String rulesets, RuleSetFactory factory) {
|
||||
return getRuleSetsWithBenchmark(rulesets, null, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #getRuleSets(String, RuleSetFactory)}. In addition, the loading of the rules
|
||||
* is benchmarked.
|
||||
* @param rulesets the string with the rulesets to load
|
||||
* @param pmdRuleSets RuleSets initialized in PMDConfiguration
|
||||
* @param factory the ruleset factory
|
||||
* @return the rulesets
|
||||
* @throws IllegalArgumentException if rulesets is empty (means, no rules have been found) or if a
|
||||
* ruleset couldn't be found.
|
||||
*/
|
||||
public static RuleSets getRuleSetsWithBenchmark(String rulesets, RuleSets pmdRuleSets, RuleSetFactory factory) {
|
||||
long loadRuleStart = System.nanoTime();
|
||||
RuleSets ruleSets = null;
|
||||
try {
|
||||
ruleSets = getRuleSets(rulesets, pmdRuleSets, factory);
|
||||
pmdRuleSets = getRuleSets(rulesets, pmdRuleSets, factory);
|
||||
} finally {
|
||||
long endLoadRules = System.nanoTime();
|
||||
Benchmarker.mark(Benchmark.LoadRules, endLoadRules - loadRuleStart, 0);
|
||||
}
|
||||
return ruleSets;
|
||||
return pmdRuleSets;
|
||||
}
|
||||
|
||||
public static RuleSetFactory getRulesetFactory(PMDConfiguration configuration) {
|
||||
|
@ -57,7 +57,7 @@ public class RuleSetFactoryTest {
|
||||
Assert.assertNotNull("Test ruleset not found - can't continue with test!", in);
|
||||
|
||||
RuleSetFactory rsf = new RuleSetFactory();
|
||||
RuleSets rs = rsf.createRuleSets("net/sourceforge/pmd/rulesets/reference-ruleset.xml");
|
||||
RuleSets rs = rsf.createRuleSets("net/sourceforge/pmd/rulesets/reference-ruleset.xml", null);
|
||||
// added by referencing a complete ruleset (TestRuleset1.xml)
|
||||
assertNotNull(rs.getRuleByName("MockRule1"));
|
||||
assertNotNull(rs.getRuleByName("MockRule2"));
|
||||
|
@ -50,7 +50,7 @@ public abstract class RuleTst {
|
||||
*/
|
||||
public Rule findRule(String ruleSet, String ruleName) {
|
||||
try {
|
||||
Rule rule = new RuleSetFactory().createRuleSets(ruleSet).getRuleByName(ruleName);
|
||||
Rule rule = new RuleSetFactory().createRuleSets(ruleSet, null).getRuleByName(ruleName);
|
||||
if (rule == null) {
|
||||
fail("Rule " + ruleName + " not found in ruleset " + ruleSet);
|
||||
}
|
||||
|
Reference in New Issue
Block a user