Skip to content

Commit

Permalink
Updated refs to latest (1.4.0) release (#2846)
Browse files Browse the repository at this point in the history
Co-authored-by: Ktlint Release Workflow <ktlint@github.com>
  • Loading branch information
paul-dingemans and Ktlint Release Workflow authored Oct 24, 2024
1 parent 2ab7cad commit d27db72
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 26 deletions.
13 changes: 9 additions & 4 deletions documentation/release-latest/docs/install/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ All releases of `ktlint` can be downloaded from the [releases](https://github.co
A particular version of `ktlint` can be downloaded with next command which also changes the file to an executable in directory `/usr/local/bin`:

```sh title="Download"
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.3.1/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.4.0/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
```

!!! tip "Curl not installed or behind proxy"
Expand Down Expand Up @@ -168,9 +168,14 @@ ktlint --stdin -F
```

!!! tip "Suppress logging and error output"
Logging output printed to `stdout` can be suppressed by setting `--log-level=none` (see [logging](#logging)).
Output printed to `stderr` can be suppressed in different ways. To ignore all error output, add `2> /dev/null` to the end of the command line. Otherwise, specify a [reporter](#violation-reporting) to write the error output to a file.
Logging output printed to `stdout` can be suppressed by setting `--log-level=none` (see [logging](#logging)).
Output printed to `stderr` can be suppressed in different ways. To ignore all error output, add `2> /dev/null` to the end of the command line. Otherwise, specify a [reporter](#violation-reporting) to write the error output to a file.

If input from `stdin` represents the contents of a file, the file path can be supplied with `stdin-path`. This path is made available for rules to use, the `--format` option will not modify this file.

```shell title="file path from stdin-path"
ktlint --stdin --stdin-path /path/to/file/Foo.kt
```

### Git hooks

Expand Down Expand Up @@ -204,6 +209,6 @@ Options `--stdin` and `--patterns-from-stdin` are mutually exclusive, only one o

Microsoft Windows is not able to run the `ktlint` command directly. Ktlint can be run in following ways on Microsoft Windows:

1. Use the `ktlint.bat` batch file provided as part of the [release](https://github.com/pinterest/ktlint/releases/tag/1.3.1). Add the batch file to your `%PATH%` environment variable for easy access
1. Use the `ktlint.bat` batch file provided as part of the [release](https://github.com/pinterest/ktlint/releases/tag/1.4.0). Add the batch file to your `%PATH%` environment variable for easy access
2. Run `ktlint` using Git Bash
3. Run as `java -jar ktlint`
6 changes: 3 additions & 3 deletions documentation/release-latest/docs/install/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ See [cli usage](../cli) for arguments that can be supplied to `ktlint`.
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-cli</artifactId>
<version>1.3.1</version>
<version>1.4.0</version>
</dependency>
<!-- additional 3rd party ruleset(s) can be specified here -->
</dependencies>
Expand Down Expand Up @@ -117,7 +117,7 @@ configurations {
}
dependencies {
ktlint("com.pinterest.ktlint:ktlint-cli:1.3.1") {
ktlint("com.pinterest.ktlint:ktlint-cli:1.4.0") {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
}
Expand Down Expand Up @@ -167,7 +167,7 @@ The configuration below, defines following task:
val ktlint by configurations.creating

dependencies {
ktlint("com.pinterest.ktlint:ktlint-cli:1.3.1") {
ktlint("com.pinterest.ktlint:ktlint-cli:1.4.0") {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
Expand Down
73 changes: 73 additions & 0 deletions documentation/release-latest/docs/rules/experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,76 @@ Suppress or disable rule (1)
ktlint_standard_square-brackets-spacing = disabled
```
## When-entry bracing
Enforce consistent usages of braces inside the when-statement. All when-entries in the when-statement should use braces around their bodies in case at least one when-entry has a multiline body, or when the body is surrounded by braces.
Braces are helpful for following reasons:
- Bodies of the when-conditions are all aligned at same column position
- Closing braces helps in separating the when-conditions
This rule is not incorporated in the Kotlin Coding conventions, nor in the Android Kotlin Styleguide. It is based on similar behavior in enforcing consistent use of braces in if-else statements. As of that the rule is only enabled automatically for code style `ktlint_official`. It can be enabled explicitly for other code styles.
=== "[:material-heart:](#) Ktlint"
```kotlin
val foo1 =
when (bar) {
BAR1 -> "bar1"
BAR2 -> "bar2"
else -> null
}
val foo2 =
when (bar) {
BAR1 -> {
"bar1"
}
BAR2 -> {
"bar2"
}
else -> {
null
}
}
```
=== "[:material-heart-off-outline:](#) Disallowed"
```kotlin
val foo3 =
when (bar) {
BAR1 -> "bar1"
BAR2 -> {
"bar2"
}
else -> null
}
val foo4 =
when (bar) {
BAR1 -> "bar1"
BAR2 ->
"bar2"
else -> null
}
```
Rule id: `standard:when-entry-spacing`
Suppress or disable rule (1)
{ .annotate }
1. Suppress rule in code with annotation below:
```kotlin
@Suppress("ktlint:standard:when-entry-spacing")
```
Enable rule via `.editorconfig`
```editorconfig
ktlint_standard_when-entry-spacing = enabled
```
Disable rule via `.editorconfig`
```editorconfig
ktlint_standard_when-entry-spacing = disabled
```
Loading

0 comments on commit d27db72

Please sign in to comment.