You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Description:
Will CPD's "--exclude" option support regular expression some day? Using regular expression to skip paths is so much more effective than listing all the folders I want to exclude.
For instance, a large JavaScript project can include tons of *.min.js files in different directories. We won't want these files to be scanned. Using regular expression for "--exclude" argument can easily solve this problem. Otherwise, we have to find all the *.min.js files first, then combine them into a long argument for the cpd command.
I don't think regular expressions would be a good fit here, but maybe using Ant paths would be better… it tells very explicitly how to glob and what to leave out, it's flexible, but not as flexible / obscure as regexps, and it's going to require a lot less escaping.
What do you think?
Another problem I encountered here is: the "--exclude " option does not support directories with special characters, such as Chinese.
I tried
--exclude /data/iccen/test_exclude/core-js/test1- 副本.js
, and the file is still scanned :(
[core]CPD: supporting regular expression for "--exclude" option
[core] CPD: supporting regular expression for "--exclude" option
Jan 13, 2023
This would be really helpful for languages where nominally excluded files, like tests, are intermixed with code (Go, for example). Unfortunately
--exclude *_test.go
(or variations) simply results in
[main] WARN net.sourceforge.pmd.cli - No such file *_test.go
.
The best option to dynamically find code files is something like:
find . -type f -name "*.go" ! -name "*_test.go" > go_files.txt
pmd cpd --file-list="go_files.txt" --language="go"
It was actually pretty easy to exclude both individual files and full paths with a specific string in the from the report:
find . -type f -name "*.php" ! -name "*settings.php" ! -name "*settings*php" ! -name "_ping.php" ! -name "*Test.php" -not -path "*tests*" > non-test-php-files.txt
pmd cpd --minimum-tokens 100 -f csv -l php -z . --file-list non-test-php-files.txt > code-all-duplicates.csv