Skip to content

[Bug Report] Dependency violation not flagged when Zeitwerk collapsing is used #406

@pareeohnos

Description

@pareeohnos

Description
A package calling another package is not triggering a violation

To Reproduce

  • Create app/modules folder
  • Create two packages in the new folder, with package.yml files enforcing dependencies
  • Add a class in each package. Make one call the other
  • Run bin/packwerk check

Expected Behaviour
A violation error to be raised

Screenshots
I've created a reproduction of the issue here https://github.com/pareeohnos/packwerk-issue

Version Information

  • Packwerk: 3.2
  • Ruby 3.3.0

Additional Context
The project structure contains modules in the app/modules directory. Within each package, each sub-directory is collapsed in Zeitwerk, so for example the directory app/modules/package_one/services/service_one.rb is loaded its PackageOne::ServiceOne instead of PackageOne::Services::ServiceOne.

I've tried removing the dependency on . and it triggers violations, but this is because the ApplicationController and ApplicationRecord classes are both located in the root of the project - it still makes not mention of the cross package violation.

If I remove the collapsing altogether, it starts to work correctly but this causes issues in our application so we need the collapsing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions