Skip to content

Commit

Permalink
Updated refs to latest (1.1.0) release (#2457)
Browse files Browse the repository at this point in the history
Co-authored-by: Ktlint Release Workflow <>
  • Loading branch information
paul-dingemans committed Dec 21, 2023
1 parent 19a547d commit 4b55eb3
Show file tree
Hide file tree
Showing 6 changed files with 267 additions and 34 deletions.
8 changes: 4 additions & 4 deletions documentation/release-latest/docs/install/cli.md
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.0.1/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.1.0/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
```

!!! tip "Curl not installed or behind proxy"
Expand Down Expand Up @@ -138,7 +138,7 @@ By default, the `info` log level is used meaning that all log lines at level `in

Some rules can be tweaked via the [`editorconfig file`](../../rules/configuration-ktlint/).

A scaffold of the `.editorconfig file` can be generated with command below. Note: that the generated file only contains configuration settings which are actively used by the [rules which are loaded](#rule-sets):
A scaffold of the `.editorconfig` file can be generated with command below. Note: that the generated file only contains configuration settings which are actively used by the [rules which are loaded](#rule-sets):

```shell title="Generate .editorconfig"
# Specify the code style(ktlint_official, intellij_idea or android_studio) to be used when generating the .editorconfig
Expand All @@ -147,7 +147,7 @@ ktlint generateEditorConfig ktlint_official
ktlint --ruleset=/path/to/custom-ruleset.jar generateEditorConfig android_studio
```

Normally this file is located in the root of your project directory. In case the file is located in a sub folder of the project, the settings of that file only applies to that subdirectory and its folders (recursively). Ktlint automatically detects and reads all `.editorconfig` files in your project.
Normally the `.editorconfig` file is located in the root of your project directory. In case the file is located in a sub folder of the project, the settings of that file only applies to that subdirectory and its folders (recursively). Ktlint automatically detects and reads all `.editorconfig` files in your project.

Use command below, to specify a default `editorconfig`. In case a property is not defined in any `.editorconfig` file on the path to the file, the value from the default file is used. The path may point to any valid file or directory. The path can be relative or absolute. Depending on your OS, the "~" at the beginning of a path is replaced by the user home directory.

Expand Down Expand Up @@ -209,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.0.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.1.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
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.0.1</version>
<version>1.1.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.0.1") {
ktlint("com.pinterest.ktlint:ktlint-cli:1.1.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.0.1") {
ktlint("com.pinterest.ktlint:ktlint-cli:1.1.0") {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
Expand Down
75 changes: 75 additions & 0 deletions documentation/release-latest/docs/rules/experimental.md
Expand Up @@ -333,6 +333,39 @@ The other code styles allow an infinite amount of parameters on the same line (a

Rule id: `class-signature` (`standard` rule set)

## Condition wrapping

Wraps each operand in a multiline condition to a separate line.

=== "[:material-heart:](#) Ktlint"

```kotlin
val foo = bar || baz
if (bar1 ||
bar2 ||
baz1 ||
(baz2 && baz3)
) {
// do somthing
}
```

=== "[:material-heart-off-outline:](#) Disallowed"

```kotlin
val foo =
multiLineOperand(
"bar"
) || baz
if (bar1 || bar2 ||
baz1 || (baz2 && baz3)
) {
// do somthing
}
```

Rule id: `condition-wrapping` (`standard` rule set)

## Function expression body

Rewrites a function body only containing a `return` or `throw` expression to an expression body.
Expand Down Expand Up @@ -477,3 +510,45 @@ Enforce a single whitespace between the modifier list and the function type.
```

Rule id: `function-type-modifier-spacing` (`standard` rule set)

## Mixed condition operators

Conditions should not use a both `&&` and `||` operators between operators at the same level. By using parenthesis the expression is to be clarified.

=== "[:material-heart:](#) Ktlint"

```kotlin
val foo = bar1 && (bar2 || bar3) && bar4
```

=== "[:material-heart-off-outline:](#) Disallowed"

```kotlin
val foo = bar1 &&
bar2 ||
bar3
val foo = bar1 && (bar2 || bar3 && bar4) && bar5
```

Rule id: `mixed-condition-operators` (`standard` rule set)

## Multiline loop

Braces required for multiline for, while, and do statements.

=== "[:material-heart:](#) Ktlint"

```kotlin
for (i in 1..10) {
println(i)
}
```

=== "[:material-heart-off-outline:](#) Disallowed"

```kotlin
for (i in 1..10)
println(i)
```

Rule id: `multiline-loop` (`standard` rule set)
202 changes: 180 additions & 22 deletions documentation/release-latest/docs/rules/standard.md
Expand Up @@ -128,27 +128,6 @@ Lines in a block comment which (exclusive the indentation) start with a `*` shou

Rule id: `block-comment-initial-star-alignment` (`standard` rule set)

## Discouraged comment location

Detect discouraged comment locations (no autocorrect).

!!! note
Kotlin allows comments to be placed almost everywhere. As this can lead to code which is hard to read, most of them will never be used in practice. Ideally each rule takes comments at all possible locations into account. Sometimes this is really hard and not worth the effort. By explicitly forbidding such comment locations, the development of those rules becomes a bit easier.

=== "[:material-heart-off-outline:](#) Disallowed"

```kotlin
fun <T> /* some comment */ foo(t: T) = "some-result"

fun foo() {
if (true)
// some comment
bar()
}
```

Rule id: `discouraged-comment-location` (`standard` rule set)

## Enum entry

Enum entry names should be uppercase underscore-separated or upper camel-case separated.
Expand Down Expand Up @@ -370,6 +349,8 @@ Enforce naming of class and objects.
class Foo

class Foo1

class `class` // Any keyword is allowed when wrapped between backticks
```
=== "[:material-heart:](#) Ktlint JUnit Test"

Expand Down Expand Up @@ -408,6 +389,8 @@ Enforce naming of function.
fun foo() {}

fun fooBar() {}

fun `fun` {} // Any keyword is allowed when wrapped between backticks
```
=== "[:material-heart:](#) Ktlint Test"

Expand Down Expand Up @@ -493,6 +476,8 @@ Enforce naming of property.
val FOO1 = Foo() // In case developer want to communicate that Foo is deeply immutable
}
}

var `package` = "foo" // Any keyword is allowed when wrapped between backticks
```
=== "[:material-heart-off-outline:](#) Disallowed"

Expand All @@ -514,7 +499,7 @@ Enforce naming of property.
}
```

This rule can also be suppressed with the IntelliJ IDEA inspection suppression `PropertyName`.
This rule can also be suppressed with the IntelliJ IDEA inspection suppression `PropertyName` or `ConstPropertyName`.

Rule id: `property-naming` (`standard` rule set)

Expand Down Expand Up @@ -2025,6 +2010,89 @@ Consistent removal (default) or adding of trailing commas on declaration site.

Rule id: `trailing-comma-on-declaration-site` (`standard` rule set)

## Type argument comment

Disallows comments to be placed at certain locations inside a type argument (list). A KDoc is not allowed.

=== "[:material-heart:](#) Ktlint"

```kotlin
fun Foo<
/* some comment */
out Any
>.foo() {}
fun Foo<
// some comment
out Any
>.foo() {}
```

=== "[:material-heart-off-outline:](#) Disallowed"

```kotlin
fun Foo<out /* some comment */ Any>.foo() {}
fun Foo<
out Any, // some comment
>.foo() {}
val fooBar: FooBar<
/** some comment */
Foo,
Bar
>
```

Note: Although code sample below might look ok, it is semantically and programmatically unclear to which element `some comment 1` refers. As of that comments are only allowed when starting on a separate line.
```kotlin
fun Foo<
out Bar1, // some comment 1
// some comment 2
out Bar2, // some comment
>.foo() {}
```

Rule id: `type-argument-comment` (`standard` rule set)

## Type parameter comment

Disallows comments to be placed at certain locations inside a type parameter (list). A KDoc is not allowed.

=== "[:material-heart:](#) Ktlint"

```kotlin
class Foo2<
/* some comment */
out Bar
>
class Foo3<
// some comment
out Bar
>
```

=== "[:material-heart-off-outline:](#) Disallowed"

```kotlin
class Foo1<
/** some comment */
in Bar
>
class Foo2<in /* some comment */ Bar>
class Foo3<
in Bar, // some comment
>
```

Note: Although code sample below might look ok, it is semantically and programmatically unclear to which element `some comment 1` refers. As of that comments are only allowed when starting on a separate line.
```kotlin
class Foo<
out Bar1, // some comment 1
// some comment 2
out Bar2, // some comment
>
```

Rule id: `type-parameter-comment` (`standard` rule set)

## Unnecessary parenthesis before trailing lambda

An empty parentheses block before a lambda is redundant.
Expand All @@ -2043,6 +2111,96 @@ An empty parentheses block before a lambda is redundant.

Rule id: `unnecessary-parentheses-before-trailing-lambda` (`standard` rule set)

## Value argument comment

Disallows comments to be placed at certain locations inside a value argument (list). A KDoc is not allowed.

=== "[:material-heart:](#) Ktlint"

```kotlin
val foo2 =
foo(
/* some comment */
bar = "bar"
)
val foo3 =
foo(
// some comment
bar = "bar"
)
```

=== "[:material-heart-off-outline:](#) Disallowed"

```kotlin
val foo1 = foo(bar /** some comment */ = "bar")
val foo2 = foo(bar /* some comment */ = "bar")
val foo3 =
foo(
bar = // some comment
"bar"
)
```

Note: Although code sample below might look ok, it is semantically and programmatically unclear to which element `some comment 1` refers. As of that comments are only allowed when starting on a separate line.
```kotlin
class Foo<
out Bar1, // some comment 1
// some comment 2
out Bar2, // some comment
>
```

Rule id: `value-argument-comment` (`standard` rule set)

## Value parameter comment

Disallows comments to be placed at certain locations inside a value argument (list). A KDoc is allowed but must start on a separate line.

=== "[:material-heart:](#) Ktlint"

```kotlin
class Foo1(
/** some comment */
bar = "bar"
)
class Foo2(
/* some comment */
bar = "bar"
)
class Foo3(
// some comment
bar = "bar"
)
```

=== "[:material-heart-off-outline:](#) Disallowed"

```kotlin
class Foo2(
bar /** some comment */ = "bar"
)
class Foo2(
bar = /* some comment */ "bar"
)
class Foo3(
bar =
// some comment
"bar"
)
```

Note: Although code sample below might look ok, it is semantically and programmatically unclear to which element `some comment 1` refers. As of that comments are only allowed when starting on a separate line.
```kotlin
class Foo(
bar: Bar1, // some comment 1
// some comment 2
bar2: Bar2, // some comment
)
```

Rule id: `value-parameter-comment` (`standard` rule set)

## Wrapping

### Argument list wrapping
Expand Down

0 comments on commit 4b55eb3

Please sign in to comment.