Sha256: 4a40d2b70c8f91d998aa99054e18be0033f313dc79115b0cb6dec617f781da1c

Contents?: true

Size: 1.02 KB

Versions: 15

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # A scaffold for concrete forces.
    class Force
      # @api private
      class HookError < StandardError
        attr_reader :joining_cop

        def initialize(joining_cop)
          super
          @joining_cop = joining_cop
        end
      end

      attr_reader :cops

      def self.all
        @all ||= []
      end

      def self.inherited(subclass)
        super
        all << subclass
      end

      def self.force_name
        name.split('::').last
      end

      def initialize(cops)
        @cops = cops
      end

      def name
        self.class.force_name
      end

      def run_hook(method_name, *args)
        cops.each do |cop|
          next unless cop.respond_to?(method_name)

          cop.public_send(method_name, *args)
        rescue StandardError
          raise HookError, cop
        end
      end

      def investigate(_processed_source)
        # Do custom processing and invoke #run_hook at arbitrary timing.
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
rubocop-1.71.0 lib/rubocop/cop/force.rb
rubocop-1.70.0 lib/rubocop/cop/force.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cop/force.rb
rubocop-1.69.2 lib/rubocop/cop/force.rb
rubocop-1.69.1 lib/rubocop/cop/force.rb
rubocop-1.69.0 lib/rubocop/cop/force.rb
rubocop-1.68.0 lib/rubocop/cop/force.rb
rubocop-1.67.0 lib/rubocop/cop/force.rb
rubocop-1.66.1 lib/rubocop/cop/force.rb
rubocop-1.66.0 lib/rubocop/cop/force.rb
rubocop-1.65.1 lib/rubocop/cop/force.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cop/force.rb
rubocop-1.65.0 lib/rubocop/cop/force.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rubocop-1.64.1/lib/rubocop/cop/force.rb
rubocop-1.64.1 lib/rubocop/cop/force.rb