48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/rubocop/cop/packwerk_lite/dependency_checker.rb', line 48
def on_const(node)
return if Private.partial_const_reference?(node)
constant_reference = ConstantResolver::ConstantReference.resolve(node, processed_source)
return if constant_reference.nil?
return if constant_reference.referencing_package.name == constant_reference.source_package.name
return if constant_reference.constant_name.include?('PncApi')
is_new_violation = [
!constant_reference.referencing_package.dependencies.include?(constant_reference.source_package.name),
constant_reference.referencing_package.enforces_dependencies?,
!Private.violation_in_package_todo_yml?(constant_reference, type: 'dependency')
].all?
if is_new_violation
add_offense(
node.source_range,
message: format(
'Dependency violation detected. See https://github.com/Shopify/packwerk/blob/main/RESOLVING_VIOLATIONS.md for help'
)
)
end
end
|