Sha256: e722b8a7f407cb4f3b258bf2c7a10c2caa8288fb01a2a704c9f3fab1892b6e8b

Contents?: true

Size: 1.95 KB

Versions: 9

Compression:

Stored size: 1.95 KB

Contents

# frozen_string_literal: true

require 'avm/eac_generic_base0/sources/base'
require 'eac_ruby_utils/core_ext'

module Avm
  module EacRubyBase1
    module Sources
      class Base < ::Avm::EacGenericBase0::Sources::Base
        class RubocopCommand
          acts_as_immutable
          immutable_accessor :ignore_parent_exclusion, :autocorrect, :autocorrect_all,
                             type: :boolean
          immutable_accessor :file, type: :array
          common_constructor :source
          delegate :execute, :execute!, :system, :system!, to: :bundle_command

          # @return [Enumerable]
          def immutable_constructor_args
            [source]
          end

          # @return [Gemspec::Version]
          def version
            @version ||= ::Gemspec::Version.new(
              source.bundle('exec', 'rubocop', '--version').execute!
            )
          end

          private

          # @return [String]
          def autocorrect_option
            '--auto-correct'
          end

          # @return [String]
          def autocorrect_all_option
            '--auto-correct-all'
          end

          # @return [String]
          def ignore_parent_exclusion_option
            '--ignore-parent-exclusion'
          end

          # @return [Avm::EacRubyBase1::Sources::Base::BundleCommand]
          def bundle_command
            source.bundle(*bundle_command_args)
          end

          # @return [Array<String>]
          def bundle_command_args
            %w[exec rubocop] + rubocop_command_args
          end

          # @return [Array<String>]
          def rubocop_command_args
            r = ['--config', source.rubocop_config_path]
            r << ignore_parent_exclusion_option if ignore_parent_exclusion?
            if autocorrect_all?
              r << autocorrect_all_option
            elsif autocorrect?
              r << autocorrect_option
            end
            r + files
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
eac_tools-0.82.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb
eac_tools-0.81.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb
avm-eac_ruby_base1-0.33.0 lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb
eac_tools-0.80.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb
eac_tools-0.79.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb
avm-eac_ruby_base1-0.32.1 lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb
eac_tools-0.78.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb
avm-eac_ruby_base1-0.32.0 lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb
eac_tools-0.77.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb