Skip to content

Commit

Permalink
Clarify dependency violation message
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
derekprior committed Jan 17, 2025
1 parent ab53e75 commit 8fa0500
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions TROUBLESHOOT.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ See: [USAGE.md - Enforcing dependency boundary](USAGE.md#Enforcing-dependency-bo

> /Users/JaneDoe/src/github.com/sample-project/billing/app/jobs/document_processing_job.rb:48:6
> Dependency violation: ::Edi::Source belongs to 'edi', but 'billing' does not specify a dependency on 'edi'.
> Are we missing an abstraction?
> Is the code making the reference, and the referenced constant, in the right packages?
> Are the constant and its references in the right packages?
>
> Inference details: 'Edi::Source' refers to ::Edi::Source which seems to be defined in edi/app/models/edi/source.rb.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def message(reference)

<<~EOS
Dependency violation: #{const_name} belongs to '#{const_package}', but '#{ref_package}' does not specify a dependency on '#{const_package}'.
Are we missing an abstraction?
Is the code making the reference, and the referenced constant, in the right packages?
Are the constant and its references in the right packages?
#{standard_help_message(reference)}
EOS
Expand Down
3 changes: 1 addition & 2 deletions test/unit/packwerk/reference_offense_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class ReferenceOffenseTest < Minitest::Test

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

0 comments on commit 8fa0500

Please sign in to comment.