I'm Trying to run PMD using CMD
pmd -d "C:\refactoring-toy-example" -f csv -R rulesets/java/unusedcode.xml
it return the result on the console but i need the result on a CSV file . how can I do this ?
You can redirect it, but the preferred way is to use the option "-reportfile":
pmd -d "C:\refactoring-toy-example" -f csv -R rulesets/java/unusedcode.xml ^
-reportfile "C:\refactoring-toy-example\pmd-results.csv"
See https://pmd.github.io/latest/pmd_userdocs_cli_reference.html for the full documentation of the command line options.
The advantage of using the reportfile option over redirecting is, that the reportfile then only contains the report, but redirecting the output would also contain log statements during PMD's execution (especially if you redirect stdout+stderr).
Please note, that you are using a deprecated ruleset (unusedcode.xml). Consider having a look at the available rules and create your own ruleset.