Class: RuboCop::Cop::Ruact::NoExtendSelf

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/ruact/no_extend_self.rb

Overview

Prohibits ‘extend self` and `module_function` in all files. Modules must use explicit class methods or classes with initialize (NFR13).

Examples:

# bad
module MyModule
  extend self
  def do_thing; end
end

# good
module MyModule
  def self.do_thing; end
end

Constant Summary collapse

MSG =
"extend self is prohibited (NFR13). Use explicit class methods or a class with initialize."

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



23
24
25
26
27
# File 'lib/rubocop/cop/ruact/no_extend_self.rb', line 23

def on_send(node)
  return unless extend_self?(node) || module_function_bare?(node)

  add_offense(node)
end