This commit is contained in:
Phillip Webb 2025-01-24 19:21:48 -08:00
parent 432681734f
commit 4b26a08206
1 changed files with 8 additions and 4 deletions

View File

@ -119,9 +119,9 @@ final class ArchitectureRules {
.stream()
.filter(notAnnotatedWithLazy)
.filter((parameter) -> notOfASafeType.test(parameter.getRawType()))
.forEach((parameter) -> events.add(SimpleConditionEvent.violated(parameter,
.forEach((parameter) -> addViolation(events, parameter,
parameter.getDescription() + " will cause eager initialization as it is "
+ notAnnotatedWithLazy.getDescription() + " and is " + notOfASafeType.getDescription())));
+ notAnnotatedWithLazy.getDescription() + " and is " + notOfASafeType.getDescription()));
}
private static ArchRule allBeanFactoryPostProcessorBeanMethodsShouldBeStaticAndHaveNoParameters() {
@ -193,8 +193,8 @@ final class ArchitectureRules {
if (!properties.containsKey("type") && !properties.containsKey("name")) {
conditionalAnnotation.get("value").ifPresent((value) -> {
if (containsOnlySingleType((JavaType[]) value, item.getReturnType())) {
events.add(SimpleConditionEvent.violated(item, conditionalAnnotation.getDescription()
+ " should not specify only a value that is the same as the method's return type"));
addViolation(events, item, conditionalAnnotation.getDescription()
+ " should not specify only a value that is the same as the method's return type");
}
});
}
@ -265,6 +265,10 @@ final class ArchitectureRules {
};
}
private static void addViolation(ConditionEvents events, Object correspondingObject, String message) {
events.add(SimpleConditionEvent.violated(correspondingObject, message));
}
private static String shouldUse(String string) {
return string + " should be used instead";
}