Sha256: 443a9442248ed010c8766122d4926b4c9a15b747ef7510de0f40617b9c11f3c6

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

require 'pre-commit/checks/shell'

module PreCommit
  module Checks
    class Checkstyle < Shell
      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

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

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

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

      def alternate_config_file
        support_path('sun_checks.xml')
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pre-commit-checkstyle-0.0.1 lib/plugins/pre_commit/checks/checkstyle.rb