Sha256: 10dcb6d201023d7156467c2e1fe22f4b9e0c7ef22c0e64a7988fedcc8f7f94ab

Contents?: true

Size: 726 Bytes

Versions: 15

Compression:

Stored size: 726 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.'

        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

15 entries across 15 versions & 2 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/empty_interpolation.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/empty_interpolation.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/empty_interpolation.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/empty_interpolation.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/empty_interpolation.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/empty_interpolation.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/empty_interpolation.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.73.0 lib/rubocop/cop/lint/empty_interpolation.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/empty_interpolation.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.72.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.71.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.70.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-0.69.0 lib/rubocop/cop/lint/empty_interpolation.rb