From 3fcf3396567a950ae46e909360b1d00a7c84272b Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 24 Jan 2021 18:39:43 +0100 Subject: [PATCH] Rename local variable rsf -> rulesetLoader --- .../pmd/RuleSetFactoryCompatibilityTest.java | 8 +-- .../sourceforge/pmd/RuleSetFactoryTest.java | 50 ++++++++++--------- .../pmd/lang/java/QuickstartRulesetTest.java | 4 +- .../pmd/AbstractLanguageVersionTest.java | 4 +- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryCompatibilityTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryCompatibilityTest.java index bbc4a5db96..c397dae645 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryCompatibilityTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryCompatibilityTest.java @@ -22,8 +22,8 @@ public class RuleSetFactoryCompatibilityTest { compat.addFilterRuleMoved("dummy", "notexisting", "basic", "DummyBasicMockRule"); - RuleSetLoader factory = new RuleSetLoader().setCompatibility(compat); - RuleSet createdRuleSet = factory.loadFromString("dummy.xml", ruleset); + RuleSetLoader rulesetLoader = new RuleSetLoader().setCompatibility(compat); + RuleSet createdRuleSet = rulesetLoader.loadFromString("dummy.xml", ruleset); Assert.assertNotNull(createdRuleSet.getRuleByName("DummyBasicMockRule")); } @@ -52,8 +52,8 @@ public class RuleSetFactoryCompatibilityTest { RuleSetFactoryCompatibility compat = new RuleSetFactoryCompatibility(); compat.addFilterRuleRenamed("dummy", "basic", "OldNameOfSampleXPathRule", "SampleXPathRule"); - RuleSetLoader factory = new RuleSetLoader().setCompatibility(compat); - RuleSet createdRuleSet = factory.loadFromString("dummy.xml", ruleset); + RuleSetLoader rulesetLoader = new RuleSetLoader().setCompatibility(compat); + RuleSet createdRuleSet = rulesetLoader.loadFromString("dummy.xml", ruleset); Assert.assertNotNull(createdRuleSet.getRuleByName("DummyBasicMockRule")); Assert.assertNull(createdRuleSet.getRuleByName("SampleXPathRule")); 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 0b0bab592b..3121aef3a3 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java @@ -490,47 +490,48 @@ public class RuleSetFactoryTest { public void testReferencePriority() { RuleSetLoader config = new RuleSetLoader().warnDeprecated(false).enableCompatibility(true); - RuleSetLoader rsf = config.filterAbovePriority(RulePriority.LOW); - RuleSet ruleSet = rsf.loadFromString("", REF_INTERNAL_TO_INTERNAL_CHAIN); + RuleSetLoader rulesetLoader = config.filterAbovePriority(RulePriority.LOW); + RuleSet ruleSet = rulesetLoader.loadFromString("", 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); - ruleSet = rsf.loadFromString("", REF_INTERNAL_TO_INTERNAL_CHAIN); + rulesetLoader = config.filterAbovePriority(RulePriority.MEDIUM_HIGH); + ruleSet = rulesetLoader.loadFromString("", 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); - ruleSet = rsf.loadFromString("", REF_INTERNAL_TO_INTERNAL_CHAIN); + rulesetLoader = config.filterAbovePriority(RulePriority.HIGH); + ruleSet = rulesetLoader.loadFromString("", REF_INTERNAL_TO_INTERNAL_CHAIN); assertEquals("Number of Rules", 1, ruleSet.getRules().size()); assertNotNull(ruleSet.getRuleByName("MockRuleNameRefRef")); - rsf = config.filterAbovePriority(RulePriority.LOW); - ruleSet = rsf.loadFromString("", REF_INTERNAL_TO_EXTERNAL_CHAIN); + rulesetLoader = config.filterAbovePriority(RulePriority.LOW); + ruleSet = rulesetLoader.loadFromString("", 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); - ruleSet = rsf.loadFromString("", REF_INTERNAL_TO_EXTERNAL_CHAIN); + rulesetLoader = config.filterAbovePriority(RulePriority.MEDIUM_HIGH); + ruleSet = rulesetLoader.loadFromString("", 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); - ruleSet = rsf.loadFromString("", REF_INTERNAL_TO_EXTERNAL_CHAIN); + rulesetLoader = config.filterAbovePriority(RulePriority.HIGH); + ruleSet = rulesetLoader.loadFromString("", REF_INTERNAL_TO_EXTERNAL_CHAIN); assertEquals("Number of Rules", 1, ruleSet.getRules().size()); assertNotNull(ruleSet.getRuleByName("ExternalRefRuleNameRefRef")); } @Test public void testOverridePriorityLoadWithMinimum() { - RuleSetLoader rsf = new RuleSetLoader().filterAbovePriority(RulePriority.MEDIUM_LOW).warnDeprecated(true).enableCompatibility(true); - RuleSet ruleset = rsf.loadFromResource("net/sourceforge/pmd/rulesets/ruleset-minimum-priority.xml"); + RuleSetLoader rulesetLoader = new RuleSetLoader().filterAbovePriority(RulePriority.MEDIUM_LOW) + .warnDeprecated(true).enableCompatibility(true); + RuleSet ruleset = rulesetLoader.loadFromResource("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()); @@ -541,8 +542,8 @@ public class RuleSetFactoryTest { assertNotNull(ruleset.getRuleByName("SampleXPathRule")); // now, load with default minimum priority - rsf = new RuleSetLoader(); - ruleset = rsf.loadFromResource("net/sourceforge/pmd/rulesets/ruleset-minimum-priority.xml"); + rulesetLoader = new RuleSetLoader(); + ruleset = rulesetLoader.loadFromResource("net/sourceforge/pmd/rulesets/ruleset-minimum-priority.xml"); assertEquals("Number of Rules", 2, ruleset.getRules().size()); Rule dummyBasicMockRule = ruleset.getRuleByName("DummyBasicMockRule"); assertEquals("Wrong Priority", RulePriority.LOW, dummyBasicMockRule.getPriority()); @@ -550,14 +551,15 @@ public class RuleSetFactoryTest { @Test public void testExcludeWithMinimumPriority() { - RuleSetLoader rsf = new RuleSetLoader().filterAbovePriority(RulePriority.HIGH); - RuleSet ruleset = rsf.loadFromResource("net/sourceforge/pmd/rulesets/ruleset-minimum-priority-exclusion.xml"); + RuleSetLoader rulesetLoader = new RuleSetLoader().filterAbovePriority(RulePriority.HIGH); + RuleSet ruleset = rulesetLoader + .loadFromResource("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 RuleSetLoader().filterAbovePriority(RulePriority.LOW); - ruleset = rsf.loadFromResource("net/sourceforge/pmd/rulesets/ruleset-minimum-priority-exclusion.xml"); + rulesetLoader = new RuleSetLoader().filterAbovePriority(RulePriority.LOW); + ruleset = rulesetLoader.loadFromResource("net/sourceforge/pmd/rulesets/ruleset-minimum-priority-exclusion.xml"); // only one rule, we have excluded one... assertEquals("Number of Rules", 1, ruleset.getRules().size()); // rule is excluded @@ -585,10 +587,10 @@ public class RuleSetFactoryTest { @Test public void testSetPriority() { - RuleSetLoader rsf = new RuleSetLoader().filterAbovePriority(RulePriority.MEDIUM_HIGH).warnDeprecated(false); - assertEquals(0, rsf.loadFromString("", SINGLE_RULE).size()); - rsf = new RuleSetLoader().filterAbovePriority(RulePriority.MEDIUM_LOW).warnDeprecated(false); - assertEquals(1, rsf.loadFromString("", SINGLE_RULE).size()); + RuleSetLoader rulesetLoader = new RuleSetLoader().filterAbovePriority(RulePriority.MEDIUM_HIGH).warnDeprecated(false); + assertEquals(0, rulesetLoader.loadFromString("", SINGLE_RULE).size()); + rulesetLoader = new RuleSetLoader().filterAbovePriority(RulePriority.MEDIUM_LOW).warnDeprecated(false); + assertEquals(1, rulesetLoader.loadFromString("", SINGLE_RULE).size()); } @Test diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java index c72a41b24e..209f80b27f 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java @@ -47,8 +47,8 @@ public class QuickstartRulesetTest { } }); - RuleSetLoader ruleSetFactory = new RuleSetLoader().enableCompatibility(false); - RuleSet quickstart = ruleSetFactory.loadFromResource("rulesets/java/quickstart.xml"); + RuleSetLoader ruleSetLoader = new RuleSetLoader().enableCompatibility(false); + RuleSet quickstart = ruleSetLoader.loadFromResource("rulesets/java/quickstart.xml"); Assert.assertFalse(quickstart.getRules().isEmpty()); } } diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java index 41a01c7833..bf7b8d3230 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java @@ -159,7 +159,7 @@ public class AbstractLanguageVersionTest { String rulesetFilenames = props.getProperty("rulesets.filenames"); assertNotNull(rulesetFilenames); - RuleSetLoader factory = new RuleSetLoader(); + RuleSetLoader rulesetLoader = new RuleSetLoader(); if (rulesetFilenames.trim().isEmpty()) { return; @@ -167,7 +167,7 @@ public class AbstractLanguageVersionTest { String[] rulesets = rulesetFilenames.split(","); for (String r : rulesets) { - RuleSet ruleset = factory.loadFromResource(r); + RuleSet ruleset = rulesetLoader.loadFromResource(r); assertNotNull(ruleset); } }