<commit_before># frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # This cop checks for trailing code after the method definition.
      #
      # NOTE: It always accepts endless method definitions that are basically on the same line.
      #
      # @example
      #   # bad
      #   def some_method; do_stuff
      #   end
      #
      #   def f(x); b = foo
      #     b[c: x]
      #   end
      #
      #   # good
      #   def some_method
      #     do_stuff
      #   end
      #
      #   def f(x)
      #     b = foo
      #     b[c: x]
      #   end
      #
      #   def endless_method = do_stuff
      #
      class TrailingBodyOnMethodDefinition < Base
        include Alignment
        include TrailingBody
        extend AutoCorrector

        MSG = "Place the first line of a multi-line method definition's " \
              'body on its own line.'

        def on_def(node)
          return unless trailing_body?(node)
          return if node.endless? && node.body.parenthesized_call?

          add_offense(first_part_of(node.body)) do |corrector|
            LineBreakCorrector.correct_trailing_body(
              configured_width: configured_indentation_width,
              corrector: corrector,
              node: node,
              processed_source: processed_source
            )
          end
        end
        alias on_defs on_def
      end
    end
  end
end<commit_msg>Remove a redundant condition for `Style/TrailingBodyOnMethodDefinition`<commit_after># frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # This cop checks for trailing code after the method definition.
      #
      # NOTE: It always accepts endless method definitions that are basically on the same line.
      #
      # @example
      #   # bad
      #   def some_method; do_stuff
      #   end
      #
      #   def f(x); b = foo
      #     b[c: x]
      #   end
      #
      #   # good
      #   def some_method
      #     do_stuff
      #   end
      #
      #   def f(x)
      #     b = foo
      #     b[c: x]
      #   end
      #
      #   def endless_method = do_stuff
      #
      class TrailingBodyOnMethodDefinition < Base
        include Alignment
        include TrailingBody
        extend AutoCorrector

        MSG = "Place the first line of a multi-line method definition's " \
              'body on its own line.'

        def on_def(node)
          return unless trailing_body?(node)
          return if node.endless?

          add_offense(first_part_of(node.body)) do |corrector|
            LineBreakCorrector.correct_trailing_body(
              configured_width: configured_indentation_width,
              corrector: corrector,
              node: node,
              processed_source: processed_source
            )
          end
        end
        alias on_defs on_def
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06144287193648602, 'fraction_numerical': 0.0, 'mean_word_length': 1.5533039647577092, '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': '6343759', 'n_tokens_mistral': 838, 'n_tokens_neox': 825, 'n_words': 233}