class RuboCop::Cop::Style::EmptyMethod

end
def self.foo(bar)
end
def foo(bar)
@good
def self.foo(bar); end
def foo(bar); end
@bad
EnforcedStyle: expanded
def self.foo(bar); end
end
# baz
def foo(bar)
def foo(bar); end
@good
end
def self.foo(bar)
end
def foo(bar)
@bad
EnforcedStyle: compact (default)
@example
comments.
Note: A method definition is not considered empty if it contains
to go on its own line (expanded style.)
line (compact style), but it can be configured to enforce the ‘end`
By default it enforces empty method definitions to go on a single
This cop checks for the formatting of empty method definitions.

def autocorrect(node)

def autocorrect(node)
  lambda do |corrector|
    corrector.replace(node.source_range, corrected(node))
  end
end

def comment_lines?(node)

def comment_lines?(node)
  processed_source[line_range(node)].any? { |line| comment_line?(line) }
end

def compact?(node)

def compact?(node)
  node.single_line?
end

def compact_style?

def compact_style?
  style == :compact
end

def corrected(node)

def corrected(node)
  method_name, args, _body, scope = method_def_node_parts(node)
  arguments = args.source unless args.children.empty?
  joint = compact_style? ? '; ' : "\n"
  scope = scope ? 'self.' : ''
  ["def #{scope}#{method_name}#{arguments}", 'end'].join(joint)
end

def expanded?(node)

def expanded?(node)
  node.multiline?
end

def expanded_style?

def expanded_style?
  style == :expanded
end

def message

def message
  compact_style? ? MSG_COMPACT : MSG_EXPANDED
end

def on_method_def(node, _method_name, _args, body)

def on_method_def(node, _method_name, _args, body)
  return if body || comment_lines?(node)
  return if compact_style? && compact?(node)
  return if expanded_style? && expanded?(node)
  add_offense(node, node.source_range, message)
end