Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/LemonAppDev/konsist
Konsist is a powerful static code analyzer tailored for Kotlin, focused on ensuring codebase consistency and adherence to coding conventions.
https://github.com/LemonAppDev/konsist
Last synced: 9 days ago
JSON representation
Konsist is a powerful static code analyzer tailored for Kotlin, focused on ensuring codebase consistency and adherence to coding conventions.
- Host: GitHub
- URL: https://github.com/LemonAppDev/konsist
- Owner: LemonAppDev
- License: apache-2.0
- Created: 2023-03-30T06:37:57.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-28T07:47:10.000Z (19 days ago)
- Last Synced: 2024-10-29T15:34:19.427Z (18 days ago)
- Language: Kotlin
- Homepage: https://docs.konsist.lemonappdev.com
- Size: 14.3 MB
- Stars: 1,302
- Watchers: 12
- Forks: 29
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-list - LemonAppDev/konsist - Konsist is a powerful static code analyzer tailored for Kotlin, focused on ensuring codebase consistency and adherence to coding conventions. (Kotlin)
README
![Konsist](misc/konsist-logo/logo.png)
==========[![Kotlin](https://img.shields.io/badge/Kotlin-blue.svg?style=flat&logo=kotlin)](https://kotlinlang.org)
![Check Workflow](https://github.com/LemonAppDev/konsist/actions/workflows/check.yml/badge.svg)
[](https://central.sonatype.com/artifact/com.lemonappdev/konsist)Konsist is a linter that guards the consistency of [Kotlin](https://kotlinlang.org/) projects by enforcing a cohesive code structure
and unified architecture. Konsist guards are written in the form of unit tests ([JUnit](https://junit.org/) / [Kotest](https://kotest.io/)).## Dependencies
```kotlin
// Gradle Kotlin:
testImplementation("com.lemonappdev:konsist:0.16.1")// Gradle Groovy:
testImplementation "com.lemonappdev:konsist:0.16.1"// Maven:
com.lemonappdev
konsist
0.16.1
test```
Check the [Konsist documentation](https://docs.konsist.lemonappdev.com/) to learn more about Konsist and take a
look at [getting started guide](https://docs.konsist.lemonappdev.com/getting-started/getting-started).## Examples
Konsist API reflects the structure of Kotlin code. All declarations such as classes, functions, and properties can be
queried and verified with the Konsist API. Take a look at a few examples below.### General Kotlin Check
```kotlin
@Test
fun `classes with 'UseCase' suffix should reside in 'usecase' package`() {
Konsist.scopeFromProject()
.classes()
.withNameEndingWith("UseCase")
.assertTrue { it.resideInPackage("..usecase..") }
}
```### Android Specific Check
```kotlin
@Test
fun `classes extending 'ViewModel' should have 'ViewModel' suffix`() {
Konsist.scopeFromProject()
.classes()
.withAllParentsOf(ViewModel::class)
.assertTrue { it.name.endsWith("ViewModel") }
}
```### Spring Specific Check
```kotlin
@Test
fun `interfaces with 'Repository' annotation should have 'Repository' suffix`() {
Konsist
.scopeFromProject()
.interfaces()
.withAllAnnotationsOf(Repository::class)
.assertTrue { it.hasNameEndingWith("Repository") }
}
```### Architecture Layers Check
```kotlin
@Test
fun `clean architecture layers have correct dependencies`() {
Konsist
.scopeFromProduction()
.assertArchitecture {
// Define layers
val domain = Layer("Domain", "com.myapp.domain..")
val presentation = Layer("Presentation", "com.myapp.presentation..")
val data = Layer("Data", "com.myapp.data..")// Define architecture assertions
domain.dependsOnNothing()
presentation.dependsOn(domain)
data.dependsOn(domain)
}
}
```
Check out our [snippet](https://docs.konsist.lemonappdev.com/inspiration/snippets) page for a feast of examples!
## ArticlesRead the [Konsist articles](https://docs.konsist.lemonappdev.com/getting-started/getting-started/articles) to gain valuable insights into best practices and strategies for maintaining consistency in your projects.
## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=LemonAppDev/konsist&type=Date)](https://star-history.com/#LemonAppDev/konsist&Date)
## Community & Support
Write a message on the [#konsist channel](https://kotlinlang.slack.com/archives/C05QG9FD6KS) at kotlinlang Slack
Workspace (preferred) or start a [GitHub discussion](https://github.com/LemonAppDev/konsist/discussions).## Contributing
Please be sure to review Konsist [contributing guidelines](https://docs.konsist.lemonappdev.com/help/contributing)
to learn how to support the project.## Licence
Konsist is distributed under the terms of the Apache License (Version 2.0). See [LICENSE.md](LICENSE) for details.