Sha256: 3ff217a07891e495f82a94481361292bf127442cb46b540b042a48ac17dbc8df

Contents?: true

Size: 683 Bytes

Versions: 5

Compression:

Stored size: 683 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|
              convention(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.15.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.14.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.14.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.13.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.13.0 lib/rubocop/cop/style/module_function.rb