Class: PreCommit::Checks::Checkstyle

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descriptionObject



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

def self.description
  'Runs coffeelint to detect errors'
end

Instance Method Details

#alternate_config_fileObject



27
28
29
# File 'lib/plugins/pre_commit/checks/checkstyle.rb', line 27

def alternate_config_file
  support_path('sun_checks.xml')
end

#call(staged_files) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/plugins/pre_commit/checks/checkstyle.rb', line 6

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

  args = (jar_flag + config_file_flag + staged_files).join(' ')

  execute("java #{args}")
end

#config_file_flagObject



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

def config_file_flag
  config_file ? ['-c', config_file] : []
end

#jar_flagObject



15
16
17
# File 'lib/plugins/pre_commit/checks/checkstyle.rb', line 15

def jar_flag
  ['-jar', support_path('checkstyle-5.7-all.jar')]
end

#support_path(file) ⇒ Object



19
20
21
# File 'lib/plugins/pre_commit/checks/checkstyle.rb', line 19

def support_path(file)
  File.expand_path("../../../../pre-commit/support/checkstyle/#{file}", __FILE__)
end