Skip to content

Commit

Permalink
Changed continuation_indent_size to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
shyiko committed Nov 30, 2017
1 parent f49e0b6 commit ed26117
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ ktlint recognizes the following [.editorconfig](http://editorconfig.org/) proper
# possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely)
indent_size=4
# possible values: number (e.g. 2), "unset"
# it's automatically set to 8 on `ktlint --android ...` (per Android Kotlin Style Guide)
continuation_indent_size=unset
# true (recommended) / false
insert_final_newline=unset
Expand Down Expand Up @@ -265,7 +264,6 @@ Go to `File -> Settings... -> Editor`
- uncheck `Method declaration parameters -> Align when multiline`.
- (optional but recommended) open `Tabs and Indents` tab
- change `Continuation indent` to 4
(to be compliant with [Android Kotlin Style Guide](https://android.github.io/kotlin-guides/style.html) value should stay equal 8).
- `Inspections`
- change `Severity` level of `Unused import directive`, `Redundant semicolon` and (optional but recommended) `Unused symbol` to `ERROR`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class IndentationRule : Rule("indent") {
// indentation size recommended by JetBrains
private const val DEFAULT_INDENT = 4
private const val DEFAULT_CONTINUATION_INDENT = 4
// Android Kotlin Style Guide
private const val DEFAULT_CONTINUATION_INDENT_ANDROID = 8
}

private var indent = -1
Expand All @@ -45,8 +43,7 @@ class IndentationRule : Rule("indent") {
val indentSize = editorConfig.get("indent_size")
val continuationIndentSize = editorConfig.get("continuation_indent_size")
indent = indentSize?.toIntOrNull() ?: if (indentSize?.toLowerCase() == "unset") -1 else DEFAULT_INDENT
continuationIndent = continuationIndentSize?.toIntOrNull()
?: if (android) DEFAULT_CONTINUATION_INDENT_ANDROID else DEFAULT_CONTINUATION_INDENT
continuationIndent = continuationIndentSize?.toIntOrNull() ?: DEFAULT_CONTINUATION_INDENT
return
}
if (indent <= 0 || continuationIndent <= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object IntellijIDEAIntegration {
}
val home = System.getProperty("user.home")
val editorConfig: Map<String, String> = EditorConfig.of(".") ?: emptyMap()
val continuationIndentSize = editorConfig["continuation_indent_size"]?.toIntOrNull() ?: if (android) 8 else 4
val continuationIndentSize = editorConfig["continuation_indent_size"]?.toIntOrNull() ?: 4
val indentSize = editorConfig["indent_size"]?.toIntOrNull() ?: 4
val codeStyleName = "ktlint${
if (continuationIndentSize == 4) "" else "-cis$continuationIndentSize"
Expand Down

0 comments on commit ed26117

Please # to comment.