com.puppycrawl.tools.checkstyle.checks
Class NewlineAtEndOfFileCheck

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended bycom.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended bycom.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
              extended bycom.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck
All Implemented Interfaces:
Configurable, Contextualizable, FileSetCheck

public class NewlineAtEndOfFileCheck
extends AbstractFileSetCheck

Checks that there is a newline at the end of each file.

An example of how to configure the check is:

 <module name="NewlineAtEndOfFile"/>

This will check against the platform-specific default line separator.

It is also possible to enforce the use of a specific line-separator across platforms, with the 'lineSeparator' property:

 <module name="NewlineAtEndOfFile">
   <property name="lineSeparator" value="lf"/>
 </module>

Valid values for the 'lineSeparator' property are 'system' (system default), 'crlf' (windows), 'cr' (mac) and 'lf' (unix).

Version:
1.0
Author:
Christopher Lenz, lkuehne

Constructor Summary
NewlineAtEndOfFileCheck()
           
 
Method Summary
 void process(java.io.File[] aFiles)
          Processes a set of files and fires errors to the MessageDispatcher.
 void setLineSeparator(java.lang.String aLineSeparator)
          Sets the line separator to one of 'crlf', 'lf' or 'cr'.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
destroy, filter, fireErrors, getCharset, getMessageCollector, getMessageDispatcher, log, log, setCharset, setFileExtensions, setMessageDispatcher
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, 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

NewlineAtEndOfFileCheck

public NewlineAtEndOfFileCheck()
Method Detail

process

public void process(java.io.File[] aFiles)
Description copied from interface: FileSetCheck
Processes a set of files and fires errors to the MessageDispatcher. The file set to process might contain files that are not interesting to the FileSetCheck. Such files should be ignored, no error message should be fired for them. For example a FileSetCheck that checks java files should ignore html or properties files. Once processiong is done, it is highly recommended to call for the destroy method to close and remove the listeners.

Parameters:
aFiles - the files to be audited.
See Also:
FileSetCheck.process(java.io.File[])

setLineSeparator

public void setLineSeparator(java.lang.String aLineSeparator)
Sets the line separator to one of 'crlf', 'lf' or 'cr'.

Parameters:
aLineSeparator - The line separator to set
Throws:
java.lang.IllegalArgumentException - If the specified line separator is not one of 'crlf', 'lf' or 'cr'

Back to the Checkstyle Home Page