Class: Overcommit::Hook::PreCommit::Scalastyle
- Defined in:
- lib/overcommit/hook/pre_commit/scalastyle.rb
Overview
Runs ‘scalastyle` against any modified Scala files.
Constant Summary collapse
- MESSAGE_REGEX =
/ ^(?<type>error|warning)\s file=(?<file>(?:\w:)?.+)\s message=.+\s* (line=(?<line>\d+))? /x
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#applicable_files, #command, #description, #enabled?, #execute, #execute_in_background, #flags, #in_path?, #included_files, #initialize, #name, #parallelize?, #processors, #quiet?, #required?, #required_executable, #required_libraries, #run?, #run_and_transform, #skip?
Constructor Details
This class inherits a constructor from Overcommit::Hook::Base
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/overcommit/hook/pre_commit/scalastyle.rb', line 15 def run result = execute(command, args: applicable_files) output = result.stdout.chomp + result.stderr.chomp = output.split("\n").grep(MESSAGE_REGEX) return [:fail, output] unless result.success? || .any? # example message: # error file=/path/to/file.scala message=Error message line=1 column=1 ( , MESSAGE_REGEX, lambda { |type| type.to_sym } ) end |