module RuboCop::Cop::Parentheses

Common functionality for handling parentheses.

Public Instance Methods

autocorrect(node) click to toggle source
# File lib/rubocop/cop/mixin/parentheses.rb, line 13
def autocorrect(node)
  lambda do |corrector|
    corrector.remove(node.loc.begin)
    corrector.remove(node.loc.end)
  end
end
parens_required?(node) click to toggle source
# File lib/rubocop/cop/mixin/parentheses.rb, line 6
def parens_required?(node)
  range  = node.source_range
  source = range.source_buffer.source
  source[range.begin_pos - 1] =~ /[a-z]/ ||
    source[range.end_pos] =~ /[a-z]/
end