Sha256: 61ee9a4c8c63e58c52a2e3997f7378df4a32402797e4d8ac3669fbe8eee7a598

Contents?: true

Size: 696 Bytes

Versions: 4

Compression:

Stored size: 696 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

          add_offence(:convention,
                      node.loc.keyword,
                      MSG)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.12.0 lib/rubocop/cop/style/alias.rb
rubocop-0.11.1 lib/rubocop/cop/style/alias.rb
rubocop-0.11.0 lib/rubocop/cop/style/alias.rb
rubocop-0.10.0 lib/rubocop/cop/style/alias.rb