com.puppycrawl.tools.checkstyle.checks.duplicates
Class StrictDuplicateCodeCheck

java.lang.Object
  extended by com.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended by com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended by com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
              extended by com.puppycrawl.tools.checkstyle.checks.duplicates.StrictDuplicateCodeCheck
All Implemented Interfaces:
Configurable, Contextualizable, FileSetCheck

public final class StrictDuplicateCodeCheck
extends AbstractFileSetCheck

Performs a line-by-line comparison of all code lines and reports duplicate code if a sequence of lines differs only in indentation. All import statements in Java code are ignored, any other line - including javadoc, whitespace lines between methods, etc. - is considered (which is why the check is called strict).

Author:
Lars Kühne

Constructor Summary
StrictDuplicateCodeCheck()
          Creates a new instance of this class.
 
Method Summary
 void beginProcessing(java.lang.String aCharset)
          Called when about to be called to process a set of files.
 void finishProcessing()
          Called when all the files have been processed.
protected  void processFiltered(java.io.File aFile, java.util.List<java.lang.String> aLines)
          Called to process a file that matches the specified file extensions.
 void setBasedir(java.lang.String aBasedir)
           
 void setMin(int aMin)
          Sets the minimum number of lines that must be equivalent before the check complains.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
destroy, fireErrors, getMessageCollector, getMessageDispatcher, init, log, log, process, setFileExtensions, setMessageDispatcher
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.puppycrawl.tools.checkstyle.api.Configurable
configure
 
Methods inherited from interface com.puppycrawl.tools.checkstyle.api.Contextualizable
contextualize
 

Constructor Detail

StrictDuplicateCodeCheck

public StrictDuplicateCodeCheck()
Creates a new instance of this class.

Method Detail

setMin

public void setMin(int aMin)
Sets the minimum number of lines that must be equivalent before the check complains.

Parameters:
aMin - the number of lines that must be equal before triggering a 'duplicate code' message.

setBasedir

public void setBasedir(java.lang.String aBasedir)
Parameters:
aBasedir - the base directory to strip off in filenames

beginProcessing

public void beginProcessing(java.lang.String aCharset)
Description copied from class: AbstractFileSetCheck
Called when about to be called to process a set of files.

Specified by:
beginProcessing in interface FileSetCheck
Overrides:
beginProcessing in class AbstractFileSetCheck
Parameters:
aCharset - the character set used to read the files.

processFiltered

protected void processFiltered(java.io.File aFile,
                               java.util.List<java.lang.String> aLines)
Description copied from class: AbstractFileSetCheck
Called to process a file that matches the specified file extensions.

Specified by:
processFiltered in class AbstractFileSetCheck
Parameters:
aFile - the file to be processed
aLines - an immutable list of the contents of the file.

finishProcessing

public void finishProcessing()
Description copied from class: AbstractFileSetCheck
Called when all the files have been processed. This is the time to perform any checks that need to be done across a set of files. In this method, the implementation is responsible for the logging of messages.

Specified by:
finishProcessing in interface FileSetCheck
Overrides:
finishProcessing in class AbstractFileSetCheck


Copyright © 2001-2011. All Rights Reserved.