Repository navigation
Say where an association's reference is, and split out list-references' violations - #80
Merged
Merged
Conversation
…s' violations A reference that pks infers from an association, as `has_many :tacos` gives `::Taco`, is at the association, so `Taco` isn't written at its line and column, or anywhere in the file. A consumer that looks for the constant in the file, as query_packwerk's file cache does, finds nothing. The schema's `constant_name` now says so. The loop that collects a reference's violations moves out of `list` into `violations`, which takes two levels of nesting out of `list`. The output is the same. The `expect` on the defining pack stays. `between_packs` drops constants that no pack defines, and carrying each reference's defining pack beside it would change what `between_packs` returns to `rm` too, which doesn't need it. The message now names `between_packs`.
A reference that pks infers from an association is at the start of the call, where no constant is written. A `class_name: "Taco"` option names the constant there only in a string, and the file may write the constant elsewhere, so the previous commit's "or anywhere in the file" went too far. The schema's `constant_name` now says where the reference is, that `class_name:` takes a string, and that the source may write a constant relatively. A test pins the associations' references in app_with_rails_relationships at the start of their calls. `violations` is now `violations_of`, like `files_of`, so its local `violations` no longer shadows it. The comment on the copies of a reference that it merges now says that only the experimental parser makes them.
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two things left over from #71's review.
schema/list-references-output.jsonnow says that a reference pks infers from an association, ashas_many :tacosgives::Taco, is at the start of the call, where no constant is written. Aclass_name:option names the constant only in a string. query_packwerk's file cache looks for the constant's node in the file and finds none there. The description also says the source may write a constant relatively, asBarinsidemodule Foo.listintoviolations_of, which takes the nested loops out oflist. The output is the same. The comment on the copies it merges now says that only the experimental parser makes them.The
expecton the defining pack stays.between_packsdrops constants that no pack defines, and carrying each reference's defining pack beside it would change whatbetween_packsreturns tormtoo, which doesn't need it. The message now namesbetween_packs.Test plan
cargo test(375 passed),cargo fmt --check, andcargo clippy --all-targets --all-features -- -Dwarnings.test_list_references_from_associationspins::Censusand::Tacoatcarrier.rb:2:2and:3:2inapp_with_rails_relationships, where the source has onlyhas_many :censusesandhas_many :tacos.