Rename stuff
This commit is contained in:
@ -22,7 +22,7 @@ public class DefaultRulesetTest {
|
||||
@Rule
|
||||
public final SystemErrRule systemErrRule = new SystemErrRule().enableLog().muteForSuccessfulTests();
|
||||
|
||||
private RuleSetFactory factory = new RuleSetParser().enableCompatibility(false).createFactory();
|
||||
private RuleSetFactory factory = new RuleSetParser().enableCompatibility(false).toFactory();
|
||||
|
||||
@Test
|
||||
public void loadDefaultRuleset() throws Exception {
|
||||
|
@ -222,7 +222,7 @@ public class PMD {
|
||||
public static int doPMD(PMDConfiguration configuration) {
|
||||
|
||||
// Load the RuleSets
|
||||
final RuleSetFactory ruleSetFactory = RuleSetParser.fromPmdConfig(configuration).createFactory();
|
||||
final RuleSetFactory ruleSetFactory = RuleSetParser.fromPmdConfig(configuration).toFactory();
|
||||
final RuleSets ruleSets = RulesetsFactoryUtils.getRuleSetsWithBenchmark(configuration.getRuleSets(), ruleSetFactory);
|
||||
if (ruleSets == null) {
|
||||
return PMDCommandLineInterface.NO_ERRORS_STATUS;
|
||||
@ -336,7 +336,7 @@ public class PMD {
|
||||
// Make sure the cache is listening for analysis results
|
||||
ctx.getReport().addListener(configuration.getAnalysisCache());
|
||||
|
||||
final RuleSetFactory silentFactory = ruleSetFactory.toConfig().warnDeprecated(false).createFactory();
|
||||
final RuleSetFactory silentFactory = ruleSetFactory.toParser().warnDeprecated(false).toFactory();
|
||||
newFileProcessor(configuration).processFiles(silentFactory, files, ctx, renderers);
|
||||
configuration.getAnalysisCache().persist();
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public class RuleSetFactory {
|
||||
* Whether deprecation warnings are to be produced by this
|
||||
* factory
|
||||
*
|
||||
* @deprecated Use {@link #toConfig()} to rebuild a factory from a configuration
|
||||
* @deprecated Use {@link #toParser()} to rebuild a factory from a configuration
|
||||
*/
|
||||
@Deprecated
|
||||
public RuleSetFactory(final RuleSetFactory factory, final boolean warnDeprecated) {
|
||||
@ -566,7 +566,7 @@ public class RuleSetFactory {
|
||||
|
||||
// load the ruleset with minimum priority low, so that we get all rules, to be able to exclude any rule
|
||||
// minimum priority will be applied again, before constructing the final ruleset
|
||||
RuleSetFactory ruleSetFactory = toConfig().filterAbovePriority(RulePriority.LOW).warnDeprecated(false).createFactory();
|
||||
RuleSetFactory ruleSetFactory = toParser().filterAbovePriority(RulePriority.LOW).warnDeprecated(false).toFactory();
|
||||
RuleSet otherRuleSet = ruleSetFactory.createRuleSet(RuleSetReferenceId.parse(ref).get(0));
|
||||
List<RuleReference> potentialRules = new ArrayList<>();
|
||||
int countDeprecated = 0;
|
||||
@ -681,7 +681,7 @@ public class RuleSetFactory {
|
||||
|
||||
// load the ruleset with minimum priority low, so that we get all rules, to be able to exclude any rule
|
||||
// minimum priority will be applied again, before constructing the final ruleset
|
||||
RuleSetFactory ruleSetFactory = toConfig().warnDeprecated(false).createFactory();
|
||||
RuleSetFactory ruleSetFactory = toParser().warnDeprecated(false).toFactory();
|
||||
|
||||
boolean isSameRuleSet = false;
|
||||
RuleSetReferenceId otherRuleSetReferenceId = RuleSetReferenceId.parse(ref).get(0);
|
||||
@ -843,11 +843,16 @@ public class RuleSetFactory {
|
||||
}
|
||||
|
||||
|
||||
public RuleSetParser toConfig() {
|
||||
/**
|
||||
* Create a new {@link RuleSetParser} with the same config as this
|
||||
* factory. This is a transitional API.
|
||||
*/
|
||||
public RuleSetParser toParser() {
|
||||
return new RuleSetParser().loadResourcesWith(resourceLoader)
|
||||
.filterAbovePriority(minimumPriority)
|
||||
.warnDeprecated(warnDeprecated)
|
||||
.enableCompatibility(compatibilityFilter != null);
|
||||
.enableCompatibility(compatibilityFilter != null)
|
||||
.includeDeprecatedRuleReferences(includeDeprecatedRuleReferences);
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,7 +95,8 @@ public final class RuleSetParser {
|
||||
* Create a new rule set factory, if you have to (that class is deprecated).
|
||||
* That factory will use the configuration that was set using the setters of this.
|
||||
*/
|
||||
public RuleSetFactory createFactory() {
|
||||
@Deprecated
|
||||
public RuleSetFactory toFactory() {
|
||||
return new RuleSetFactory(this);
|
||||
}
|
||||
|
||||
|
@ -507,38 +507,38 @@ public class RuleSetFactoryTest {
|
||||
public void testReferencePriority() throws RuleSetNotFoundException {
|
||||
RuleSetParser config = new RuleSetParser().warnDeprecated(false).enableCompatibility(true);
|
||||
|
||||
RuleSetFactory rsf = config.filterAbovePriority(RulePriority.LOW).createFactory();
|
||||
RuleSetFactory rsf = config.filterAbovePriority(RulePriority.LOW).toFactory();
|
||||
RuleSet ruleSet = rsf.createRuleSet(createRuleSetReferenceId(REF_INTERNAL_TO_INTERNAL_CHAIN));
|
||||
assertEquals("Number of Rules", 3, ruleSet.getRules().size());
|
||||
assertNotNull(ruleSet.getRuleByName("MockRuleName"));
|
||||
assertNotNull(ruleSet.getRuleByName("MockRuleNameRef"));
|
||||
assertNotNull(ruleSet.getRuleByName("MockRuleNameRefRef"));
|
||||
|
||||
rsf = config.filterAbovePriority(RulePriority.MEDIUM_HIGH).createFactory();
|
||||
rsf = config.filterAbovePriority(RulePriority.MEDIUM_HIGH).toFactory();
|
||||
ruleSet = rsf.createRuleSet(createRuleSetReferenceId(REF_INTERNAL_TO_INTERNAL_CHAIN));
|
||||
assertEquals("Number of Rules", 2, ruleSet.getRules().size());
|
||||
assertNotNull(ruleSet.getRuleByName("MockRuleNameRef"));
|
||||
assertNotNull(ruleSet.getRuleByName("MockRuleNameRefRef"));
|
||||
|
||||
rsf = config.filterAbovePriority(RulePriority.HIGH).createFactory();
|
||||
rsf = config.filterAbovePriority(RulePriority.HIGH).toFactory();
|
||||
ruleSet = rsf.createRuleSet(createRuleSetReferenceId(REF_INTERNAL_TO_INTERNAL_CHAIN));
|
||||
assertEquals("Number of Rules", 1, ruleSet.getRules().size());
|
||||
assertNotNull(ruleSet.getRuleByName("MockRuleNameRefRef"));
|
||||
|
||||
rsf = config.filterAbovePriority(RulePriority.LOW).createFactory();
|
||||
rsf = config.filterAbovePriority(RulePriority.LOW).toFactory();
|
||||
ruleSet = rsf.createRuleSet(createRuleSetReferenceId(REF_INTERNAL_TO_EXTERNAL_CHAIN));
|
||||
assertEquals("Number of Rules", 3, ruleSet.getRules().size());
|
||||
assertNotNull(ruleSet.getRuleByName("ExternalRefRuleName"));
|
||||
assertNotNull(ruleSet.getRuleByName("ExternalRefRuleNameRef"));
|
||||
assertNotNull(ruleSet.getRuleByName("ExternalRefRuleNameRefRef"));
|
||||
|
||||
rsf = config.filterAbovePriority(RulePriority.MEDIUM_HIGH).createFactory();
|
||||
rsf = config.filterAbovePriority(RulePriority.MEDIUM_HIGH).toFactory();
|
||||
ruleSet = rsf.createRuleSet(createRuleSetReferenceId(REF_INTERNAL_TO_EXTERNAL_CHAIN));
|
||||
assertEquals("Number of Rules", 2, ruleSet.getRules().size());
|
||||
assertNotNull(ruleSet.getRuleByName("ExternalRefRuleNameRef"));
|
||||
assertNotNull(ruleSet.getRuleByName("ExternalRefRuleNameRefRef"));
|
||||
|
||||
rsf = config.filterAbovePriority(RulePriority.HIGH).createFactory();
|
||||
rsf = config.filterAbovePriority(RulePriority.HIGH).toFactory();
|
||||
ruleSet = rsf.createRuleSet(createRuleSetReferenceId(REF_INTERNAL_TO_EXTERNAL_CHAIN));
|
||||
assertEquals("Number of Rules", 1, ruleSet.getRules().size());
|
||||
assertNotNull(ruleSet.getRuleByName("ExternalRefRuleNameRefRef"));
|
||||
@ -546,7 +546,7 @@ public class RuleSetFactoryTest {
|
||||
|
||||
@Test
|
||||
public void testOverridePriorityLoadWithMinimum() throws RuleSetNotFoundException {
|
||||
RuleSetFactory rsf = new RuleSetParser().filterAbovePriority(RulePriority.MEDIUM_LOW).warnDeprecated(true).enableCompatibility(true).createFactory();
|
||||
RuleSetFactory rsf = new RuleSetParser().filterAbovePriority(RulePriority.MEDIUM_LOW).warnDeprecated(true).enableCompatibility(true).toFactory();
|
||||
RuleSet ruleset = rsf.createRuleSet("net/sourceforge/pmd/rulesets/ruleset-minimum-priority.xml");
|
||||
// only one rule should remain, since we filter out the other rule by minimum priority
|
||||
assertEquals("Number of Rules", 1, ruleset.getRules().size());
|
||||
@ -567,13 +567,13 @@ public class RuleSetFactoryTest {
|
||||
|
||||
@Test
|
||||
public void testExcludeWithMinimumPriority() throws RuleSetNotFoundException {
|
||||
RuleSetFactory rsf = new RuleSetParser().filterAbovePriority(RulePriority.HIGH).createFactory();
|
||||
RuleSetFactory rsf = new RuleSetParser().filterAbovePriority(RulePriority.HIGH).toFactory();
|
||||
RuleSet ruleset = rsf.createRuleSet("net/sourceforge/pmd/rulesets/ruleset-minimum-priority-exclusion.xml");
|
||||
// no rules should be loaded
|
||||
assertEquals("Number of Rules", 0, ruleset.getRules().size());
|
||||
|
||||
// now, load with default minimum priority
|
||||
rsf = new RuleSetParser().filterAbovePriority(RulePriority.LOW).createFactory();
|
||||
rsf = new RuleSetParser().filterAbovePriority(RulePriority.LOW).toFactory();
|
||||
ruleset = rsf.createRuleSet("net/sourceforge/pmd/rulesets/ruleset-minimum-priority-exclusion.xml");
|
||||
// only one rule, we have excluded one...
|
||||
assertEquals("Number of Rules", 1, ruleset.getRules().size());
|
||||
@ -602,9 +602,9 @@ public class RuleSetFactoryTest {
|
||||
|
||||
@Test
|
||||
public void testSetPriority() throws RuleSetNotFoundException {
|
||||
RuleSetFactory rsf = new RuleSetParser().filterAbovePriority(RulePriority.MEDIUM_HIGH).warnDeprecated(false).createFactory();
|
||||
RuleSetFactory rsf = new RuleSetParser().filterAbovePriority(RulePriority.MEDIUM_HIGH).warnDeprecated(false).toFactory();
|
||||
assertEquals(0, rsf.createRuleSet(createRuleSetReferenceId(SINGLE_RULE)).size());
|
||||
rsf = new RuleSetParser().filterAbovePriority(RulePriority.MEDIUM_LOW).warnDeprecated(false).createFactory();
|
||||
rsf = new RuleSetParser().filterAbovePriority(RulePriority.MEDIUM_LOW).warnDeprecated(false).toFactory();
|
||||
assertEquals(1, rsf.createRuleSet(createRuleSetReferenceId(SINGLE_RULE)).size());
|
||||
}
|
||||
|
||||
@ -779,7 +779,7 @@ public class RuleSetFactoryTest {
|
||||
+ " <description>Ruleset which references a empty ruleset</description>\n" + "\n"
|
||||
+ " <rule ref=\"rulesets/dummy/empty-ruleset.xml\" />\n"
|
||||
+ "</ruleset>\n");
|
||||
RuleSetFactory ruleSetFactory = new RuleSetParser().loadResourcesWith(new ResourceLoader()).filterAbovePriority(RulePriority.LOW).warnDeprecated(true).enableCompatibility(true).createFactory();
|
||||
RuleSetFactory ruleSetFactory = new RuleSetParser().loadResourcesWith(new ResourceLoader()).filterAbovePriority(RulePriority.LOW).warnDeprecated(true).enableCompatibility(true).toFactory();
|
||||
RuleSet ruleset = ruleSetFactory.createRuleSet(ref);
|
||||
assertEquals(0, ruleset.getRules().size());
|
||||
|
||||
@ -1284,7 +1284,7 @@ public class RuleSetFactoryTest {
|
||||
}
|
||||
|
||||
private RuleSet loadRuleSetWithDeprecationWarnings(String ruleSetXml) throws RuleSetNotFoundException {
|
||||
RuleSetFactory rsf = new RuleSetParser().warnDeprecated(true).enableCompatibility(false).createFactory();
|
||||
RuleSetFactory rsf = new RuleSetParser().warnDeprecated(true).enableCompatibility(false).toFactory();
|
||||
return rsf.createRuleSet(createRuleSetReferenceId(ruleSetXml));
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class PMD5RulesetTest {
|
||||
|
||||
@Test
|
||||
public void loadRuleset() throws Exception {
|
||||
RuleSetFactory ruleSetFactory = new RuleSetParser().createFactory();
|
||||
RuleSetFactory ruleSetFactory = new RuleSetParser().toFactory();
|
||||
RuleSet ruleset = ruleSetFactory.createRuleSet("net/sourceforge/pmd/lang/java/pmd5ruleset.xml");
|
||||
Assert.assertNotNull(ruleset);
|
||||
Assert.assertNull(ruleset.getRuleByName("GuardLogStatementJavaUtil"));
|
||||
|
@ -49,7 +49,7 @@ public class QuickstartRulesetTest {
|
||||
}
|
||||
});
|
||||
|
||||
RuleSetFactory ruleSetFactory = new RuleSetParser().enableCompatibility(false).createFactory();
|
||||
RuleSetFactory ruleSetFactory = new RuleSetParser().enableCompatibility(false).toFactory();
|
||||
RuleSet quickstart = ruleSetFactory.createRuleSet("rulesets/java/quickstart.xml");
|
||||
Assert.assertFalse(quickstart.getRules().isEmpty());
|
||||
}
|
||||
|
Reference in New Issue
Block a user