Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for checking transitive dependencies #253

Closed
lukfas opened this issue Oct 23, 2019 · 2 comments
Closed

Support for checking transitive dependencies #253

lukfas opened this issue Oct 23, 2019 · 2 comments

Comments

@lukfas
Copy link

lukfas commented Oct 23, 2019

ArchUnit supports checking for dependencies between classes using com.tngtech.archunit.lang.conditions.AnyDependencyCondition via com.tngtech.archunit.lang.conditions.ArchConditions.dependOnClassesThat(DescribedPredicate<? super JavaClass>).

However, this Condition does not cover indirect dependencies.

Checking for immediate dependencies ist sufficient in projects where there exists a consistent architectural guideline that specifies for every package / class the allowed dependencies.

When refactoring a large legacy project without such detailed guidelines, one might still pose independence constraints on two (groups of) classes, but defining guidelines for all indirectly referenced classes would be too expensive. In this case, one has to check for the absence of transitive dependencies.

As a Proof of Concept, I have implemented a subclass TransitiveDependenceCondition of ArchCondition. It checks for transitive dependencies from the current class to some target class satisfying a target-condition, without passing through other classes matching some ignore-condition.

When used on about 20.000 classes, a check for transitive independence takes much less than the import of all classes. Hence the transitive dependency check itself is not really expensive.
Although this POC is working in our project, it is still preliminary and not as general as it could be.

@lukfas
Copy link
Author

lukfas commented Oct 23, 2019

Here is the POC: [transitiveDependencies.zip] (https://github.com/TNG/ArchUnit/files/3762706/transitiveDependencies.zip)

@codecholeric
Copy link
Collaborator

I think this should be solved by #401, otherwise feel free to reopen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants