Merge pull request #4000 from adangel:fix-cli-file-list-3999

[core] Fix cli when only --file-list is used #4000
This commit is contained in:
Andreas Dangel
2022-06-13 18:27:45 +02:00
3 changed files with 16 additions and 1 deletions

View File

@ -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)

View File

@ -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());

View File

@ -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());
}
}