Sha256: c01a899b4809d78edf7ac768d29e1f8961fcfb11555aacbfaca31f6aa51925b0
Contents?: true
Size: 731 Bytes
Versions: 19
Compression:
Stored size: 731 Bytes
Contents
# frozen_string_literal: true module Overcommit::Hook::PreCommit # Runs `checkstyle` against any modified Java files. # # @see http://checkstyle.sourceforge.net/ class JavaCheckstyle < Base MESSAGE_REGEX = /^(\[(?<type>[^\]]+)\]\s+)?(?<file>(?:\w:)?[^:]+):(?<line>\d+)/ MESSAGE_TYPE_CATEGORIZER = lambda do |type| %w[WARN INFO].include?(type.to_s) ? :warning : :error end def run result = execute(command, args: applicable_files) output = result.stdout.chomp # example message: # path/to/file.java:3:5: Error message extract_messages( output.split("\n").grep(MESSAGE_REGEX), MESSAGE_REGEX, MESSAGE_TYPE_CATEGORIZER ) end end end
Version data entries
19 entries across 19 versions & 2 rubygems