Sha256: 4cf43d1dd5370cb62b00b203607f81ec3964b164c1e4eb1618c9b1ff9aaf9433

Contents?: true

Size: 660 Bytes

Versions: 1

Compression:

Stored size: 660 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop checks for usage of the %x() syntax when `` would do.
      class UnneededPercentX < Cop
        MSG = 'Do not use `%x` unless the command string contains backquotes.'

        def on_xstr(node)
          add_offense(node, :expression) if node.loc.expression.source !~ /`/
        end

        private

        def autocorrect(node)
          string, = *node
          @corrections << lambda do |corrector|
            corrector.replace(node.loc.expression,
                              "`#{string.loc.expression.source}`")
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.22.0 lib/rubocop/cop/style/unneeded_percent_x.rb