Class: ArchSpec::Rules::Naming::Forbidden

Inherits:
Object
  • Object
show all
Defined in:
lib/archspec/rules/naming_rules.rb

Overview

Forbids any selected method from existing. Rule id naming.forbidden.

Instance Method Summary collapse

Constructor Details

#initialize(because: nil) ⇒ Forbidden

Returns a new instance of Forbidden.



77
78
79
# File 'lib/archspec/rules/naming_rules.rb', line 77

def initialize(because: nil)
  @because = because
end

Instance Method Details

#diagnostics(selected, rule, _graph) ⇒ Object



85
86
87
88
89
90
91
92
93
94
# File 'lib/archspec/rules/naming_rules.rb', line 85

def diagnostics(selected, rule, _graph)
  selected.map do |definition, _match|
    Diagnostic.new(
      rule: id,
      message: message_for(definition),
      location: definition.location,
      evidence: "#{definition.owner} defines #{definition.scope} method #{definition.name} (#{rule.selector.describe})"
    )
  end
end

#idObject



81
82
83
# File 'lib/archspec/rules/naming_rules.rb', line 81

def id
  'naming.forbidden'
end