This SBT plug-in enables you to analyze your code with the help of the great PMD Copy/Paste Detector tool. It defines a cpd
sbt action for that purpose.
For SBT 0.13, you've basically got to add the following to your project's build.sbt
file:
import de.johoop.cpd4sbt.CopyPasteDetector._
cpdSettings
Also, you have to add the plugin dependency to your project's ./project/plugins.sbt
or the global .sbt/project/build.sbt
:
addSbtPlugin("de.johoop" % "cpd4sbt" % "1.1.5")
The settings specified below are still mostly valid, but they're now specified using the new settings system of SBT 0.13.
- 1.1.5
- Added settings for the CPD command line switches
ignore-annotations
,ignore-literals
,ignore-identifiers
,skip-duplicate-files
andskip-lexical-errors
- Added
cs
andplsql
languages (and fixed a typo) - Added option to print the CPD report to the console
- Added settings for the CPD command line switches
(see also the CPD documentation)
- Description: Selects the output format for the CPD report. Requires to import
import de.johoop.cpd4sbt._
. - Accepts:
ReportType.{Simple, XML, CSV, VS}
- Default:
ReportType.Xml
- Description: Output path for CPD reports.
- Accepts: any
sbt.Path
- Default:
outputPath / "cpd"
- Description: Name of the report file to generate.
- Accepts: any legal filename
- Default:
"cpd.xml"
- Description: Selects the output type for the CPD report. Requires to import
import de.johoop.cpd4sbt._
. - Accepts:
OutputType.{File, Console}
- Default:
OutputType.File
- Description: Language to analyze. - If you want Scala specifically, you still need to extend the CPD tokenizers! Otherwise, choosing Scala will default to the "AnyLanguage" tokenizer
- Accepts:
Language.{Java, C, CPP, CS, PHP, Ruby, Fortran, ECMAScript, JavaScript, JSP, PLSQL, Scala}
- Default:
Language.Scala
- Description: Maximum amount of memory to allow for CPD (in MB).
- Accepts: any reasonable amount of memory as an integer value
- Default:
512
- Description: Minimum number of tokens of potential duplicates.
- Accepts: A positive
Int
- Default:
100
- Description: Source file encoding.
- Accepts: String representations of valid encodings.
- Default:
"utf-8"
- Description: Output file encoding.
- Accepts: String representations of valid encodings.
- Default:
"utf-8"
- Description: Paths of the source files to analyze.
- Accepts: A
List
ofPath
s - Default:
List(mainSourcePath)
.
- Description: Ignore multiple copies of files of the same name and length in comparison.
- Accepts:
Boolean
- Default:
false
- Description: Skip files which can't be tokenized due to invalid characters instead of aborting.
- Accepts:
Boolean
- Default:
false
- Description: Ignore literal value differences when evaluating a duplicate block.
- Accepts:
Boolean
- Default:
false
- Description: Ignore identifier name differences when evaluating a duplicate block.
- Accepts:
Boolean
- Default:
false
- Description: Ignore language annotations when evaluating a duplicate block.
- Accepts:
Boolean
- Default:
false
Many thanks to corux and Matic Potočnik for their awesome contributions!
This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html