Sha256: 981d08652ed0d8040a73331d1b14769442091f09a75c355d600e1b327da3952b

Contents?: true

Size: 627 Bytes

Versions: 9

Compression:

Stored size: 627 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Lint
      # This cop checks for empty interpolation.
      #
      # @example
      #
      #   "result is #{}"
      class EmptyInterpolation < Cop
        MSG = 'Empty interpolation detected.'.freeze

        def on_dstr(node)
          node.each_child_node(:begin) do |begin_node|
            add_offense(begin_node, :expression) if begin_node.children.empty?
          end
        end

        def autocorrect(node)
          lambda do |collector|
            collector.remove(node.loc.expression)
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/cop/lint/empty_interpolation.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/cop/lint/empty_interpolation.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/lint/empty_interpolation.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/lint/empty_interpolation.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/lint/empty_interpolation.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/lint/empty_interpolation.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.46.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.45.0 lib/rubocop/cop/lint/empty_interpolation.rb