[cs] Added option to exclude C# using directives from CPD analysis #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some of our customers complained that their duplicated code was to high because because a lot of files have duplicate using directives. For example:
This duplicates cannot be prevented, because each file needs to specify its dependencies, so the 'using' directives should be ignored during duplicated code analysis. To fix this I added a option called 'ignore_usings' to the CPD CS tokenizer, which can be added by specifying the following system property on the CPD command line: '-Dignore_usings=true'.
As you can see in the diff, the 'using' directive tokens are not omitted from the token stream but replaced by a random token. This is done to prevent that we get duplication blocks that spans over the using directives. (Starts before and end afterwards.)
As you can see this pull request also contains an older commit of us. ('Extended Objective-C grammar to accept Unicode characters in identifiers' ) This commit was already merged in the 'pmd/5.4.x' branch, but unfortunately we cannot upgrade to PMD 5.4 because a lot of our customers still use Java 1.6.
If both commit are merged and released in PMD 5.3, we can use an official PMD release again instead of our own builds. Please let me know if there are changes needed before this pull request can be accepted.