<commit_before># encoding: utf-8
# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # Helper module to provide common methods to classes needed for the
      # ConditionalAssignment Cop.
      module ConditionalAssignmentHelper
        EQUAL = '='.freeze
        END_ALIGNMENT = 'Lint/EndAlignment'.freeze
        ALIGN_WITH = 'AlignWith'.freeze
        KEYWORD = 'keyword'.freeze

        # `elsif` branches show up in the `node` as an `else`. We need
        # to recursively iterate over all `else` branches and consider all
        # but the last `node` an `elsif` branch and consider the last `node`
        # the actual `else` branch.
        def expand_elses(branch)
          elsif_branches = expand_elsif(branch)
          else_branch = elsif_branches.any? ? elsif_branches.pop : branch
          [elsif_branches, else_branch]
        end

        # `when` nodes contain the entire branch including the condition.
        # We only need the contents of the branch, not the condition.
        def expand_when_branches(when_branches)
          when_branches.map { |branch| branch.children[1] }
        end

        def tail(branch)
          branch.begin_type? ? [*branch].last : branch
        end

        def lhs(node)
          case node.type
          when :send
            lhs_for_send(node)
          when :op_asgn
            "#{node.children[0].source} #{node.children[1]}= "
          when :and_asgn
            "#{node.children[0].source} &&= "
          when :or_asgn
            "#{node.children[0].source} ||= "
          when :casgn
            "#{node.children[1]} = "
          when *ConditionalAssignment::VARIABLE_ASSIGNMENT_TYPES
            "#{node.children[0]} = "
          else
            node.source
          end
        end

        def indent(cop, source)
          if cop.config[END_ALIGNMENT] &&
             cop.config[END_ALIGNMENT][ALIGN_WITH] &&
             cop.config[END_ALIGNMENT][ALIGN_WITH] == KEYWORD<commit_msg>Allow exceeding MethodLength in ConditionalAssignment<commit_after># encoding: utf-8
# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # Helper module to provide common methods to classes needed for the
      # ConditionalAssignment Cop.
      module ConditionalAssignmentHelper
        EQUAL = '='.freeze
        END_ALIGNMENT = 'Lint/EndAlignment'.freeze
        ALIGN_WITH = 'AlignWith'.freeze
        KEYWORD = 'keyword'.freeze

        # `elsif` branches show up in the `node` as an `else`. We need
        # to recursively iterate over all `else` branches and consider all
        # but the last `node` an `elsif` branch and consider the last `node`
        # the actual `else` branch.
        def expand_elses(branch)
          elsif_branches = expand_elsif(branch)
          else_branch = elsif_branches.any? ? elsif_branches.pop : branch
          [elsif_branches, else_branch]
        end

        # `when` nodes contain the entire branch including the condition.
        # We only need the contents of the branch, not the condition.
        def expand_when_branches(when_branches)
          when_branches.map { |branch| branch.children[1] }
        end

        def tail(branch)
          branch.begin_type? ? [*branch].last : branch
        end

        def lhs(node) # rubocop:disable Metrics/MethodLength
          case node.type
          when :send
            lhs_for_send(node)
          when :op_asgn
            "#{node.children[0].source} #{node.children[1]}= "
          when :and_asgn
            "#{node.children[0].source} &&= "
          when :or_asgn
            "#{node.children[0].source} ||= "
          when :casgn
            "#{node.children[1]} = "
          when *ConditionalAssignment::VARIABLE_ASSIGNMENT_TYPES
            "#{node.children[0]} = "
          else
            node.source
          end
        end

        def indent(cop, source)
          if cop.config[END_ALIGNMENT] &&
             cop.config[END_ALIGNMENT][ALIGN_WITH] &&
             cop.config[END_ALIGNMENT][ALIGN_WITH] == KEYWORD
{'fraction_non_alphanumeric': 0.09225092250922509, 'fraction_numerical': 0.0039360393603936035, 'mean_word_length': 2.0826383623957545, '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': '4256183', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1185, 'n_words': 305}