Skip to content

Commit

Permalink
Update README to reflect latest behavior changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed Oct 22, 2022
1 parent 91a7f56 commit 203414b
Showing 1 changed file with 34 additions and 53 deletions.
87 changes: 34 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ kotlinter {
reporters = arrayOf("checkstyle", "plain")
experimentalRules = false
disabledRules = emptyArray()
ktlintVersion = "x.y.z"
}
```

Expand All @@ -171,6 +172,7 @@ kotlinter {
reporters = ['checkstyle', 'plain']
experimentalRules = false
disabledRules = []
ktlintVersion = 'x.y.z'
}
```

Expand All @@ -188,6 +190,9 @@ disabledRules = ["no-wildcard-imports"]
```
You must prefix rule ids not part of the standard rule set with `<rule-set-id>:<rule-id>`. For example `experimental:annotation`.

There is a basic support for overriding `ktlintVersion`, but the plugin doesn't guarantee backwards compatibility with all `ktlint` versions.
Errors like `java.lang.NoSuchMethodError:` or `com/pinterest/ktlint/core/KtLint$Params` can be thrown if provided `ktlint` version isn't compatible with the latest ktlint apis.

### Editorconfig

Kotlinter will configure itself using an `.editorconfig` file if one is present.
Expand Down Expand Up @@ -225,6 +230,34 @@ tasks.named('lintKotlinMain') {

Note that exclude paths are relative to the package root.

#### Advanced
By default, `Kotlinter` Gradle workers will use 256MB of heap size. To adjust this setting use:
<details>
<summary>Kotlin</summary>

```kotlin
import org.jmailen.gradle.kotlinter.tasks.ConfigurableKtLintTask

tasks.withType<ConfigurableKtLintTask> {
workerMaxHeapSize.set("512m")
}
```

</details>

<details>
<summary>Groovy</summary>

```groovy
import org.jmailen.gradle.kotlinter.tasks.ConfigurableKtLintTask
tasks.withType(ConfigurableKtLintTask::class).configureEach {
workerMaxHeapSize.set("512m")
}
```

</details>

### Custom Tasks

If you aren't using autoconfiguration from a supported plugin or otherwise need to handle additional source code, you can create custom tasks:
Expand Down Expand Up @@ -284,61 +317,9 @@ tasks.register('ktFormat', FormatTask) {

</details>

### Custom ktlint version

If you need to use a different version of `ktlint` you can override the dependency.

<details open>
<summary>Kotlin</summary>

```kotlin
buildscript {
configurations.classpath {
resolutionStrategy {
force(
"com.pinterest.ktlint:ktlint-core:0.39.0",
"com.pinterest.ktlint:ktlint-reporter-checkstyle:0.39.0",
"com.pinterest.ktlint:ktlint-reporter-json:0.39.0",
"com.pinterest.ktlint:ktlint-reporter-html:0.39.0",
"com.pinterest.ktlint:ktlint-reporter-plain:0.39.0",
"com.pinterest.ktlint:ktlint-reporter-sarif:0.39.0",
"com.pinterest.ktlint:ktlint-ruleset-experimental:0.39.0",
"com.pinterest.ktlint:ktlint-ruleset-standard:0.39.0"
)
}
}
}
```

</details>

<details>
<summary>Groovy</summary>

```groovy
buildscript {
configurations.classpath {
resolutionStrategy {
force(
"com.pinterest.ktlint:ktlint-core:0.39.0",
"com.pinterest.ktlint:ktlint-reporter-checkstyle:0.39.0",
"com.pinterest.ktlint:ktlint-reporter-json:0.39.0",
"com.pinterest.ktlint:ktlint-reporter-html:0.39.0",
"com.pinterest.ktlint:ktlint-reporter-plain:0.39.0",
"com.pinterest.ktlint:ktlint-reporter-sarif:0.39.0",
"com.pinterest.ktlint:ktlint-ruleset-experimental:0.39.0",
"com.pinterest.ktlint:ktlint-ruleset-standard:0.39.0"
)
}
}
}
```

</details>

### Custom Rules

You can add custom ktlint RuleSets using the `ktlintRuleSet` dependency:
You can add custom `ktlint` RuleSets using the `ktlintRuleSet` dependency:

<details open>
<summary>Kotlin</summary>
Expand Down

0 comments on commit 203414b

Please sign in to comment.