Sha256: 8ddc30374929836b240e146dae4698a360c4a779f5b5fbb6eceab160769ce3ee

Contents?: true

Size: 631 Bytes

Versions: 4

Compression:

Stored size: 631 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # The purpose of the this cop is advise the use of
      # alias_method over the alias keyword whenever possible.
      class Alias < Cop
        MSG = 'Use alias_method instead of alias.'

        # TODO: Make this check context aware - alias_method is not
        #   available outside of classes/modules.
        def on_alias(node)
          # alias_method can't be used with global variables
          new, old = *node

          return if new.type == :gvar && old.type == :gvar

          convention(node, :keyword)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.14.1 lib/rubocop/cop/style/alias.rb
rubocop-0.14.0 lib/rubocop/cop/style/alias.rb
rubocop-0.13.1 lib/rubocop/cop/style/alias.rb
rubocop-0.13.0 lib/rubocop/cop/style/alias.rb