[core] Remove ruleset compatibility filter (RuleSetFactoryCompatibility) and CLI option --no-ruleset-compatibility
Fixes #4314 Closes #4378
This commit is contained in:
parent
2e7263af69
commit
ba602d1978
@ -174,6 +174,7 @@ Most notable changes:
|
||||
an error message such as `[main] ERROR net.sourceforge.pmd.cli.commands.internal.PmdCommand - No such file false`.
|
||||
* PMD tries to display a progress bar. If you don't want this (e.g. on a CI build server), you can disable this
|
||||
with `--no-progress`.
|
||||
* `--no-ruleset-compatibility` has been removed
|
||||
|
||||
### Custom distribution packages
|
||||
|
||||
|
@ -105,6 +105,8 @@ in the Migration Guide.
|
||||
* [#4723](https://github.com/pmd/pmd/issues/4723): \[cli] Launch fails for "bash pmd"
|
||||
* core
|
||||
* [#1027](https://github.com/pmd/pmd/issues/1027): \[core] Apply the new PropertyDescriptor<Pattern> type where applicable
|
||||
* [#4314](https://github.com/pmd/pmd/issues/4314): \[core] Remove ruleset compatibility filter (RuleSetFactoryCompatibility) and CLI option `--no-ruleset-compatibility`
|
||||
* [#4378](https://github.com/pmd/pmd/issues/4378): \[core] Ruleset loading processes commented rules
|
||||
* [#4674](https://github.com/pmd/pmd/issues/4674): \[core] WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass
|
||||
* [#4694](https://github.com/pmd/pmd/pull/4694): \[core] Fix line/col numbers in TokenMgrError
|
||||
* [#4717](https://github.com/pmd/pmd/issues/4717): \[core] XSLTRenderer doesn't close report file
|
||||
@ -159,6 +161,15 @@ The following previously deprecated classes have been removed:
|
||||
If the current version is needed, then `Node.getTextDocument().getLanguageVersion()` can be used. This
|
||||
is the version that has been selected via CLI `--use-version` parameter.
|
||||
|
||||
**Removed functionality**
|
||||
|
||||
* The CLI parameter `--no-ruleset-compatibility` has been removed. It was only used to allow loading
|
||||
some rulesets originally written for PMD 5 also in PMD 6 without fixing the rulesets.
|
||||
* The class {% jdoc_old core::RuleSetFactoryCompatibility %} has been removed without replacement.
|
||||
The different ways to enable/disable this filter in {% jdoc core::PMDConfiguration %}
|
||||
(Property "RuleSetFactoryCompatibilityEnabled") and
|
||||
{% jdoc ant::ant.PMDTask %} (Property "noRuleSetCompatibility") have been removed as well.
|
||||
|
||||
#### External Contributions
|
||||
* [#4640](https://github.com/pmd/pmd/pull/4640): \[cli] Launch script fails if run via "bash pmd" - [Shai Bennathan](https://github.com/shai-bennathan) (@shai-bennathan)
|
||||
* [#4673](https://github.com/pmd/pmd/pull/4673): \[javascript] CPD: Added support for decorator notation - [Wener](https://github.com/wener-tiobe) (@wener-tiobe)
|
||||
@ -566,10 +577,12 @@ See also [Detailed Release Notes for PMD 7]({{ baseurl }}pmd_release_notes_pmd7.
|
||||
* [#4204](https://github.com/pmd/pmd/issues/4204): \[core] Provide a CpdAnalysis class as a programmatic entry point into CPD
|
||||
* [#4301](https://github.com/pmd/pmd/issues/4301): \[core] Remove deprecated property concrete classes
|
||||
* [#4302](https://github.com/pmd/pmd/issues/4302): \[core] Migrate Property Framework API to Java 8
|
||||
* [#4314](https://github.com/pmd/pmd/issues/4314): \[core] Remove ruleset compatibility filter (RuleSetFactoryCompatibility) and CLI option `--no-ruleset-compatibility`
|
||||
* [#4323](https://github.com/pmd/pmd/issues/4323): \[core] Refactor CPD integration
|
||||
* [#4353](https://github.com/pmd/pmd/pull/4353): \[core] Micro optimizations for Node API
|
||||
* [#4365](https://github.com/pmd/pmd/pull/4365): \[core] Improve benchmarking
|
||||
* [#4397](https://github.com/pmd/pmd/pull/4397): \[core] Refactor CPD
|
||||
* [#4378](https://github.com/pmd/pmd/issues/4378): \[core] Ruleset loading processes commented rules
|
||||
* [#4420](https://github.com/pmd/pmd/pull/4420): \[core] Remove PMD.EOL
|
||||
* [#4425](https://github.com/pmd/pmd/pull/4425): \[core] Replace TextFile::pathId
|
||||
* [#4454](https://github.com/pmd/pmd/issues/4454): \[core] "Unknown option: '-min'" but is referenced in documentation
|
||||
|
@ -61,7 +61,6 @@ public class PMDTask extends Task {
|
||||
private final List<Path> relativizePathsWith = new ArrayList<>();
|
||||
private String suppressMarker;
|
||||
private String rulesetFiles;
|
||||
private boolean noRuleSetCompatibility;
|
||||
private String encoding;
|
||||
private int threads = 1; // same default as in PMDParameters (CLI)
|
||||
private int minimumPriority = RulePriority.LOW.getPriority(); // inclusive
|
||||
@ -267,14 +266,6 @@ public class PMDTask extends Task {
|
||||
return nestedRules;
|
||||
}
|
||||
|
||||
public boolean isNoRuleSetCompatibility() {
|
||||
return noRuleSetCompatibility;
|
||||
}
|
||||
|
||||
public void setNoRuleSetCompatibility(boolean noRuleSetCompatibility) {
|
||||
this.noRuleSetCompatibility = noRuleSetCompatibility;
|
||||
}
|
||||
|
||||
public String getCacheLocation() {
|
||||
return cacheLocation;
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ public class PMDTaskImpl {
|
||||
configuration.setRuleSets(Arrays.asList(task.getRulesetFiles().split(",")));
|
||||
}
|
||||
|
||||
configuration.setRuleSetFactoryCompatibilityEnabled(!task.isNoRuleSetCompatibility());
|
||||
if (task.getEncoding() != null) {
|
||||
configuration.setSourceEncoding(Charset.forName(task.getEncoding()));
|
||||
}
|
||||
|
@ -39,6 +39,6 @@ class DefaultRulesetTest {
|
||||
}
|
||||
|
||||
private RuleSetLoader rulesetLoader() {
|
||||
return new RuleSetLoader().enableCompatibility(false);
|
||||
return new RuleSetLoader();
|
||||
}
|
||||
}
|
||||
|
@ -102,8 +102,6 @@ public class PmdCommand extends AbstractAnalysisPmdSubcommand<PMDConfiguration>
|
||||
|
||||
private String auxClasspath;
|
||||
|
||||
private boolean noRuleSetCompatibility;
|
||||
|
||||
private Path cacheLocation;
|
||||
|
||||
private boolean noCache;
|
||||
@ -213,12 +211,6 @@ public class PmdCommand extends AbstractAnalysisPmdSubcommand<PMDConfiguration>
|
||||
this.auxClasspath = auxClasspath;
|
||||
}
|
||||
|
||||
@Option(names = "--no-ruleset-compatibility",
|
||||
description = "Disable the ruleset compatibility filter. The filter is active by default and tries automatically 'fix' old ruleset files with old rule names")
|
||||
public void setNoRuleSetCompatibility(final boolean noRuleSetCompatibility) {
|
||||
this.noRuleSetCompatibility = noRuleSetCompatibility;
|
||||
}
|
||||
|
||||
@Option(names = "--cache",
|
||||
description = "Specify the location of the cache file for incremental analysis. "
|
||||
+ "This should be the full path to the file, including the desired file name (not just the parent directory). "
|
||||
@ -274,7 +266,6 @@ public class PmdCommand extends AbstractAnalysisPmdSubcommand<PMDConfiguration>
|
||||
configuration.addRelativizeRoots(relativizeRootPaths);
|
||||
}
|
||||
configuration.setRuleSets(rulesets);
|
||||
configuration.setRuleSetFactoryCompatibilityEnabled(!this.noRuleSetCompatibility);
|
||||
configuration.setShowSuppressedViolations(showSuppressed);
|
||||
configuration.setSuppressMarker(suppressMarker);
|
||||
configuration.setThreads(threads);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,9 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
// This class has been taken from 7.0.0-SNAPSHOT
|
||||
// Before removing RuleSetFactoryCompatibility (#4314)
|
||||
|
||||
package net.sourceforge.pmd;
|
||||
|
||||
import java.text.MessageFormat;
|
328
pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoader.java
Normal file
328
pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoader.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -44,9 +44,6 @@ import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter;
|
||||
* These can be file paths or classpath resources.</li>
|
||||
* <li>Use {@link #setMinimumPriority(RulePriority)} to control the minimum priority a
|
||||
* rule must have to be included. Defaults to the lowest priority, ie all rules are loaded.</li>
|
||||
* <li>Use {@link #setRuleSetFactoryCompatibilityEnabled(boolean)} to disable the
|
||||
* compatibility measures for removed and renamed rules in the rulesets that will
|
||||
* be loaded.
|
||||
* </ul>
|
||||
*
|
||||
* <h3>Source files</h3>
|
||||
@ -106,7 +103,6 @@ public class PMDConfiguration extends AbstractConfiguration {
|
||||
// Rule and source file options
|
||||
private List<String> ruleSets = new ArrayList<>();
|
||||
private RulePriority minimumPriority = RulePriority.LOW;
|
||||
private boolean ruleSetFactoryCompatibilityEnabled = true;
|
||||
|
||||
// Reporting options
|
||||
private String reportFormat;
|
||||
@ -449,28 +445,6 @@ public class PMDConfiguration extends AbstractConfiguration {
|
||||
this.failOnViolation = failOnViolation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the rule set factory compatibility feature is enabled.
|
||||
*
|
||||
* @return true, if the rule set factory compatibility feature is enabled
|
||||
*
|
||||
* @see RuleSetLoader#enableCompatibility(boolean)
|
||||
*/
|
||||
public boolean isRuleSetFactoryCompatibilityEnabled() {
|
||||
return ruleSetFactoryCompatibilityEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rule set factory compatibility feature enabled/disabled.
|
||||
*
|
||||
* @param ruleSetFactoryCompatibilityEnabled {@code true} if the feature should be enabled
|
||||
*
|
||||
* @see RuleSetLoader#enableCompatibility(boolean)
|
||||
*/
|
||||
public void setRuleSetFactoryCompatibilityEnabled(boolean ruleSetFactoryCompatibilityEnabled) {
|
||||
this.ruleSetFactoryCompatibilityEnabled = ruleSetFactoryCompatibilityEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the currently used analysis cache. Will never be null.
|
||||
*
|
||||
|
@ -80,7 +80,6 @@ final class RuleSetFactory {
|
||||
private final LanguageRegistry languageRegistry;
|
||||
private final RulePriority minimumPriority;
|
||||
private final boolean warnDeprecated;
|
||||
private final RuleSetFactoryCompatibility compatibilityFilter;
|
||||
private final MessageReporter reporter;
|
||||
private final boolean includeDeprecatedRuleReferences;
|
||||
|
||||
@ -90,7 +89,6 @@ final class RuleSetFactory {
|
||||
LanguageRegistry languageRegistry,
|
||||
RulePriority minimumPriority,
|
||||
boolean warnDeprecated,
|
||||
RuleSetFactoryCompatibility compatFilter,
|
||||
boolean includeDeprecatedRuleReferences,
|
||||
MessageReporter reporter) {
|
||||
this.resourceLoader = resourceLoader;
|
||||
@ -99,7 +97,6 @@ final class RuleSetFactory {
|
||||
this.warnDeprecated = warnDeprecated;
|
||||
this.includeDeprecatedRuleReferences = includeDeprecatedRuleReferences;
|
||||
|
||||
this.compatibilityFilter = compatFilter;
|
||||
this.reporter = reporter;
|
||||
}
|
||||
|
||||
@ -374,7 +371,6 @@ final class RuleSetFactory {
|
||||
// has been reported
|
||||
continue;
|
||||
}
|
||||
excludedRuleName = compatibilityFilter.applyExclude(ref, excludedRuleName, this.warnDeprecated);
|
||||
if (excludedRuleName != null) {
|
||||
excludedRulesCheck.put(excludedRuleName, child);
|
||||
}
|
||||
@ -441,7 +437,6 @@ final class RuleSetFactory {
|
||||
private RuleSetReferenceId parseReferenceAndWarn(String ref,
|
||||
Node xmlPlace,
|
||||
PmdXmlReporter err) {
|
||||
ref = compatibilityFilter.applyRef(ref, this.warnDeprecated);
|
||||
if (ref == null) {
|
||||
err.at(xmlPlace).warn("Rule reference references a deleted rule, ignoring");
|
||||
return null; // deleted rule
|
||||
@ -664,7 +659,6 @@ final class RuleSetFactory {
|
||||
return new RuleSetLoader().loadResourcesWith(resourceLoader)
|
||||
.filterAbovePriority(minimumPriority)
|
||||
.warnDeprecated(warnDeprecated)
|
||||
.enableCompatibility(compatibilityFilter != null)
|
||||
.includeDeprecatedRuleReferences(includeDeprecatedRuleReferences);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,6 @@ public final class RuleSetLoader {
|
||||
private ResourceLoader resourceLoader = new ResourceLoader(RuleSetLoader.class.getClassLoader());
|
||||
private RulePriority minimumPriority = RulePriority.LOW;
|
||||
private boolean warnDeprecated = true;
|
||||
private @NonNull RuleSetFactoryCompatibility compatFilter = RuleSetFactoryCompatibility.DEFAULT;
|
||||
private boolean includeDeprecatedRuleReferences = false;
|
||||
private @NonNull MessageReporter reporter = MessageReporter.quiet();
|
||||
|
||||
@ -102,29 +101,9 @@ public final class RuleSetLoader {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable translating old rule references to newer ones, if they have
|
||||
* been moved or renamed. This is enabled by default, if disabled,
|
||||
* unresolved references will not be translated and will produce an
|
||||
* error.
|
||||
*
|
||||
* @return This instance, modified
|
||||
*/
|
||||
public RuleSetLoader enableCompatibility(boolean enable) {
|
||||
return setCompatibility(enable ? RuleSetFactoryCompatibility.DEFAULT
|
||||
: RuleSetFactoryCompatibility.EMPTY);
|
||||
}
|
||||
|
||||
// test only
|
||||
RuleSetLoader setCompatibility(@NonNull RuleSetFactoryCompatibility filter) {
|
||||
this.compatFilter = filter;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow deprecated rule references. By default this is off,
|
||||
* and those references will be ignored (with a warning depending
|
||||
* on {@link #enableCompatibility(boolean)}).
|
||||
* and those references will be ignored.
|
||||
*
|
||||
* @return This instance, modified
|
||||
*/
|
||||
@ -147,7 +126,6 @@ public final class RuleSetLoader {
|
||||
this.languageRegistry,
|
||||
this.minimumPriority,
|
||||
this.warnDeprecated,
|
||||
this.compatFilter,
|
||||
this.includeDeprecatedRuleReferences,
|
||||
this.reporter
|
||||
);
|
||||
@ -278,7 +256,6 @@ public final class RuleSetLoader {
|
||||
*/
|
||||
public static RuleSetLoader fromPmdConfig(PMDConfiguration configuration) {
|
||||
return new RuleSetLoader().filterAbovePriority(configuration.getMinimumPriority())
|
||||
.enableCompatibility(configuration.isRuleSetFactoryCompatibilityEnabled())
|
||||
.withLanguages(configuration.getLanguageRegistry())
|
||||
.withReporter(configuration.getReporter());
|
||||
}
|
||||
|
@ -12,7 +12,9 @@ This ruleset contains links to rules that are new in PMD v3.4
|
||||
<rule ref="rulesets/java/basic.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>
|
||||
|
||||
<rule ref="rulesets/java/design.xml/NonThreadSafeSingleton"/>
|
||||
<!-- removed with 5.4.0, renamed to UncommentedEmptyMethodBody
|
||||
<rule ref="rulesets/java/design.xml/UncommentedEmptyMethod"/>
|
||||
-->
|
||||
<rule ref="rulesets/java/design.xml/UncommentedEmptyConstructor"/>
|
||||
|
||||
<!-- <rule ref="rulesets/java/controversial.xml/DefaultPackage"/>-->
|
||||
|
@ -20,7 +20,9 @@ This ruleset contains links to rules that are new in PMD v3.5
|
||||
|
||||
<!-- <rule ref="rulesets/java/junit.xml/UseAssertNullInsteadOfAssertTrue"/>-->
|
||||
|
||||
<!-- removed with 5.6.0:
|
||||
<rule ref="rulesets/java/design.xml/AvoidConstantsInterface"/>
|
||||
-->
|
||||
|
||||
<rule ref="rulesets/java/optimizations.xml/UseArraysAsList"/>
|
||||
<rule ref="rulesets/java/optimizations.xml/AvoidArrayLoops"/>
|
||||
|
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class RuleSetFactoryCompatibilityTest {
|
||||
|
||||
@Test
|
||||
void testCorrectOldReference() throws Exception {
|
||||
final String ruleset = "<?xml version=\"1.0\"?>\n" + "\n" + "<ruleset name=\"Test\"\n"
|
||||
+ " xmlns=\"http://pmd.sourceforge.net/ruleset/2.0.0\"\n"
|
||||
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
|
||||
+ " xsi:schemaLocation=\"http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd\">\n"
|
||||
+ " <description>Test</description>\n" + "\n"
|
||||
+ " <rule ref=\"rulesets/dummy/notexisting.xml/DummyBasicMockRule\" />\n" + "</ruleset>\n";
|
||||
|
||||
RuleSetFactoryCompatibility compat = new RuleSetFactoryCompatibility();
|
||||
compat.addFilterRuleMoved("dummy", "notexisting", "basic", "DummyBasicMockRule");
|
||||
|
||||
|
||||
RuleSetLoader rulesetLoader = new RuleSetLoader().setCompatibility(compat);
|
||||
RuleSet createdRuleSet = rulesetLoader.loadFromString("dummy.xml", ruleset);
|
||||
|
||||
assertNotNull(createdRuleSet.getRuleByName("DummyBasicMockRule"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCorrectMovedAndRename() {
|
||||
|
||||
RuleSetFactoryCompatibility rsfc = new RuleSetFactoryCompatibility();
|
||||
rsfc.addFilterRuleMoved("dummy", "notexisting", "basic", "OldDummyBasicMockRule");
|
||||
rsfc.addFilterRuleRenamed("dummy", "basic", "OldDummyBasicMockRule", "NewNameForDummyBasicMockRule");
|
||||
|
||||
String out = rsfc.applyRef("rulesets/dummy/notexisting.xml/OldDummyBasicMockRule");
|
||||
|
||||
assertEquals("rulesets/dummy/basic.xml/NewNameForDummyBasicMockRule", out);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExclusion() {
|
||||
final String ruleset = "<?xml version=\"1.0\"?>\n" + "\n" + "<ruleset name=\"Test\"\n"
|
||||
+ " xmlns=\"http://pmd.sourceforge.net/ruleset/2.0.0\"\n"
|
||||
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
|
||||
+ " xsi:schemaLocation=\"http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd\">\n"
|
||||
+ " <description>Test</description>\n" + "\n" + " <rule ref=\"rulesets/dummy/basic.xml\">\n"
|
||||
+ " <exclude name=\"OldNameOfSampleXPathRule\"/>\n" + " </rule>\n" + "</ruleset>\n";
|
||||
|
||||
RuleSetFactoryCompatibility compat = new RuleSetFactoryCompatibility();
|
||||
compat.addFilterRuleRenamed("dummy", "basic", "OldNameOfSampleXPathRule", "SampleXPathRule");
|
||||
|
||||
RuleSetLoader rulesetLoader = new RuleSetLoader().setCompatibility(compat);
|
||||
RuleSet createdRuleSet = rulesetLoader.loadFromString("dummy.xml", ruleset);
|
||||
|
||||
assertNotNull(createdRuleSet.getRuleByName("DummyBasicMockRule"));
|
||||
assertNull(createdRuleSet.getRuleByName("SampleXPathRule"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExclusionRenamedAndMoved() {
|
||||
|
||||
RuleSetFactoryCompatibility rsfc = new RuleSetFactoryCompatibility();
|
||||
rsfc.addFilterRuleMovedAndRenamed("dummy", "oldbasic", "OldDummyBasicMockRule", "basic", "NewNameForDummyBasicMockRule");
|
||||
|
||||
String in = "rulesets/dummy/oldbasic.xml";
|
||||
String out = rsfc.applyRef(in);
|
||||
|
||||
assertEquals(in, out);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilter() {
|
||||
RuleSetFactoryCompatibility rsfc = new RuleSetFactoryCompatibility();
|
||||
rsfc.addFilterRuleMoved("dummy", "notexisting", "basic", "DummyBasicMockRule");
|
||||
rsfc.addFilterRuleRemoved("dummy", "basic", "DeletedRule");
|
||||
rsfc.addFilterRuleRenamed("dummy", "basic", "OldNameOfBasicMockRule", "NewNameOfBasicMockRule");
|
||||
|
||||
assertEquals("rulesets/dummy/basic.xml/DummyBasicMockRule",
|
||||
rsfc.applyRef("rulesets/dummy/notexisting.xml/DummyBasicMockRule"));
|
||||
|
||||
assertEquals("rulesets/dummy/basic.xml/NewNameOfBasicMockRule",
|
||||
rsfc.applyRef("rulesets/dummy/basic.xml/OldNameOfBasicMockRule"));
|
||||
|
||||
assertNull(rsfc.applyRef("rulesets/dummy/basic.xml/DeletedRule"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExclusionFilter() {
|
||||
RuleSetFactoryCompatibility rsfc = new RuleSetFactoryCompatibility();
|
||||
rsfc.addFilterRuleRenamed("dummy", "basic", "AnotherOldNameOfBasicMockRule", "NewNameOfBasicMockRule");
|
||||
|
||||
String out = rsfc.applyExclude("rulesets/dummy/basic.xml", "AnotherOldNameOfBasicMockRule", false);
|
||||
|
||||
assertEquals("NewNameOfBasicMockRule", out);
|
||||
}
|
||||
|
||||
}
|
@ -525,7 +525,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase {
|
||||
|
||||
@Test
|
||||
void testReferencePriority() {
|
||||
RuleSetLoader config = new RuleSetLoader().warnDeprecated(false).enableCompatibility(true);
|
||||
RuleSetLoader config = new RuleSetLoader().warnDeprecated(false);
|
||||
|
||||
RuleSetLoader rulesetLoader = config.filterAbovePriority(RulePriority.LOW);
|
||||
RuleSet ruleSet = rulesetLoader.loadFromString("", REF_INTERNAL_TO_INTERNAL_CHAIN);
|
||||
@ -567,7 +567,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase {
|
||||
@Test
|
||||
void testOverridePriorityLoadWithMinimum() {
|
||||
RuleSetLoader rulesetLoader = new RuleSetLoader().filterAbovePriority(RulePriority.MEDIUM_LOW)
|
||||
.warnDeprecated(true).enableCompatibility(true);
|
||||
.warnDeprecated(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(1, ruleset.getRules().size(), "Number of Rules");
|
||||
|
@ -109,7 +109,7 @@ public class RulesetFactoryTestBase {
|
||||
try (PmdAnalysis pmd = PmdAnalysis.create(config)) {
|
||||
return pmd.newRuleSetLoader()
|
||||
.warnDeprecated(true)
|
||||
.enableCompatibility(false).loadFromString("dummyRuleset.xml", ruleSetXml);
|
||||
.loadFromString("dummyRuleset.xml", ruleSetXml);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,12 @@ import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.sourceforge.pmd.PMDConfiguration;
|
||||
import net.sourceforge.pmd.RuleSetLoader;
|
||||
import net.sourceforge.pmd.internal.util.IOUtil;
|
||||
import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter;
|
||||
|
||||
class RuleSetResolverTest {
|
||||
|
||||
@ -33,7 +36,9 @@ class RuleSetResolverTest {
|
||||
assertFalse(additionalRulesets.isEmpty());
|
||||
|
||||
for (String filename : additionalRulesets) {
|
||||
new RuleSetLoader().warnDeprecated(false).loadFromResource(filename); // will throw if invalid
|
||||
PMDConfiguration config = new PMDConfiguration();
|
||||
config.setReporter(new SimpleMessageReporter(LoggerFactory.getLogger(RuleSetResolverTest.class)));
|
||||
RuleSetLoader.fromPmdConfig(config).warnDeprecated(false).loadFromResource(filename); // will throw if invalid
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ class QuickstartRulesetTest {
|
||||
|
||||
@Test
|
||||
void noDeprecations() throws Exception {
|
||||
RuleSetLoader ruleSetLoader = new RuleSetLoader().enableCompatibility(false);
|
||||
RuleSetLoader ruleSetLoader = new RuleSetLoader();
|
||||
String errorOutput = SystemLambda.tapSystemErr(() -> {
|
||||
RuleSet quickstart = ruleSetLoader.loadFromResource(QUICKSTART_RULESET);
|
||||
assertFalse(quickstart.getRules().isEmpty());
|
||||
|
Loading…
x
Reference in New Issue
Block a user