|
36 | 36 | import com.tngtech.archunit.core.domain.JavaClass.Predicates;
|
37 | 37 | import com.tngtech.archunit.core.domain.JavaClasses;
|
38 | 38 | import com.tngtech.archunit.core.domain.JavaMethod;
|
| 39 | +import com.tngtech.archunit.core.domain.JavaModifier; |
39 | 40 | import com.tngtech.archunit.core.domain.JavaParameter;
|
40 | 41 | import com.tngtech.archunit.core.domain.JavaType;
|
41 | 42 | import com.tngtech.archunit.core.domain.properties.CanBeAnnotated;
|
@@ -97,7 +98,7 @@ public ArchitectureCheck() {
|
97 | 98 | noClassesShouldLoadResourcesUsingResourceUtils(), noClassesShouldCallStringToUpperCaseWithoutLocale(),
|
98 | 99 | noClassesShouldCallStringToLowerCaseWithoutLocale(),
|
99 | 100 | conditionalOnMissingBeanShouldNotSpecifyOnlyATypeThatIsTheSameAsMethodReturnType(),
|
100 |
| - enumSourceShouldNotSpecifyOnlyATypeThatIsTheSameAsMethodParameterType()); |
| 101 | + enumSourceShouldNotSpecifyOnlyATypeThatIsTheSameAsMethodParameterType(), conditionsShouldNotBePublic()); |
101 | 102 | getRules().addAll(getProhibitObjectsRequireNonNull()
|
102 | 103 | .map((prohibit) -> prohibit ? noClassesShouldCallObjectsRequireNonNull() : Collections.emptyList()));
|
103 | 104 | getRuleDescriptions().set(getRules().map((rules) -> rules.stream().map(ArchRule::getDescription).toList()));
|
@@ -254,6 +255,20 @@ private ArchRule noClassesShouldCallURLEncoderWithStringEncoding() {
|
254 | 255 | .because("java.net.URLEncoder.encode(String s, Charset charset) should be used instead");
|
255 | 256 | }
|
256 | 257 |
|
| 258 | + private ArchRule conditionsShouldNotBePublic() { |
| 259 | + String springBootCondition = "org.springframework.boot.autoconfigure.condition.SpringBootCondition"; |
| 260 | + return ArchRuleDefinition.noClasses() |
| 261 | + .that() |
| 262 | + .areAssignableTo(springBootCondition) |
| 263 | + .and() |
| 264 | + .doNotHaveModifier(JavaModifier.ABSTRACT) |
| 265 | + .and() |
| 266 | + .areNotAnnotatedWith(Deprecated.class) |
| 267 | + .should() |
| 268 | + .bePublic() |
| 269 | + .allowEmptyShould(true); |
| 270 | + } |
| 271 | + |
257 | 272 | private ArchRule noClassesShouldCallURLDecoderWithStringEncoding() {
|
258 | 273 | return ArchRuleDefinition.noClasses()
|
259 | 274 | .should()
|
|
0 commit comments