Module: RuboCop::Cop::Parentheses
- Included in:
- Style::ParenthesesAroundCondition, Style::RedundantParentheses
- Defined in:
- lib/rubocop/cop/mixin/parentheses.rb
Overview
Common functionality for handling parentheses.
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/rubocop/cop/mixin/parentheses.rb', line 14 def autocorrect(node) lambda do |corrector| corrector.remove(node.loc.begin) corrector.remove(node.loc.end) end end |
#parens_required?(node) ⇒ Boolean
8 9 10 11 12 |
# File 'lib/rubocop/cop/mixin/parentheses.rb', line 8 def parens_required?(node) source_buffer = node.source_range.source_buffer source_buffer.source[node.source_range.begin_pos - 1] =~ /[a-z]/ || source_buffer.source[node.source_range.end_pos] =~ /[a-z]/ end |