Sha256: 95d4c198564bfefa949a7516cd5135cd6bafe90489278c7f6e948ed4a1cff00c

Contents?: true

Size: 733 Bytes

Versions: 6838

Compression:

Stored size: 733 Bytes

Contents

# frozen_string_literal: true

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

        def on_dstr(node)
          node.each_child_node(:begin) do |begin_node|
            add_offense(begin_node) 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

6,838 entries across 6,832 versions & 26 rubygems

Version Path
rubocop-0.59.2 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.59.1 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.59.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.58.2 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.58.1 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.58.0 lib/rubocop/cop/lint/empty_interpolation.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rubocop-0.57.2/lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.57.2 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.57.1 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.57.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.56.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.55.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.54.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.53.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.52.1 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.52.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.51.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.50.0 lib/rubocop/cop/lint/empty_interpolation.rb