com.puppycrawl.tools.checkstyle.checks.duplicates
Class StrictDuplicateCodeCheck
- Configurable, Contextualizable, FileSetCheck
public final class StrictDuplicateCodeCheck
Checks for duplicate code.
There are many approaches for detecting duplicate code. Some involve
parsing a file of a programming language and analyzing the source trees
of all files. This is a very powerful approach for a specific programming
language (such as Java), as it can potentially even detect duplicate code
where linebreaks have been changed, variables have been renamed, etc.
This copy and paste detection implementation works differently.
It cannot detect copy and paste code where the author deliberately
tries to hide his copy+paste action. Instead it focusses on the standard
corporate problem of reuse by copy and paste. Usually this leaves linebreaks
and variable names intact. Since we do not need to analyse a parse tree
our tool is not tied to a particular programming language.
Simian
is a very good commercial duplicate code detection tool. It comes with
a Checkstyle module, so we encourage all users to evaluate Simian
as an alternative to this check.
- Lars Kühne
void | process(File[] aFiles)
|
void | setBasedir(String aBasedir)
|
void | setMin(int aMin) - Sets the minimum number of lines that must be equivalent
before the check complains.
|
destroy , filter , fireErrors , getCharset , getMessageCollector , getMessageDispatcher , log , log , setCharset , setFileExtensions , setMessageDispatcher |
getMessageBundle , getSeverity , getSeverityLevel , log , log , log , log , log , log , log , log , log , log , log , setSeverity |
StrictDuplicateCodeCheck
public StrictDuplicateCodeCheck()
Creates a new instance of this class.
setBasedir
public void setBasedir(String aBasedir)
aBasedir
- the base directory to strip off in filenames
setMin
public void setMin(int aMin)
Sets the minimum number of lines that must be equivalent
before the check complains.
aMin
- the number of lines that must be equal before
triggering a 'duplicate code' message.