|
|
|
@ -94,7 +94,8 @@ public abstract class ArchitectureCheck extends DefaultTask { |
|
|
|
noClassesShouldCallURLEncoderWithStringEncoding(), noClassesShouldCallURLDecoderWithStringEncoding(), |
|
|
|
noClassesShouldCallURLEncoderWithStringEncoding(), noClassesShouldCallURLDecoderWithStringEncoding(), |
|
|
|
noClassesShouldLoadResourcesUsingResourceUtils(), noClassesShouldCallStringToUpperCaseWithoutLocale(), |
|
|
|
noClassesShouldLoadResourcesUsingResourceUtils(), noClassesShouldCallStringToUpperCaseWithoutLocale(), |
|
|
|
noClassesShouldCallStringToLowerCaseWithoutLocale(), |
|
|
|
noClassesShouldCallStringToLowerCaseWithoutLocale(), |
|
|
|
conditionalOnMissingBeanShouldNotSpecifyOnlyATypeThatIsTheSameAsMethodReturnType()); |
|
|
|
conditionalOnMissingBeanShouldNotSpecifyOnlyATypeThatIsTheSameAsMethodReturnType(), |
|
|
|
|
|
|
|
enumSourceShouldNotSpecifyOnlyATypeThatIsTheSameAsMethodParameterType()); |
|
|
|
getRules().addAll(getProhibitObjectsRequireNonNull() |
|
|
|
getRules().addAll(getProhibitObjectsRequireNonNull() |
|
|
|
.map((prohibit) -> prohibit ? noClassesShouldCallObjectsRequireNonNull() : Collections.emptyList())); |
|
|
|
.map((prohibit) -> prohibit ? noClassesShouldCallObjectsRequireNonNull() : Collections.emptyList())); |
|
|
|
getRuleDescriptions().set(getRules().map((rules) -> rules.stream().map(ArchRule::getDescription).toList())); |
|
|
|
getRuleDescriptions().set(getRules().map((rules) -> rules.stream().map(ArchRule::getDescription).toList())); |
|
|
|
@ -299,6 +300,35 @@ public abstract class ArchitectureCheck extends DefaultTask { |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ArchRule enumSourceShouldNotSpecifyOnlyATypeThatIsTheSameAsMethodParameterType() { |
|
|
|
|
|
|
|
return ArchRuleDefinition.methods() |
|
|
|
|
|
|
|
.that() |
|
|
|
|
|
|
|
.areAnnotatedWith("org.junit.jupiter.params.provider.EnumSource") |
|
|
|
|
|
|
|
.should(notSpecifyOnlyATypeThatIsTheSameAsTheMethodParameterType()) |
|
|
|
|
|
|
|
.allowEmptyShould(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ArchCondition<? super JavaMethod> notSpecifyOnlyATypeThatIsTheSameAsTheMethodParameterType() { |
|
|
|
|
|
|
|
return new ArchCondition<>("not specify only a type that is the same as the method's parameter type") { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void check(JavaMethod item, ConditionEvents events) { |
|
|
|
|
|
|
|
JavaAnnotation<JavaMethod> conditional = item |
|
|
|
|
|
|
|
.getAnnotationOfType("org.junit.jupiter.params.provider.EnumSource"); |
|
|
|
|
|
|
|
Map<String, Object> properties = conditional.getProperties(); |
|
|
|
|
|
|
|
if (properties.size() == 1 && item.getParameterTypes().size() == 1) { |
|
|
|
|
|
|
|
conditional.get("value").ifPresent((value) -> { |
|
|
|
|
|
|
|
if (value.equals(item.getParameterTypes().get(0))) { |
|
|
|
|
|
|
|
events.add(SimpleConditionEvent.violated(item, conditional.getDescription() |
|
|
|
|
|
|
|
+ " should not specify only a value that is the same as the method's parameter type")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setClasses(FileCollection classes) { |
|
|
|
public void setClasses(FileCollection classes) { |
|
|
|
this.classes = classes; |
|
|
|
this.classes = classes; |
|
|
|
} |
|
|
|
} |
|
|
|
|