Sha256: ad811526fee215ea9ed11fe146740e2e150c8f39fa218011d90706fc73ea4edf

Contents?: true

Size: 784 Bytes

Versions: 4

Compression:

Stored size: 784 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Layout
      # Checks if empty lines exist around the bodies of methods.
      #
      # @example
      #
      #   # good
      #
      #   def foo
      #     # ...
      #   end
      #
      #   # bad
      #
      #   def bar
      #
      #     # ...
      #
      #   end
      class EmptyLinesAroundMethodBody < Base
        include EmptyLinesAroundBody
        extend AutoCorrector

        KIND = 'method'

        def on_def(node)
          first_line = node.arguments.source_range&.last_line

          check(node, node.body, adjusted_first_line: first_line)
        end
        alias on_defs on_def

        private

        def style
          :no_empty_lines
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-1.70.0 lib/rubocop/cop/layout/empty_lines_around_method_body.rb
rubocop-1.69.2 lib/rubocop/cop/layout/empty_lines_around_method_body.rb
rubocop-1.69.1 lib/rubocop/cop/layout/empty_lines_around_method_body.rb
rubocop-1.69.0 lib/rubocop/cop/layout/empty_lines_around_method_body.rb