Code
Konsist – Linter for coding conventions and project architecture

Konsist is a library that guards the consistency of Kotlin projects by promoting the standardization of the Kotlin codebase. It enforces coding conventions and project architecture. Konsist tests are written in Kotlin and can be easily integrated with popular testing frameworks such as JUnit4, JUnit5.
See Konsist documentation for more information.
Examples
Konsist API reflects the structure of Kotlin code. Konsist guards are written in form of unit tests.
General Kotlin Check
@Test
fun `classes with 'UseCase' suffix should reside in 'usecase' package`() {
Konsist.scopeFromProject()
.classes()
.withNameEndingWith("UseCase")
.assert { it.resideInPackage("..usecase..") }
}
Android Specific Check
@Test
fun `classes extending 'ViewModel' should have 'ViewModel' suffix`() {
Konsist.scopeFromProject()
.classes()
.withParentClassOf(ViewModel::class)
.assert { it.name.endsWith("ViewModel") }
}
Spring Specific Check
@Test
fun `interfaces with 'Repository' annotation should have 'Repository' suffix`() {
Konsist
.scopeFromProject()
.interfaces()
.withAllAnnotationsOf(Repository::class)
.assert { it.hasNameEndingWith("Repository") }
}
Getting Started
See Konsist Getting Started for quick start page guide and Snippet page for more examples.
