Skip to content

feat(#174660): add new code conventions rules#1

Open
kirill-pyatunin wants to merge 1 commit intoclutcher:mainfrom
kirill-pyatunin:174660
Open

feat(#174660): add new code conventions rules#1
kirill-pyatunin wants to merge 1 commit intoclutcher:mainfrom
kirill-pyatunin:174660

Conversation

@kirill-pyatunin
Copy link
Copy Markdown

No description provided.

Comment on lines +149 to +150
moduleBasePackage + properties.getDomainModelPackageMatcher(),
"java..",
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to props

return noClasses()
.that().resideInAPackage(moduleBasePackage + properties.getDomainPackageMatcher())
.should().dependOnClassesThat(
resideInAPackage("..app.domain..")
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

.that().resideInAPackage(moduleBasePackage + properties.getDomainPackageMatcher())
.should().dependOnClassesThat(
resideInAPackage("..app.domain..")
.and(resideOutsideOfPackage(moduleBasePackage + ".."))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? check and remove


String getApplicationRoot();

default String getDomainModelPackageMatcher() {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check. it should already exists in configs

.allowEmptyShould(true);
}

public static ArchRule ruleForCrossModuleDomainIsolation(String moduleBasePackage, HexagonalArchitectureSettings properties) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

.allowEmptyShould(true);
}

public static ArchRule ruleForDomainModelNotExposedInDrivingAdapters(String moduleBasePackage, HexagonalArchitectureSettings properties) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check rule *Test that domain.model is not used to be returned from in rest controller - only for controllers

Copy link
Copy Markdown
Author

@kirill-pyatunin kirill-pyatunin Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*Mapper class
mappers package?

.allowEmptyShould(true);
}

static DescribedPredicate<JavaClass> areNotAnnotatedWithAnyOf(String[] annotationNames) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not arch rule - move

moduleBasePackage + properties.getDomainModelPackageMatcher(),
"java..",
"lombok..",
"org.springframework.stereotype..",
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    • too wide. component and service

};
}

public static ArchRule ruleForNoAutowiredInDomain(String moduleBasePackage, HexagonalArchitectureSettings properties) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove.

.allowEmptyShould(true);
}

public static ArchRule ruleForNoAutowiredFieldsInDomain(String moduleBasePackage, HexagonalArchitectureSettings properties) {
Copy link
Copy Markdown
Author

@kirill-pyatunin kirill-pyatunin Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!

.allowEmptyShould(true);
}

public static ArchRule ruleForDomainModelOnlyRecordsOrPojos(String moduleBasePackage, HexagonalArchitectureSettings properties) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should check records or pojos

.allowEmptyShould(true);
}

public static ArchRule ruleForSpringAdapterNaming(String moduleBasePackage, HexagonalArchitectureSettings properties) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!

}


// --- Custom ArchConditions ---
Copy link
Copy Markdown
Author

@kirill-pyatunin kirill-pyatunin Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move ArchConditions

import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.fields;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;

public class CodeConventionsRulesLibrary {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create interface.
Create property to allow on/off or redefine rules, add rule

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id rule = true / false, true by default (exmpl)

@@ -0,0 +1,24 @@
dev:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Comment thread build.gradle.kts
extra["springBootVersion"] = "3.5.3"
extra["springModulithVersion"] = "2.0.3"
extra["springBootVersion"] = "4.0.2"
extra["archUnitVersion"] = "1.4.1"
Copy link
Copy Markdown
Author

@kirill-pyatunin kirill-pyatunin Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

142 ver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant