-
Notifications
You must be signed in to change notification settings - Fork 0
Description
We’re seeing a false positive pks when defining a polymorphic belongs_to :event association in a model. Even though the association is polymorphic and doesn’t reference a specific model, a privacy and dependency violation is triggered referencing a model named Event in a different pack.
Context:
In a model within Pack A, we have the following line:
belongs_to :event, polymorphic: trueThis is intended to be a generic polymorphic association and does not directly reference the Event model defined in Pack B. However, the tooling is inferring a direct dependency on that model purely based on the association name.
Violation Output:
Privacy Violation: `::Event` belongs to Pack B, which is not visible to Pack A.
Dependency Violation: `::Event` belongs to Pack B, but Pack A does not declare it as a dependency.
Expected Behavior:
A polymorphic association like belongs_to :event, polymorphic: true should not result in a violation unless the code explicitly references a concrete class or constant from another pack.
Temporary Workaround:
- Add a TODO to suppress the violation using
bin/pks update - Alternatively, rename the association (e.g.
:related_event) to avoid triggering the incorrect inference (though this breaks with established naming conventions)
Notes:
bin/packwerk checkandbin/pks checkproduce the same result- Slack thread (Gusto internal)