Kotlin / Kotlin/ktfmt

Short implementations of functional interfaces could be on a single line

Open
#253 2 comments 2 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Kotlin
Stars
1.3k
Forks
116
Avg merge
4d 10h
Merged PRs (30d)
15

Description

Actual:
```kotlin
fun interface VeryVeryLongCustomInterface {
fun function(options: Options): EndResult
}

val EMPTY_VERY_VERY_LONG_CUSTOM_INTERFACE: VeryVeryLongCustomInterface =
VeryVeryLongCustomInterface {
EndResult
}
```

Preferable, perhaps?
```kotlin
val EMPTY_VERY_VERY_LONG_CUSTOM_INTERFACE: VeryVeryLongCustomInterface =
VeryVeryLongCustomInterface { EndResult }
```

Contributor guide

Open the contributing guide

Research direction

Start by locating the formatter logic and tests that handle Kotlin functional-interface implementations and single-expression lambdas. Compare the actual and preferable examples in the issue, then add coverage showing that the short implementation is kept on one line when appropriate. Done means the formatter produces the requested compact output without regressing related formatting cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.