Sha256: 3d7b61ec69fbb0fe14253431a4a9e5c142af639a935fa2ee63b863299cd02fe0

Contents?: true

Size: 675 Bytes

Versions: 11

Compression:

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

11 entries across 11 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/style/module_function.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/style/module_function.rb
rubocop-0.28.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.27.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.27.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.26.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.26.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.25.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.24.1 lib/rubocop/cop/style/module_function.rb
rubocop-0.24.0 lib/rubocop/cop/style/module_function.rb
rubocop-0.23.0 lib/rubocop/cop/style/module_function.rb