Skip to content

Commit 67a585e

Browse files
committed
Merge branch '3.3.x' into 3.4.x
2 parents 3f00b08 + 4b26a08 commit 67a585e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ private static void allBeanPostProcessorBeanMethodsShouldBeStaticAndNotCausePrem
120120
.stream()
121121
.filter(notAnnotatedWithLazy)
122122
.filter((parameter) -> notOfASafeType.test(parameter.getRawType()))
123-
.forEach((parameter) -> events.add(SimpleConditionEvent.violated(parameter,
123+
.forEach((parameter) -> addViolation(events, parameter,
124124
parameter.getDescription() + " will cause eager initialization as it is "
125-
+ notAnnotatedWithLazy.getDescription() + " and is " + notOfASafeType.getDescription())));
125+
+ notAnnotatedWithLazy.getDescription() + " and is " + notOfASafeType.getDescription()));
126126
}
127127

128128
private static ArchRule allBeanFactoryPostProcessorBeanMethodsShouldBeStaticAndHaveOnlyInjectEnvironment() {
@@ -140,7 +140,7 @@ private static ArchCondition<JavaMethod> onlyInjectEnvironment() {
140140

141141
private static void onlyInjectEnvironment(JavaMethod item, ConditionEvents events) {
142142
if (item.getParameters().stream().anyMatch(ArchitectureRules::isNotEnvironment)) {
143-
events.add(SimpleConditionEvent.violated(item, item.getDescription() + " should only inject Environment"));
143+
addViolation(events, item, item.getDescription() + " should only inject Environment");
144144
}
145145
}
146146

@@ -208,8 +208,8 @@ private static ArchCondition<? super JavaMethod> notSpecifyOnlyATypeThatIsTheSam
208208
if (!properties.containsKey("type") && !properties.containsKey("name")) {
209209
conditionalAnnotation.get("value").ifPresent((value) -> {
210210
if (containsOnlySingleType((JavaType[]) value, item.getReturnType())) {
211-
events.add(SimpleConditionEvent.violated(item, conditionalAnnotation.getDescription()
212-
+ " should not specify only a value that is the same as the method's return type"));
211+
addViolation(events, item, conditionalAnnotation.getDescription()
212+
+ " should not specify only a value that is the same as the method's return type");
213213
}
214214
});
215215
}
@@ -237,8 +237,8 @@ private static void notSpecifyOnlyATypeThatIsTheSameAsTheMethodParameterType(Jav
237237
if (properties.size() == 1 && item.getParameterTypes().size() == 1) {
238238
enumSourceAnnotation.get("value").ifPresent((value) -> {
239239
if (value.equals(item.getParameterTypes().get(0))) {
240-
events.add(SimpleConditionEvent.violated(item, enumSourceAnnotation.getDescription()
241-
+ " should not specify only a value that is the same as the method's parameter type"));
240+
addViolation(events, item, enumSourceAnnotation.getDescription()
241+
+ " should not specify only a value that is the same as the method's parameter type");
242242
}
243243
});
244244
}
@@ -297,6 +297,10 @@ public void check(T item, ConditionEvents events) {
297297
};
298298
}
299299

300+
private static void addViolation(ConditionEvents events, Object correspondingObject, String message) {
301+
events.add(SimpleConditionEvent.violated(correspondingObject, message));
302+
}
303+
300304
private static String shouldUse(String string) {
301305
return string + " should be used instead";
302306
}

0 commit comments

Comments
 (0)