forked from phoedos/pmd
Add "--ignore-usings" parameter to CPD commandline for C#
This commit is contained in:
@ -67,6 +67,9 @@ public class CPDConfiguration extends AbstractConfiguration {
|
||||
@Parameter(names = "--ignore-annotations", description = "Ignore language annotations when comparing text", required = false)
|
||||
private boolean ignoreAnnotations;
|
||||
|
||||
@Parameter(names = "--ignore-usings", description = "Ignore using directives in C#", required = false)
|
||||
private boolean ignoreUsings;
|
||||
|
||||
@Parameter(names = "--skip-lexical-errors", description = "Skip files which can't be tokenized due to invalid characters instead of aborting CPD", required = false)
|
||||
private boolean skipLexicalErrors = false;
|
||||
|
||||
@ -224,6 +227,11 @@ public class CPDConfiguration extends AbstractConfiguration {
|
||||
} else {
|
||||
properties.remove(Tokenizer.IGNORE_ANNOTATIONS);
|
||||
}
|
||||
if (configuration.isIgnoreUsings()) {
|
||||
properties.setProperty(Tokenizer.IGNORE_USINGS, "true");
|
||||
} else {
|
||||
properties.remove(Tokenizer.IGNORE_USINGS);
|
||||
}
|
||||
properties.setProperty(Tokenizer.OPTION_SKIP_BLOCKS, Boolean.toString(!configuration.isNoSkipBlocks()));
|
||||
properties.setProperty(Tokenizer.OPTION_SKIP_BLOCKS_PATTERN, configuration.getSkipBlocksPattern());
|
||||
configuration.getLanguage().setProperties(properties);
|
||||
@ -335,6 +343,14 @@ public class CPDConfiguration extends AbstractConfiguration {
|
||||
this.ignoreAnnotations = ignoreAnnotations;
|
||||
}
|
||||
|
||||
public boolean isIgnoreUsings() {
|
||||
return ignoreUsings;
|
||||
}
|
||||
|
||||
public void setIgnoreUsings(boolean ignoreUsings) {
|
||||
this.ignoreUsings = ignoreUsings;
|
||||
}
|
||||
|
||||
public boolean isSkipLexicalErrors() {
|
||||
return skipLexicalErrors;
|
||||
}
|
||||
|
@ -9,6 +9,13 @@ public interface Tokenizer {
|
||||
String IGNORE_LITERALS = "ignore_literals";
|
||||
String IGNORE_IDENTIFIERS = "ignore_identifiers";
|
||||
String IGNORE_ANNOTATIONS = "ignore_annotations";
|
||||
|
||||
/**
|
||||
* Ignore using directives in C#.
|
||||
* The default value is <code>false</code>.
|
||||
*/
|
||||
String IGNORE_USINGS = "ignore_usings";
|
||||
|
||||
/**
|
||||
* Enables or disabled skipping of blocks like a pre-processor.
|
||||
* It is a boolean property.
|
||||
|
@ -20,8 +20,6 @@ import org.apache.commons.lang3.RandomStringUtils;
|
||||
*/
|
||||
public class CsTokenizer implements Tokenizer {
|
||||
|
||||
public static final String IGNORE_USINGS = "ignore_usings";
|
||||
|
||||
private boolean ignoreUsings = false;
|
||||
|
||||
public void setProperties(Properties properties) {
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
**Feature Request and Improvements:**
|
||||
|
||||
* CPD: New command line parameter `--ignore-usings`: Ignore using directives in C# when comparing text.
|
||||
|
||||
**New/Modified/Deprecated Rules:**
|
||||
|
||||
**Pull Requests:**
|
||||
|
@ -147,6 +147,12 @@ The options "minimum-tokens" and "files" are the two required options; there are
|
||||
<td>no</td>
|
||||
<td>java</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>--ignore-usings</td>
|
||||
<td>Ignore using directives in C# when comparing text</td>
|
||||
<td>no</td>
|
||||
<td>C#</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>--no-skip-blocks</td>
|
||||
<td>Do not skip code blocks marked with --skip-blocks-pattern (e.g. #if 0 until #endif)</td>
|
||||
|
Reference in New Issue
Block a user