Class: RuboCop::Cop::Discourse::Plugins::NamespaceConstants

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

Overview

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

Examples:

# bad
MY_CONSTANT = :value

# good
module MyPlugin
  MY_CONSTANT = :value
end

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#on_casgn(node) ⇒ Object



21
22
23
24
# File 'lib/rubocop/cop/discourse/plugins/namespace_constants.rb', line 21

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