Skip to content

Commit bedddc2

Browse files
committed
Clarify dependency violation message
I was bothered by a couple of things in the dependency violation message and this change fixes them. 1. "Are we missing an abstraction?" is not helpful context. 2. "Is the code making the reference, and the referenced constant, in the right packages?" was not grammatically correct or clear.
1 parent ab53e75 commit bedddc2

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

TROUBLESHOOT.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ See: [USAGE.md - Enforcing dependency boundary](USAGE.md#Enforcing-dependency-bo
2828

2929
> /Users/JaneDoe/src/github.com/sample-project/billing/app/jobs/document_processing_job.rb:48:6
3030
> Dependency violation: ::Edi::Source belongs to 'edi', but 'billing' does not specify a dependency on 'edi'.
31-
> Are we missing an abstraction?
32-
> Is the code making the reference, and the referenced constant, in the right packages?
31+
> Are the constant and its references in the right packages?
3332
>
3433
> Inference details: 'Edi::Source' refers to ::Edi::Source which seems to be defined in edi/app/models/edi/source.rb.
3534

lib/packwerk/reference_checking/checkers/dependency_checker.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ def message(reference)
4040

4141
<<~EOS
4242
Dependency violation: #{const_name} belongs to '#{const_package}', but '#{ref_package}' does not specify a dependency on '#{const_package}'.
43-
Are we missing an abstraction?
44-
Is the code making the reference, and the referenced constant, in the right packages?
43+
Are the constant and its references in the right packages?
4544
4645
#{standard_help_message(reference)}
4746
EOS

test/unit/packwerk/reference_offense_test.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class ReferenceOffenseTest < Minitest::Test
2929

3030
expected = <<~EXPECTED
3131
Dependency violation: ::SomeName belongs to 'destination_package', but 'components/source' does not specify a dependency on 'destination_package'.
32-
Are we missing an abstraction?
33-
Is the code making the reference, and the referenced constant, in the right packages?
32+
Are the constant and its references in the right packages?
3433
3534
Inference details: this is a reference to ::SomeName which seems to be defined in some/location.rb.
3635
To receive help interpreting or resolving this error message, see: https://github.com/Shopify/packwerk/blob/main/TROUBLESHOOT.md#Troubleshooting-violations

0 commit comments

Comments
 (0)