Class LineEndingCheck

All Implemented Interfaces:
Configurable, Contextualizable, FileSetCheck

Checks whether file uses a specific line-ending sequence (LF, CRLF, or CR).

A violation is reported for each line whose actual line ending does not match the configured one.

Notes: Files containing mixed line endings may produce multiple violations, one for each non-matching line.

Since:
13.3.0
  • Field Details

  • Constructor Details

  • Method Details

    • setLineEnding

      public void setLineEnding(String ending)
      Setter to set lineEnding.
      Parameters:
      ending - string of value LF or CRLF
      Since:
      13.3.0
    • 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.
    • checkLineEndings

      private void checkLineEndings(LineEndingOption expected, byte... content)
      Checks that the file content uses the configured line ending and logs a violation for each line that does not match.
      Parameters:
      expected - the expected line ending
      content - the file content as bytes
    • logIncorrectLineEnding

      private void logIncorrectLineEnding(int line, LineEndingOption wrongLineEnding)
      Logs an incorrect line ending detected at the given line.
      Parameters:
      line - the line number where the issue was found
      wrongLineEnding - the detected incorrect line ending