Sha256: 6688b3364f88592c6ed135f3ee6cab88377ea585415e672beba7bbd2d985d5a4
Contents?: true
Size: 738 Bytes
Versions: 9
Compression:
Stored size: 738 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+)/.freeze 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
9 entries across 9 versions & 2 rubygems