public class CpdExtension
extends org.gradle.api.plugins.quality.CodeQualityExtension
The sample below shows various configuration options:
apply plugin: 'cpd'
cpd {
encoding = 'UTF-8'
ignoreAnnotations = true
language = 'java'
minimumTokenCount = 20
}
CpdPlugin| Constructor and Description |
|---|
CpdExtension() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getEncoding()
The character set encoding (e.g., UTF-8) to use when reading the source code files but also when producing the report; defaults to
System.getProperty("file.encoding"). |
java.lang.String |
getLanguage()
Flag to select the appropriate language; defaults to
'java'. |
int |
getMinimumTokenCount()
A positive integer indicating the minimum token count to trigger a CPD match; defaults to
50. |
java.lang.String |
getSkipBlocksPattern()
CConfigures the pattern, to find the blocks to skip if enabled using
skipBlocks. |
boolean |
isIgnoreAnnotations()
Ignore annotations because more and more modern frameworks use annotations on classes and methods which can be very redundant and
causes false positives; defaults to
false. |
boolean |
isIgnoreIdentifiers()
Option if CPD should ignore identifiers differences, i.e. variable names, methods names, and so forth, when evaluating a duplicate
block; defaults to
false. |
boolean |
isIgnoreLiterals()
Option if CPD should ignore literal value differences when evaluating a duplicate block; defaults to
false. |
boolean |
isSkipBlocks()
Enables or disables skipping of blocks configured by
skipBlocksPattern like a pre-processor; defaults to true. |
boolean |
isSkipDuplicateFiles()
Ignore multiple copies of files of the same name and length in comparison; defaults to
false. |
boolean |
isSkipLexicalErrors()
Skip files which cannot be tokenized due to invalid characters instead of aborting CPD; defaults to
false. |
void |
setEncoding(java.lang.String encoding) |
void |
setIgnoreAnnotations(boolean ignoreAnnotations) |
void |
setIgnoreIdentifiers(boolean ignoreIdentifiers) |
void |
setIgnoreLiterals(boolean ignoreLiterals) |
void |
setLanguage(java.lang.String language) |
void |
setMinimumTokenCount(int minimumTokenCount) |
void |
setSkipBlocks(boolean skipBlocks) |
void |
setSkipBlocksPattern(java.lang.String skipBlocksPattern) |
void |
setSkipDuplicateFiles(boolean skipDuplicateFiles) |
void |
setSkipLexicalErrors(boolean skipLexicalErrors) |
public java.lang.String getEncoding()
System.getProperty("file.encoding").
Example: encoding = UTF-8
public void setEncoding(java.lang.String encoding)
public boolean isIgnoreAnnotations()
false.
Note: if this option is recognized depends on the used language and its tokenizer.
Example: ignoreAnnotations = true
public void setIgnoreAnnotations(boolean ignoreAnnotations)
public boolean isIgnoreIdentifiers()
false.
Note: if this option is recognized depends on the used language and its tokenizer.
Example: ignoreIdentifiers = true
public void setIgnoreIdentifiers(boolean ignoreIdentifiers)
public boolean isIgnoreLiterals()
false. This means e.g.
that foo=42; and foo=43; will be seen as equivalent.
Note: if this option is recognized depends on the used language and its tokenizer.
Example: ignoreLiterals = true
public void setIgnoreLiterals(boolean ignoreLiterals)
public java.lang.String getLanguage()
'java'.
Example: language = 'java'
public void setLanguage(java.lang.String language)
public int getMinimumTokenCount()
50.
Example: minimumTokenCount = 25
public void setMinimumTokenCount(int minimumTokenCount)
public boolean isSkipDuplicateFiles()
false.
Example: skipDuplicateFiles = true
public void setSkipDuplicateFiles(boolean skipDuplicateFiles)
public boolean isSkipLexicalErrors()
false.
Example: skipLexicalErrors = true
public void setSkipLexicalErrors(boolean skipLexicalErrors)
public boolean isSkipBlocks()
skipBlocksPattern like a pre-processor; defaults to true.
Example: skipBlocks = false
skipBlocksPatternpublic void setSkipBlocks(boolean skipBlocks)
public java.lang.String getSkipBlocksPattern()
skipBlocks. It is a String property and
contains of two parts, separated by '|'. The first part is the start pattern, the second part is the ending pattern. defaults
to '#if 0|#endif' (which should be the same as Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN).
Example: skipBlocksPattern = '#include <|>'
skipBlockspublic void setSkipBlocksPattern(java.lang.String skipBlocksPattern)