Sha256: 0a21639bed7cf0106aab75d8f1a8372298c4af34c65d266be0634224b30c2e56

Contents?: true

Size: 616 Bytes

Versions: 12

Compression:

Stored size: 616 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)
          @corrections << lambda do |corrector|
            corrector.replace(node.loc.begin, '`')
            corrector.replace(node.loc.end, '`')
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/style/unneeded_percent_x.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/style/unneeded_percent_x.rb
rubocop-0.29.1 lib/rubocop/cop/style/unneeded_percent_x.rb
rubocop-0.29.0 lib/rubocop/cop/style/unneeded_percent_x.rb
rubocop-0.28.0 lib/rubocop/cop/style/unneeded_percent_x.rb
rubocop-0.27.1 lib/rubocop/cop/style/unneeded_percent_x.rb
rubocop-0.27.0 lib/rubocop/cop/style/unneeded_percent_x.rb
rubocop-0.26.1 lib/rubocop/cop/style/unneeded_percent_x.rb
rubocop-0.26.0 lib/rubocop/cop/style/unneeded_percent_x.rb
rubocop-0.25.0 lib/rubocop/cop/style/unneeded_percent_x.rb
rubocop-0.24.1 lib/rubocop/cop/style/unneeded_percent_x.rb
rubocop-0.24.0 lib/rubocop/cop/style/unneeded_percent_x.rb