You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Everything works as expected within the defined layers.
However, any layer can depend on namespaces that are not defined as layers yet. At the moment if someone introduced a dependency on Symfony\Component\DependencyInjection\ContainerInterface in Foo\Domain, deptrac wouldn't complain.
Things can be easily missed this way. Any newly introduced dependency needs to be defined as a layer. Someone needs to remember to do it, and people tend to forget.
For this reason I've been introducing a catch-all layer, that would catch any namespace that doesn't belong to other layers:
layers:
# ...
- name: Other Vendorscollectors:
- type: boolmust:
# must be outside of global namespace
- type: classNameregex: '[\\]+'must_not:
# must not be one of the known vendors or packages
- type: classNameregex: ^Foo\\(Domain|Infrastructure)\\.*
- type: classNameregex: ^Doctrine\\(Common|ORM)\\.*
Each time a layer is defined, the "Other Vendors" layer needs to be updated as well to exclude the new layer.
The advantage of this approach is that as soon as a new dependency or a package is introduced, deptrac will complain it doesn't know what to do with it.
The drawback of this approach is having to exclude any new layer from "Other Vendors" each time (so each regex is defined in two places).
My preference would be if deptrac either complained about namespaces that don't belong to any layers by default, or if there was a "catch-all-that-was-not-defined" collector. Perhaps authors have better ideas, or maybe I'm doing it wrong.
It has nothing todo with collectors as all dependencies will be collected. The RulesetEngine ignores classes without any layer. We need to refactor the RulesetEngine to adapt violations, skipped violations and uncovered dependencies to the DependencyContext.
Per configuration we could choose a strategy (ignore, warning, error) how uncovered dependencies are exposed.
This refactoring would us allow resolve #205 as we could add allowed dependencies also to the context.
Given the following config:
Everything works as expected within the defined layers.
However, any layer can depend on namespaces that are not defined as layers yet. At the moment if someone introduced a dependency on
Symfony\Component\DependencyInjection\ContainerInterface
inFoo\Domain
, deptrac wouldn't complain.Things can be easily missed this way. Any newly introduced dependency needs to be defined as a layer. Someone needs to remember to do it, and people tend to forget.
For this reason I've been introducing a catch-all layer, that would catch any namespace that doesn't belong to other layers:
Each time a layer is defined, the "Other Vendors" layer needs to be updated as well to exclude the new layer.
The advantage of this approach is that as soon as a new dependency or a package is introduced, deptrac will complain it doesn't know what to do with it.
The drawback of this approach is having to exclude any new layer from "Other Vendors" each time (so each regex is defined in two places).
My preference would be if deptrac either complained about namespaces that don't belong to any layers by default, or if there was a "catch-all-that-was-not-defined" collector. Perhaps authors have better ideas, or maybe I'm doing it wrong.
Real life examples:
The text was updated successfully, but these errors were encountered: