123456789_123456789_123456789_123456789_123456789_

Module: RuboCop::Cop::EndlessMethodRewriter

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/rubocop/cop/mixin/endless_method_rewriter.rb

Overview

Common functionality for rewriting endless methods to normal method definitions

Instance Method Summary

Instance Method Details

#arguments(node, missing = '') (private)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/endless_method_rewriter.rb', line 19

def arguments(node, missing = '')
  node.arguments.any? ? node.arguments.source : missing
end

#correct_to_multiline(corrector, node)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/endless_method_rewriter.rb', line 7

def correct_to_multiline(corrector, node)
  replacement = <<~RUBY.strip
    def #{node.method_name}#{arguments(node)}
      #{node.body.source}
    end
  RUBY

  corrector.replace(node, replacement)
end