Suppress warnings from CPD for C/C++ code

You can define your custom markers for excluding certain blocks from analysis through the --skip-blocks-pattern option.

--skip-blocks-pattern Pattern to find the blocks to skip. Start and End pattern separated by |. Default is #if 0|#endif.

For example the following will ignore blocks between /* SUPPRESS CPD START */ and /* SUPPRESS CPD END */ comments (the comment must occupy a separate line):

$ ./run.sh cpd --minimum-tokens 100 --files /path/to/c/source --language cpp ----skip-blocks-pattern '/* SUPPRESS CPD START */|/* SUPPRESS CPD END */'

Note however, that this will cause the tool perform copy-paste-detection inside code delimited by #if 0/#endif.


After searching through the code of PMD on GitHub, I think I can safely say that this is NOT supported at this point in time (current version being PMD 5.5.0).

A search for CPD-START in their repository, does not show any results within the pmd-cpp directory (see the search results on GitHub).