From @mhalbritter in https://github.com/spring-io/spring-javaformat/issues/339:
We should add a rule preventing calls to
Objects.requireNonNull(), instead we should useAssert.notNull()from Spring Framework.Objects.requireNonNull()throws aNullPointerException, whileAssert.notNull()throws aIllegalArgumentException.
Checkstyle can't do this accurately. We can do it in our own build instead using ArchUnit by adding a rule to the ArchitectureCheck task.
Comment From: ivamly
Hello!
I’m relatively new to open source contributions, but I’m confident that I can handle this task. Could I get started on this?
Thank you!
Comment From: philwebb
Thanks @ivamly, you might want to look at this code which is pretty similar to what we want to do.
Comment From: ivamly
Hello!
Thanks for giving me the chance to tackle this task. I’m a bit confused about the code snippet you shared. I was initially thinking we’d be adding a rule directly in ArchitectureCheck.java.
@philwebb, could you clarify how the provided code fits into the task? Any guidance would be super helpful!
Thanks again for the support!
Comment From: wilkinsona
@ivamly I suspect that was a stale clipboard entry and Phil meant to link to this code. It'd also be good to add a test to ArchitectureCheckTests too please.
Comment From: philwebb
Yeah, sorry. Too many tabs open and I copied the wrong thing! I meant to link to https://github.com/spring-projects/spring-boot/blob/f1e98d0a73f842d7e163ed248315634d42893ce5/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureCheck.java#L198-L203
Comment From: ivamly
Thanks for the clarification! I’ll check out the code and add the rule and tests.
Comment From: wilkinsona
Closing in favor of #41611. Thanks for the PR, @ivamly!