Class: PreCommit::Checks::Checkstyle
- Inherits:
-
Shell
- Object
- Shell
- PreCommit::Checks::Checkstyle
- Defined in:
- lib/plugins/pre_commit/checks/checkstyle.rb
Class Method Summary collapse
Instance Method Summary collapse
- #alternate_config_file ⇒ Object
- #call(staged_files) ⇒ Object
- #config_file_flag ⇒ Object
- #jar_flag ⇒ Object
- #support_path(file) ⇒ Object
Class Method Details
.description ⇒ Object
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_file ⇒ Object
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_flag ⇒ Object
23 24 25 |
# File 'lib/plugins/pre_commit/checks/checkstyle.rb', line 23 def config_file_flag config_file ? ['-c', config_file] : [] end |
#jar_flag ⇒ Object
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.("../../../../pre-commit/support/checkstyle/#{file}", __FILE__) end |