Sha256: d0c01ce55dabbf7741344fbeb4d9843abfa2e5dbe2be2aec4f8250fdffc072a0

Contents?: true

Size: 684 Bytes

Versions: 5

Compression:

Stored size: 684 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cops checks for use of `extend self` in a module.
      #
      # @example
      #
      # module Test
      #   extend self
      #
      #   ...
      # end
      class ModuleFunction < Cop
        MSG = 'Use `module_function` instead of `extend self`.'

        TARGET_NODE = s(:send, nil, :extend, s(:self))

        def on_module(node)
          _name, body = *node

          if body && body.type == :begin
            body.children.each do |body_node|
              add_offense(body_node, :expression) if body_node == TARGET_NODE
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.21.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.20.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.20.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.19.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.19.0 lib/rubocop/cop/style/module_function.rb