Skip to content

Commit

Permalink
Clarify value default of `ktlint_function_signature_body_expression…
Browse files Browse the repository at this point in the history
…_wrapping` (#2472)

Closes #2471
  • Loading branch information
paul-dingemans committed Dec 29, 2023
1 parent c1440aa commit 0750fe2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ This setting only takes effect when rule `function-signature` is enabled.

Setting `ktlint_function_signature_body_expression_wrapping` determines if and when the expression body of a function is wrapped to a new line. This setting can be set to value `default`, `multiline` or `always`.

!!! note
In this context `default` means the default behavior of the IntelliJ IDEA formatter. If not set explicitly, this style is used by code styles `intellij_idea` and `android_studio`. Code style `ktlint_official` uses style `multiline` when this setting has no value.

When set to `default`, the first line of a body expression is appended to the function signature as long as the max line length is not exceeded.

```kotlin title="ktlint_function_signature_body_expression_wrapping=default (or when not set)"
```kotlin title="ktlint_function_signature_body_expression_wrapping=default"
// Given that the function signature has to be written as a single line function signature
fun someFunction(a: Any, b: Any): String = "some-result"
.uppercase()
Expand Down
7 changes: 5 additions & 2 deletions documentation/snapshot/docs/rules/configuration-ktlint.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ This setting only takes effect when rule `function-signature` is enabled.

## Wrapping the expression body of a function

Setting `ktlint_function_signature_body_expression_wrapping` determines if and when the expression body of a function is wrapped to a new line. This setting can be set to value `default`, `multiline` or `always`.
Setting `ktlint_function_signature_body_expression_wrapping` determines if and when the expression body of a function is wrapped to a new line. This setting can be set to value `default`, `multiline` or `always`.

!!! note
In this context `default` means the default behavior of the IntelliJ IDEA formatter. If not set explicitly, this style is used by code styles `intellij_idea` and `android_studio`. Code style `ktlint_official` uses style `multiline` when this setting has no value.

When set to `default`, the first line of a body expression is appended to the function signature as long as the max line length is not exceeded.

```kotlin title="ktlint_function_signature_body_expression_wrapping=default (or when not set)"
```kotlin title="ktlint_function_signature_body_expression_wrapping=default"
// Given that the function signature has to be written as a single line function signature
fun someFunction(a: Any, b: Any): String = "some-result"
.uppercase()
Expand Down

0 comments on commit 0750fe2

Please sign in to comment.