Class: PackageProtections::PerFileViolation

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/package_protections/per_file_violation.rb

Overview

Perhaps this should be in ParsePackwerk. For now, this is here to help us break down violations per file. This is analogous to ‘Packwerk::ReferenceOffense`

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from(violation, reference_source_package) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/package_protections/per_file_violation.rb', line 18

def self.from(violation, reference_source_package)
  violation.files.map do |file|
    PerFileViolation.new(
      type: violation.type,
      class_name: violation.class_name,
      filepath: file,
      constant_source_package: violation.to_package_name,
      reference_source_package: reference_source_package
    )
  end
end

Instance Method Details

#dependency?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/package_protections/per_file_violation.rb', line 31

def dependency?
  type == 'dependency'
end

#privacy?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/package_protections/per_file_violation.rb', line 36

def privacy?
  type == 'privacy'
end