<commit_before>module ActionController
  class Base
    def respond_with(*resources, &block)
      if self.class.mimes_for_respond_to.empty?
        raise "In order to use respond_with, first you need to declare the formats your " \
              "controller responds to in the class level"
      end

      if collector = retrieve_collector_from_mimes(&block)
        options = resources.size == 1 ? {} : resources.extract_options!

        # Fix spree issues #3531 and #2210 (patch provided by leiyangyou)
        if (defined_response = collector.response) && !Spree::BaseController.spree_responders[self.class.to_s.to_sym].try(:[], action_name.to_sym)
          if action = options.delete(:action)
            render action: action
          else
            defined_response.call
          end
        else
          # The action name is needed for processing
          options[:action_name] = action_name.to_sym
          # If responder is not specified then pass in Spree::Responder
          (options.delete(:responder) || Spree::Responder).call(self, resources, options)
        end
      end
    end
  end
end

module Spree
  module Core
    module ControllerHelpers
      module RespondWith
        extend ActiveSupport::Concern

        included do
          cattr_accessor :spree_responders
          self.spree_responders = {}
        end

        module ClassMethods
          def clear_overrides!
            self.spree_responders = {}
          end

          def respond_override(options={})
            unless options.blank?
              action_name = options.keys.first
              action_value = options.values.first

              if action_name.blank? || action_value.blank?
                raise ArgumentError, "invalid values supplied #{options.inspect}"
              end

              format_name = action_value.keys.first
              format_value = action_value.values.first

              if format_name.blank? || format_value.blank?
                raise ArgumentError, "invalid values supplied #{options.inspect}"
              end

              if format_value.is_a?(Proc)
                options = {action_name.to_sym => {format_name.to_sym => {:success => format_value}}}
              end

              self.spree_responders.deep_merge!(self.name.to_sym => options)
            end
          end<commit_msg>Fix easy rubocop issues, some early returns make the indentation changes<commit_after># frozen_string_literal: true

module ActionController
  class Base
    def respond_with(*resources, &block)
      if self.class.mimes_for_respond_to.empty?
        raise "In order to use respond_with, first you need to declare the formats your " \
              "controller responds to in the class level"
      end

      return unless (collector = retrieve_collector_from_mimes(&block))

      options = resources.size == 1 ? {} : resources.extract_options!

      # Fix spree issues #3531 and #2210 (patch provided by leiyangyou)
      if (defined_response = collector.response) &&
         !Spree::BaseController.spree_responders[self.class.to_s.to_sym].try(:[],
                                                                             action_name.to_sym)
        if action = options.delete(:action)
          render action: action
        else
          defined_response.call
        end
      else
        # The action name is needed for processing
        options[:action_name] = action_name.to_sym
        # If responder is not specified then pass in Spree::Responder
        (options.delete(:responder) || Spree::Responder).call(self, resources, options)
      end
    end
  end
end

module Spree
  module Core
    module ControllerHelpers
      module RespondWith
        extend ActiveSupport::Concern

        included do
          cattr_accessor :spree_responders
          self.spree_responders = {}
        end

        module ClassMethods
          def clear_overrides!
            self.spree_responders = {}
          end

          def respond_override(options = {})
            return if options.blank?

            action_name = options.keys.first
            action_value = options.values.first

            if action_name.blank? || action_value.blank?
              raise ArgumentError, "invalid values supplied #{options.inspect}"
            end

            format_name = action_value.keys.first
            format_value = action_value.values.first

            if format_name.blank? || format_value.blank?
              raise ArgumentError, "invalid values supplied #{options.inspect}"
            end

            if format_value.is_a?(Proc)
              options = {
                action_name.to_sym => { format_name.to_sym => { success: format_value } }
              }
            end

            spree_responders.deep_merge!(name.to_sym => options)
          end
{'fraction_non_alphanumeric': 0.0734229576008273, 'fraction_numerical': 0.003722854188210962, 'mean_word_length': 2.003726708074534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7384871', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1232, 'n_words': 324}