https://github.com/doist/detekt-rules
Detekt rules for Doist Kotlin projects
https://github.com/doist/detekt-rules
detekt-plugin detekt-rules kotlin
Last synced: 12 days ago
JSON representation
Detekt rules for Doist Kotlin projects
- Host: GitHub
- URL: https://github.com/doist/detekt-rules
- Owner: Doist
- License: apache-2.0
- Created: 2022-07-12T13:52:10.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-19T13:41:07.000Z (about 1 month ago)
- Last Synced: 2025-03-28T10:21:36.570Z (30 days ago)
- Topics: detekt-plugin, detekt-rules, kotlin
- Language: Kotlin
- Homepage:
- Size: 276 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Doist detekt rules
This repository contains custom detekt rules based on Doist internal coding conventions.
## How to use it
First add [detekt](https://github.com/detekt/detekt) to your repository. Then follow
[adding more rule sets](https://github.com/detekt/detekt#adding-more-rule-sets) instructions and add this
detekt plugin in your gradle file:
```
dependencies {
detektPlugins("com.doist.detekt:detekt-rules:[version]")
}
```## Release
To release, update the version in the `build.gradle.kts` file and run:
```
git add build.gradle.kts
git commit -m "Release X.Y.Z"
git tag vX.Y.Z
git push --tags
```
After that GitHub actions will automatically create new release and publish it.## Rules
### NoBlankNewLineAfterClassHeader
This rule reports every class that has an empty line between a class header and its body.
### ConsistentWhenEntries
This rule reports when statements that have some entries single line and some multiline.
### SingleLineWhenEntryExpressionsAreWrapped
This rule reports every when entry expression that is on a separate line and is not wrapped with
brackets.For example this is incorrect:
```kotlin
val a = when {
c == b ->
true
else ->
false
}
```
Instead it should be:
```kotlin
val a = when {
c == b -> true
else -> false
}
// or
val a = when {
c == b -> {
true
}
else -> {
false
}
}
```### MutableObservablePropertyIsPrivate
This rule reports exposed `MutableLive...` and `MutableStateFlow` properties. They should be
private.### NoNotNullOperator
This rule reports `!!` usage. `requireNotNull` should be used instead.
### TodoPattern
Reports when TODO comment does not match a pattern. Default pattern is `// TODO(.+): .*`.
### NewLineAfterSuperCall
This rule reports if an override function does not have a new line after the super call.
For example this is incorrect:
```kotlin
override fun foo() {
super.foo()
bar.bazinga()
}
```
Instead it should be:
```kotlin
override fun foo() {
super.foo()
bar.bazinga()
}
```