Class LineEndingCheck

All Implemented Interfaces:
Configurable, Contextualizable, FileSetCheck

Checks whether the files have a specific line ending (LF or CRLF).

Files containing mixed line endings may produce multiple violations, one for each line that does not match the configured line ending.

Notes: This check treats each line independently and reports violations per line.

Since:
12.4.0
  • Field Details

  • Constructor Details

  • Method Details

    • processFiltered

      protected void processFiltered(File file, FileText fileText)
      Description copied from class: AbstractFileSetCheck
      Called to process a file that matches the specified file extensions.
      Specified by:
      processFiltered in class AbstractFileSetCheck
      Parameters:
      file - the file to be processed
      fileText - the contents of the file.
    • setLineEnding

      public void setLineEnding(String ending)
      Setter to set lineEnding.
      Parameters:
      ending - string of value LF or CRLF
      Since:
      12.3.0
    • readAndCheckFile

      private void readAndCheckFile(File file) throws IOException
      Reads the given file and checks its line endings against the configured line ending option.
      Parameters:
      file - the file to be processed
      Throws:
      IOException - if an I/O error occurs while reading the file
    • checkLfLineEndings

      private void checkLfLineEndings(byte... content)
      Checks that the file content uses LF line endings.
      Parameters:
      content - the file content as a byte array
    • checkCrlfLineEndings

      private void checkCrlfLineEndings(byte... content)
      Checks that the file content uses CRLF line endings.
      Parameters:
      content - the file content as a byte array