Sha256: f6b3078f07cb12fd37904d518402fe1dbb1a0a2c0bb7535791e9f5a8b7bce309

Contents?: true

Size: 580 Bytes

Versions: 3

Compression:

Stored size: 580 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true

module RuboCop
  module Cop
    # Common functionality for handling parentheses.
    module Parentheses
      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

      def autocorrect(node)
        lambda do |corrector|
          corrector.remove(node.loc.begin)
          corrector.remove(node.loc.end)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.37.1 lib/rubocop/cop/mixin/parentheses.rb
rubocop-0.37.0 lib/rubocop/cop/mixin/parentheses.rb
rubocop-0.36.0 lib/rubocop/cop/mixin/parentheses.rb