Add ArchUnit test to prevent exposing Eclipse Collections iml types - #29
Open
mattbertolini wants to merge 2 commits into
Open
Add ArchUnit test to prevent exposing Eclipse Collections iml types#29mattbertolini wants to merge 2 commits into
mattbertolini wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One of the rules I have when writing this library is that no types found in the
org.eclipse.collections.impl.*packages should ever be used in the public API contract. This is because I only want to depend on their definedapiinterfaces. It's ok to use them internally to a method or in private methods, but I don't want to expose them to the public contract. This sounded like a good use case for ArchUnit.I wrote a custom
ArchConditionthat checks the public API contract (public/protected constructor args, public/protected method args and return types, public/protected fields, parent classes, and interface types) for usages of forbidden packages. In my case its only one package right now.This gives me a check to make sure I don't accidentally leak some types I don't want in the public contract while still giving me the opportunity to use them internally in method bodies and private methods.