<commit_before># frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # Checks for redundant `each`.
      #
      # @safety
      #   This cop is unsafe, as it can produce false positives if the receiver
      #   is not an `Enumerable`.
      #
      # @example
      #
      #   # bad
      #   array.each.each { |v| do_something(v) }
      #
      #   # good
      #   array.each { |v| do_something(v) }
      #
      #   # bad
      #   array.each.each_with_index { |v, i| do_something(v, i) }
      #
      #   # good
      #   array.each.with_index { |v, i| do_something(v, i) }
      #   array.each_with_index { |v, i| do_something(v, i) }
      #
      #   # bad
      #   array.each.each_with_object { |v, o| do_something(v, o) }
      #
      #   # good
      #   array.each.with_object { |v, o| do_something(v, o) }
      #   array.each_with_object { |v, o| do_something(v, o) }
      #
      class RedundantEach < Base
        extend AutoCorrector

        MSG = 'Remove redundant `each`.'
        MSG_WITH_INDEX = 'Use `with_index` to remove redundant `each`.'<commit_msg>Fix a typo in the doc for `Style/RedundantEach`<commit_after># frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # Checks for redundant `each`.
      #
      # @safety
      #   This cop is unsafe, as it can produce false positives if the receiver
      #   is not an `Enumerator`.
      #
      # @example
      #
      #   # bad
      #   array.each.each { |v| do_something(v) }
      #
      #   # good
      #   array.each { |v| do_something(v) }
      #
      #   # bad
      #   array.each.each_with_index { |v, i| do_something(v, i) }
      #
      #   # good
      #   array.each.with_index { |v, i| do_something(v, i) }
      #   array.each_with_index { |v, i| do_something(v, i) }
      #
      #   # bad
      #   array.each.each_with_object { |v, o| do_something(v, o) }
      #
      #   # good
      #   array.each.with_object { |v, o| do_something(v, o) }
      #   array.each_with_object { |v, o| do_something(v, o) }
      #
      class RedundantEach < Base
        extend AutoCorrector

        MSG = 'Remove redundant `each`.'
        MSG_WITH_INDEX = 'Use `with_index` to remove redundant `each`.'
{'fraction_non_alphanumeric': 0.12168141592920353, 'fraction_numerical': 0.0, 'mean_word_length': 1.8156911581569115, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4318558', 'n_tokens_mistral': 817, 'n_tokens_neox': 795, 'n_words': 186}