Sha256: 1cac6bc0eab6147287cced3d98d4f48559c05ac9da652d4cd37cc1815368c104

Contents?: true

Size: 549 Bytes

Versions: 2

Compression:

Stored size: 549 Bytes

Contents

module Overcommit::Hook::PreCommit
  # Runs `checkstyle` against any modified Java files.
  #
  # @see http://checkstyle.sourceforge.net/
  class JavaCheckstyle < Base
    MESSAGE_REGEX = /^(?<file>[^:]+):(?<line>\d+)/

    def run
      result = execute(command + applicable_files)
      output = result.stdout.chomp
      return :pass if result.success?

      # example message:
      #   path/to/file.java:3:5: Error message
      extract_messages(
        output.split("\n").grep(MESSAGE_REGEX),
        MESSAGE_REGEX
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
overcommit-0.27.0 lib/overcommit/hook/pre_commit/java_checkstyle.rb
overcommit-0.26.0 lib/overcommit/hook/pre_commit/java_checkstyle.rb