diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87417153a5..b4b787a283 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: os: [ ubuntu-latest, windows-latest, macos-latest ] if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 2 - uses: actions/cache@v2 diff --git a/.github/workflows/git-repo-sync.yml b/.github/workflows/git-repo-sync.yml index 2219f2330a..250dd00933 100644 --- a/.github/workflows/git-repo-sync.yml +++ b/.github/workflows/git-repo-sync.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest continue-on-error: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 100 - name: Setup Environment diff --git a/.github/workflows/troubleshooting.yml b/.github/workflows/troubleshooting.yml index d58e0f2aa1..4554ddedf7 100644 --- a/.github/workflows/troubleshooting.yml +++ b/.github/workflows/troubleshooting.yml @@ -12,7 +12,7 @@ jobs: os: [ ubuntu-latest ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/cache@v2 with: path: | diff --git a/docs/pages/pmd/userdocs/tools/java-api.md b/docs/pages/pmd/userdocs/tools/java-api.md index 0deb99a596..36ebb017ea 100644 --- a/docs/pages/pmd/userdocs/tools/java-api.md +++ b/docs/pages/pmd/userdocs/tools/java-api.md @@ -66,7 +66,7 @@ public class PmdExample { public static void main(String[] args) { PMDConfiguration configuration = new PMDConfiguration(); configuration.setInputPaths("/home/workspace/src/main/java/code"); - configuration.setRuleSets("rulesets/java/quickstart.xml"); + configuration.addRuleSet("rulesets/java/quickstart.xml"); configuration.setReportFormat("xml"); configuration.setReportFile("/home/workspace/pmd-report.xml"); @@ -85,7 +85,7 @@ You can also provide your own custom renderers. ```java PMDConfiguration configuration = new PMDConfiguration(); configuration.setMinimumPriority(RulePriority.MEDIUM); - configuration.setRuleSets("rulesets/java/quickstart.xml"); + configuration.addRuleSet("rulesets/java/quickstart.xml"); ``` 2. Then we configure, which paths to analyze: @@ -166,7 +166,6 @@ import java.nio.file.Paths; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.RulePriority; -import net.sourceforge.pmd.RuleSetLoader; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.XMLRenderer; @@ -176,7 +175,7 @@ public class PmdExample2 { public static void main(String[] args) throws IOException { PMDConfiguration configuration = new PMDConfiguration(); configuration.setMinimumPriority(RulePriority.MEDIUM); - configuration.setRuleSets("rulesets/java/quickstart.xml"); + configuration.addRuleSet("rulesets/java/quickstart.xml"); configuration.setInputPaths("/home/workspace/src/main/java/code"); @@ -191,7 +190,7 @@ public class PmdExample2 { try (PmdAnalysis pmd = PmdAnalysis.create(configuration)) { // optional: add more rulesets - pmd.addRuleSet(RuleSetLoader.fromPmdConfig(configuration).loadFromResource("custom-ruleset.xml")); + pmd.addRuleSet(pmd.newRuleSetLoader().loadFromResource("custom-ruleset.xml")); // optional: add more files pmd.files().addFile(Paths.get("src", "main", "more-java", "ExtraSource.java")); // optional: add more renderers diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 59543c4dce..31b9997389 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -58,6 +58,8 @@ The CLI itself remains compatible, if you run PMD via command-line, no action is * apex-performance * [#3773](https://github.com/pmd/pmd/pull/3773): \[apex] EagerlyLoadedDescribeSObjectResult false positives with SObjectField.getDescribe() +* core + * [#3299](https://github.com/pmd/pmd/issues/3299): \[core] Deprecate system properties of PMDCommandLineInterface ### API Changes @@ -76,6 +78,9 @@ The CLI itself remains compatible, if you run PMD via command-line, no action is {% jdoc core::PMDConfiguration#addRuleSet(java.lang.String) %}, and {% jdoc core::PMDConfiguration#getRuleSetPaths() %}. * Several members of {% jdoc test::cli.BaseCLITest %} have been deprecated with replacements. +* Several members of {% jdoc core::cli.PMDCommandLineInterface %} have been explicitly deprecated. + The whole class however was deprecated long ago already with 6.30.0. It is internal API and should + not be used. #### Experimental APIs diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java index 7f9cf8a0d9..1b74fa5ab8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -50,7 +50,7 @@ import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter; * config.setInputPaths("src/main/java"); * config.prependClasspath("target/classes"); * config.setMinimumPriority(RulePriority.HIGH); - * config.setRuleSets("rulesets/java/quickstart.xml"); + * config.addRuleSet("rulesets/java/quickstart.xml"); * config.setReportFormat("xml"); * config.setReportFile("target/pmd-report.xml"); * @@ -127,8 +127,7 @@ public final class PmdAnalysis implements AutoCloseable { FileCollectionUtil.collectFiles(config, pmd.files()); if (config.getReportFormat() != null) { - Renderer renderer = config.createRenderer(); - renderer.setReportFile(config.getReportFile()); + Renderer renderer = config.createRenderer(true); pmd.addRenderer(renderer); }