<commit_before>module ScopedReflection
  def initialize(owner, reflection)
    scope_reflection(reflection)
    super
  end

  def scope_reflection(reflection)
    if reflection.options && reflection.options[:scope]
      
      source_reflection_class = 
        if reflection.options[:through] && reflection.respond_to?(:source_reflection) 
          reflection.source_reflection.klass 
        else 
          reflection.klass
        end
      
      final_scope = [reflection.options[:scope]].flatten.inject(source_reflection_class) do |accumulated_scope, scope|
        if accumulated_scope.respond_to?(scope)
          accumulated_scope.send(scope)
        else
          raise ActiveRecord::UndefinedScopeReflectionError.new(self, scope)
        end
      end
      reflection.options.merge!((final_scope.send(:current_scoped_methods) || {})[:find] || {}) 
    end
  end
end<commit_msg>Breaking up some long lines.<commit_after>module ScopedReflection
  def initialize(owner, reflection)
    scope_reflection(reflection)
    super
  end

  def scope_reflection(reflection)
    if reflection.options && reflection.options[:scope]
      source_reflection_class = 
        if reflection.options[:through] && reflection.respond_to?(:source_reflection) 
          reflection.source_reflection.klass 
        else 
          reflection.klass
        end
      
      scope_names = [reflection.options[:scope]].flatten
      final_scope = scope_names.inject(source_reflection_class) do |accumulated_scope, scope|
        if accumulated_scope.respond_to?(scope)
          accumulated_scope.send(scope)
        else
          raise ActiveRecord::UndefinedScopeReflectionError.new(self, scope)
        end
      end

      current_scoped_methods = final_scope.send(:current_scoped_methods) || {}
      reflection.options.merge!(current_scoped_methods[:find] || {}) 
    end
  end
end
{'fraction_non_alphanumeric': 0.08665603402445508, 'fraction_numerical': 0.0, 'mean_word_length': 3.145374449339207, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4977265', 'n_tokens_mistral': 526, 'n_tokens_neox': 523, 'n_words': 86}