feat(#174660): add new code conventions rules - #1
Conversation
|
|
||
| String getApplicationRoot(); | ||
|
|
||
| default String getDomainModelPackageMatcher() { |
There was a problem hiding this comment.
check. it should already exists in configs
| .allowEmptyShould(true); | ||
| } | ||
|
|
||
| public static ArchRule ruleForCrossModuleDomainIsolation(String moduleBasePackage, HexagonalArchitectureSettings properties) { |
| .allowEmptyShould(true); | ||
| } | ||
|
|
||
| public static ArchRule ruleForDomainModelNotExposedInDrivingAdapters(String moduleBasePackage, HexagonalArchitectureSettings properties) { |
There was a problem hiding this comment.
Check rule *Test that domain.model is not used to be returned from in rest controller - only for controllers
There was a problem hiding this comment.
*Mapper class
mappers package?
| .allowEmptyShould(true); | ||
| } | ||
|
|
||
| static DescribedPredicate<JavaClass> areNotAnnotatedWithAnyOf(String[] annotationNames) { |
| moduleBasePackage + properties.getDomainModelPackageMatcher(), | ||
| "java..", | ||
| "lombok..", | ||
| "org.springframework.stereotype..", |
There was a problem hiding this comment.
-
- too wide. component and service
| }; | ||
| } | ||
|
|
||
| public static ArchRule ruleForNoAutowiredInDomain(String moduleBasePackage, HexagonalArchitectureSettings properties) { |
| .allowEmptyShould(true); | ||
| } | ||
|
|
||
| public static ArchRule ruleForNoAutowiredFieldsInDomain(String moduleBasePackage, HexagonalArchitectureSettings properties) { |
| .allowEmptyShould(true); | ||
| } | ||
|
|
||
| public static ArchRule ruleForDomainModelOnlyRecordsOrPojos(String moduleBasePackage, HexagonalArchitectureSettings properties) { |
There was a problem hiding this comment.
should check records or pojos
| .allowEmptyShould(true); | ||
| } | ||
|
|
||
| public static ArchRule ruleForSpringAdapterNaming(String moduleBasePackage, HexagonalArchitectureSettings properties) { |
| } | ||
|
|
||
|
|
||
| // --- Custom ArchConditions --- |
| import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.fields; | ||
| import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; | ||
|
|
||
| public class CodeConventionsRulesLibrary { |
There was a problem hiding this comment.
create interface.
Create property to allow on/off or redefine rules, add rule
There was a problem hiding this comment.
id rule = true / false, true by default (exmpl)
| @@ -0,0 +1,24 @@ | |||
| dev: | |||
| extra["springBootVersion"] = "3.5.3" | ||
| extra["springModulithVersion"] = "2.0.3" | ||
| extra["springBootVersion"] = "4.0.2" | ||
| extra["archUnitVersion"] = "1.4.1" |
| public static ArchRule ruleForNoDtoInClassNames(String domainPackage) { | ||
| return noClasses() | ||
| .that().resideInAPackage(domainPackage) | ||
| .should().haveSimpleNameContaining("Dto") |
There was a problem hiding this comment.
Is it case sensitive? Suppose we should check DTO also? And what about Data? Suppose we should exclued that also.
| return classes() | ||
| .that().resideInAPackage(moduleBasePackage + properties.getDomainModelPackageMatcher()) | ||
| .should().onlyDependOnClassesThat() | ||
| .resideInAnyPackage(allPackages) |
There was a problem hiding this comment.
Is it working properly? Does it allow to use domain classes inside domain itself?
| String domainModelPackage = moduleBasePackage + properties.getDomainModelPackageMatcher(); | ||
| return classes() | ||
| .that().areAnnotatedWith("org.springframework.web.bind.annotation.RestController") | ||
| .or().areAnnotatedWith("org.springframework.stereotype.Controller") |
There was a problem hiding this comment.
Does it also covers graphql controllers?
| public static ArchRule ruleForDomainModelOnlyRecordsOrPojos(String moduleBasePackage, HexagonalArchitectureSettings properties) { | ||
| return classes() | ||
| .that().resideInAPackage(moduleBasePackage + properties.getDomainModelPackageMatcher()) | ||
| .should().notBeInterfaces() |
There was a problem hiding this comment.
It is wrongly working. Pojo is a specific class with fields and getter/setter naming convention. Checkin on not interface is not enough.
|
|
||
| ApiForCustomizingArchRuleCreation withDevStandardsRule(RuleProvider provider); | ||
|
|
||
| ApiForCustomizingArchRuleCreation withCodeConventionsRule(ApiForArchRuleCreation apiForArchRuleCreation); |
There was a problem hiding this comment.
Can you remind me difference between dev standards rules and code convetion rules? Looks same for me.
Also we need to update both readme and claude with all new changes.
No description provided.