Class: Ducalis::EnforceNamespace

Inherits:
RuboCop::Cop::Cop
  • Object
show all
Includes:
TypeResolving
Defined in:
lib/ducalis/cops/enforce_namespace.rb

Constant Summary collapse

OFFENSE =
<<-MESSAGE.gsub(/^ +\|\s/, '').strip
  | Too improve code organization it is better to define namespaces to group services by high-level features, domains or any other dimension.
MESSAGE

Constants included from TypeResolving

TypeResolving::CONTROLLER_SUFFIXES, TypeResolving::MODELS_CLASS_NAMES, TypeResolving::SERVICES_PATH, TypeResolving::WORKERS_SUFFIXES

Instance Method Summary collapse

Instance Method Details

#on_class(node) ⇒ Object



13
14
15
16
17
# File 'lib/ducalis/cops/enforce_namespace.rb', line 13

def on_class(node)
  return if !node.parent.nil? || !in_service?

  add_offense(node, :expression, OFFENSE)
end

#on_module(node) ⇒ Object



19
20
21
22
23
24
# File 'lib/ducalis/cops/enforce_namespace.rb', line 19

def on_module(node)
  return if !node.parent.nil? || !in_service?
  return if contains_class?(node) || contains_classes?(node)

  add_offense(node, :expression, OFFENSE)
end