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

Add rule to use ListCrudRepository and ListPagingAndSortingRepository #12

Open
timothysparg opened this issue Aug 1, 2024 · 2 comments

Comments

@timothysparg
Copy link

For most use cases ListCrudRepository and ListPagingAndSortingRepository are preferable.

It would be nice to have a rule that could enable that.

I would also be happy to contribute to that, but would need a bit of pointers on how best to achieve it 😅
My skill level on archunit is not good enough to get past the problem that ListCrudRepository extends CrudRepository ....

@rweisleder
Copy link
Owner

The rule for this could be

classes()
    .that().areAssignableTo(CrudRepository.class)
    .should().beAssignableTo(ListCrudRepository.class)

and the same for PagingAndSortingRepository.

I'll have to think about whether and how this rule can be formulated in a general way. With JPA, it makes sense to define it this way. In the reactive world, the Iterable variants make more sense.

@timothysparg
Copy link
Author

timothysparg commented Aug 1, 2024

neat - thanks for the tip, worked perfectly 🙂

Yep, I definitely get that that there are instances where the Iterable variants are sensible.

I can see this type of problem becoming a fairly common thing (within the context of this type of library).

I had a thought about using the Spring conditionalOn / autoConfiguration ecosystem to help trying to detect when a set of tests should run ... until I realised that would in essence mean runinng a SpringBootTest just to decide which tests to run 😵‍💫

Having enough of these tests that you can start worrying about those kinds of problems would be a nice problem to have in and of itself 😁

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