Class: PreCommit::Checks::Checkstyle

Inherits:
Shell
  • Object
show all
Defined in:
lib/plugins/pre_commit/checks/checkstyle.rb

Overview

Plugin implementation for pre-commit gem

It provides a java checkstyle validation using checkstyle.jar for details see: lib/pre_commit/support/checkstyle

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descriptionObject



30
31
32
# File 'lib/plugins/pre_commit/checks/checkstyle.rb', line 30

def self.description
  'Runs Checkstyle linter for java code.'
end

Instance Method Details

#call(staged_files) ⇒ Object

Function called after pre-commit execution this method receive the staged_files from git

Parameters:

  • Standard (String)

    git ouput with staged files



22
23
24
25
26
27
28
# File 'lib/plugins/pre_commit/checks/checkstyle.rb', line 22

def call(staged_files)
  staged_files = staged_files.grep(/\.java$/)
  return if staged_files.empty?

  output = execute(args(staged_files))
  format(extract(output))
end