Sha256: 19a7bb645becd0720ba956971ec496dcd425122487340a656d194f559847bd3c

Contents?: true

Size: 665 Bytes

Versions: 36

Compression:

Stored size: 665 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Lint
      # Checks for empty interpolation.
      #
      # @example
      #
      #   # bad
      #
      #   "result is #{}"
      #
      # @example
      #
      #   # good
      #
      #   "result is #{some_result}"
      class EmptyInterpolation < Base
        include Interpolation
        extend AutoCorrector

        MSG = 'Empty interpolation detected.'

        def on_interpolation(begin_node)
          return unless begin_node.children.empty?

          add_offense(begin_node) { |corrector| corrector.remove(begin_node.loc.expression) }
        end
      end
    end
  end
end

Version data entries

36 entries across 32 versions & 4 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cop/lint/empty_interpolation.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cop/lint/empty_interpolation.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cop/lint/empty_interpolation.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.31.2/lib/rubocop/cop/lint/empty_interpolation.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.35.1/lib/rubocop/cop/lint/empty_interpolation.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/cop/lint/empty_interpolation.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.31.2/lib/rubocop/cop/lint/empty_interpolation.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.35.1/lib/rubocop/cop/lint/empty_interpolation.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/cop/lint/empty_interpolation.rb
zilla-0.2.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.46.0/lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-1.46.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-1.45.1 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-1.45.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-1.44.1 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-1.44.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-1.43.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-1.42.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-1.41.1 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-1.41.0 lib/rubocop/cop/lint/empty_interpolation.rb
rubocop-1.40.0 lib/rubocop/cop/lint/empty_interpolation.rb