Sha256: 2e5c9f4b7640cf0a96be8fec56b7e9a7d3ae37e75255f8587eadab4553679244

Contents?: true

Size: 681 Bytes

Versions: 13

Compression:

Stored size: 681 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
          return unless 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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rubocop-0.35.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.35.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.34.2 lib/rubocop/cop/style/module_function.rb
rubocop-0.34.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.34.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.33.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.32.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.32.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.31.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.30.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.30.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.29.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.29.0 lib/rubocop/cop/style/module_function.rb