ArchUnit icon indicating copy to clipboard operation
ArchUnit copied to clipboard

add automatic conversions to violation handling

Open codecholeric opened this issue 1 year ago • 0 comments

The extensive freedom of how to create a ConditionEvent causes problems for any client that needs more structured results (e.g. tools). ViolationHandler provides a convenient API to obtain only those sort of violations that can be handled by a client (e.g. tackling dependencies). However, the type of the correspondingObject attached to the ConditionEvent can take many forms. From classes to methods, method calls, dependencies or aggregated dependencies (like module dependencies) it's hard to determine the possibilities and handle them all. Furthermore, the type of some objects (e.g. ComponentDependency isn't even public, so there is hardly any clean way to handle these objects.

To mitigate this a little we now support transparent conversions between compatible objects. E.g. a component dependency can also be considered a set of class dependencies. ViolationHandler now allows to be used including these conversions that are implemented by standard ArchUnit objects where reasonable. This allows e.g. to obtain all module dependencies as Set<Dependency> for every violation.

codecholeric avatar Feb 18 '24 14:02 codecholeric