Comments (5)
I'm sorry, but I don't think, that this can be achieved easily at the moment.
I have considered it in the past, but I wasn't sure, if this was a reasonable rule at class level, because there seem to be valid cases or frameworks forcing this onto you, e.g. JPA (@OneToMany
, @ManyToMany
, ...). On the other hand, modules/slices can have cyclic dependencies without any dependency cycle on class level.
It should be possible to generalize and reuse the existing code, since most infrastructure is quite generic, and it principally operates on Dependency
, which JavaClass
can provide as well.
Just don't know, how well the code would perform, since there are a lot more dependency paths to follow, if all classes are considered. Might be necessary to limit the maximum length to follow...
Maybe I could include this in the next version (of course I'm always open for PRs as well 😉 )
Do you have a simple "production" example, that shows unwanted class cycles? (Could be added to archunit-example
then)
from archunit.
I love this library and I would really like to contribute (for now my only contributions are some articles/tutorials about ArchUnit)!
You're right that processing all class references might be expensive, perhaps a first approach would be to process all classes that should be checked, evaluate their direct references and scan for an existing back-reference to the origin class.
I think I have to get to know the library better, perhaps I'm able to create some PoC.
My vision for ArchUnit in general would be to support a nice syntax to assure common quality metrics/indicators like Loc/Cyclomatic Complexity/Halstead/Chidamber&Kamerer etc.(perhaps implementing one of them is an easier task for me to start and a case for another issue) :)
from archunit.
I read your blogpost, which was AFAIK the very first article about ArchUnit out there (and surprising to me at that early stage 😉), so thanks a lot for that, I really appreciate it 😃
As for PRs, no stress, just don't be mad, if it takes me a while to get around to it... It might be a good addition though, in the end it's still possible, to only apply it to selected packages / classes, excluding some special cases, where it's necessary or justified. After all, cycles are always hard to comprehend for the human brain...
Including more metrics would surely be an interesting thing, so far I haven't pushed in that direction, because there are tools like Findbugs and PMD that can do those things already. So on the one hand it's reinventing the wheel, on the other hand, it might be a nicer, clearer API...
from archunit.
There is even another article ;)
I'll try to get a grip to the internals of ArchUnit, maybe I'm able to produce something useful :)
from archunit.
Do you think you'll have the time to implement this? Because unfortunately I know that I won't have time in the near future, so if there is no one jumping in to implement this, I would close the issue for now and reopen it, once I have the time to implement it (or someone else has).
The first step here would be to check how feasible this would be in bigger projects anyway, or if the necessary time explodes (which I could well imagine).
from archunit.
Related Issues (20)
- OnionArchitecture: "withOptionalLayers" and "because" in the same statement causes that withOptionalLayers has no effect HOT 2
- Package information is lost in the Surefire XML reports when using JUnit 5 with Maven HOT 3
- Support for Re-Throw and Wrapping of exception HOT 1
- Support Java 21 HOT 9
- Recommended test for @Transactional does not work in combination with generic interface/super class
- Exception in thread "main" java.lang.IllegalStateException: Never found a JavaCodeUnit that matches supposed origin CodeUnit HOT 5
- Add support to analyse list of classes HOT 1
- Add entry point `onlyClasses` and similar
- Add predicate to find overridden methods
- Enforce ArchTests when module is depended upon HOT 1
- Compatibility issue with logback-classic 1.4.12 HOT 2
- ClassFileImporter fails to load classes with synthetic methods HOT 2
- The tests are running too late HOT 2
- [BUG] Calling getEnclosingClass() on a nested class does provide a JavaClass with no members HOT 3
- fails with Spring Boot Nested Jars HOT 11
- getCallsOfSelf does not return calls made through interface reference HOT 4
- Add method support for function callMethod HOT 2
- Get modifiers of JavaParameter HOT 1
- Layer dependency rule ignores "catch" blocks
- Enum classes not recognized as enums and with with wrong access modifiers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from archunit.