diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java index f0a63b4518..8c1113bb82 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java @@ -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. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java index a627fc4f01..e4f93d0693 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java @@ -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)); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RulesetsFactoryUtils.java b/pmd-core/src/main/java/net/sourceforge/pmd/RulesetsFactoryUtils.java index 76fab7d7eb..0e5d668454 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RulesetsFactoryUtils.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RulesetsFactoryUtils.java @@ -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) { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java index eb0fc98403..c6b3f641d7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java @@ -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")); diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java index 023bbc6d2e..f6e12f06a5 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java @@ -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); }