diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 6726bc0659..8216e8aeeb 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -15,6 +15,8 @@ This is a {{ site.pmd.release_type }} release. ### New and noteworthy ### Fixed Issues +* core + * [#3999](https://github.com/pmd/pmd/issues/3999): \[cli] All files are analyzed despite parameter `--file-list` * java-design * [#3981](https://github.com/pmd/pmd/issues/3981): \[java] ImmutableField reports fields annotated with @Value (Spring) * [#3998](https://github.com/pmd/pmd/issues/3998): \[java] ImmutableField reports fields annotated with @Captor (Mockito) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java b/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java index 18c1da8a28..6b1888db54 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java @@ -224,7 +224,7 @@ public class PMDParameters { */ public PMDConfiguration toConfiguration() { PMDConfiguration configuration = new PMDConfiguration(); - configuration.setInputPaths(this.getSourceDir()); + configuration.setInputPaths(this.getInputPaths()); configuration.setInputFilePath(this.getFileListPath()); configuration.setIgnoreFilePath(this.getIgnoreListPath()); configuration.setInputUri(this.getUri()); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDCommandLineInterfaceTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDCommandLineInterfaceTest.java index 5923717395..897884da7a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDCommandLineInterfaceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDCommandLineInterfaceTest.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.cli; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Assert; @@ -100,4 +102,15 @@ public class PMDCommandLineInterfaceTest { Assert.assertNotNull(PMDCommandLineInterface.buildUsageText()); } + @Test + public void testOnlyFileListOption() { + PMDParameters params = new PMDParameters(); + String[] args = {"--file-list", "pmd.filelist", "-f", "text", "-R", "rulesets/java/quickstart.xml", "--no-cache", }; + PMDCommandLineInterface.extractParameters(params, args, "PMD"); + + PMDConfiguration config = params.toConfiguration(); + assertEquals("pmd.filelist", config.getInputFilePath()); + assertTrue(config.getAllInputPaths().isEmpty()); // no additional input paths + assertNull(config.getInputPaths()); + } }