Class: RuboCop::Cop::Discourse::Plugins::NamespaceMethods

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/discourse/plugins/namespace_methods.rb

Overview

Methods must be defined inside the plugin namespace (module or class).

Examples:

# bad
def my_method
end

# good
module MyPlugin
  def my_method
  end
end

Constant Summary collapse

MSG =
"Don’t define methods outside a class or a module."

Instance Method Summary collapse

Instance Method Details

#on_def(node) ⇒ Object



23
24
25
26
# File 'lib/rubocop/cop/discourse/plugins/namespace_methods.rb', line 23

def on_def(node)
  return if inside_namespace?(node)
  add_offense(node, message: MSG)
end