Class: Packwerk::ReferenceChecking::ReferenceChecker

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/packwerk/reference_checking/reference_checker.rb

Instance Method Summary collapse

Constructor Details

#initialize(checkers) ⇒ ReferenceChecker

Returns a new instance of ReferenceChecker.



10
11
12
# File 'lib/packwerk/reference_checking/reference_checker.rb', line 10

def initialize(checkers)
  @checkers = checkers
end

Instance Method Details

#call(reference) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/packwerk/reference_checking/reference_checker.rb', line 19

def call(reference)
  @checkers.each_with_object([]) do |checker, violations|
    next unless checker.invalid_reference?(reference)

    offense = Packwerk::ReferenceOffense.new(
      location: reference.source_location,
      reference: reference,
      violation_type: checker.violation_type,
      message: checker.message(reference)
    )
    violations << offense
  end
end