diff --git a/1.4.1/rules/configuration-ktlint/index.html b/1.4.1/rules/configuration-ktlint/index.html index b15a176ed5..39f1659910 100644 --- a/1.4.1/rules/configuration-ktlint/index.html +++ b/1.4.1/rules/configuration-ktlint/index.html @@ -1277,6 +1277,10 @@
Ensures that imports are ordered consistently (see Import Layouts for configuration).
+Ensures that imports are ordered consistently.
ij_kotlin_imports_layout
Defines imports order layout for Kotlin filesFor more details see below table.This property holds 0 or more import paths. The import path can be a full path, e.g. "java.util.List." as well as wildcard path, e.g. "kotlin.*".
+Imports can be grouped by composing the layout with symbols below:
+*
- wildcard. There must be at least one entry of a single wildcard to match all other imports. Matches anything after a specified symbol/import as well.|
- blank line. Supports only single blank lines between imports. No blank line is allowed in the beginning or end of the layout.^
- alias import, e.g. "^android.*" will match all android alias imports, "^" will match all other alias imports.Imports in the same group are sorted alphabetical with capital letters before lower case letters (e.g. Z before a).
+Examples: +
ij_kotlin_imports_layout=* # alphabetical with capital letters before lower case letters (e.g. Z before a), no blank lines
+ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^ # default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list
+ij_kotlin_imports_layout=android.**,|,^org.junit.**,kotlin.io.Closeable.*,|,*,^ # custom imports layout
+
Wildcard imports can be allowed for specific import paths (Comma-separated list, use "**" as wildcard for package and all subpackages). This setting overrides the no-wildcard-imports rule. This setting is best be used for allowing wildcard imports from libraries like Ktor where extension functions are used in a way that creates a lot of imports.
Rule id: standard:import-ordering
Suppress or disable rule (1)
@Suppress("ktlint:standard:import-ordering")
+
Enable rule via .editorconfig
- ktlint_standard_import-ordering = enabled
+
Disable rule via .editorconfig
- ktlint_standard_import-ordering = disabled
+
Indentation¶
@@ -4111,25 +4174,25 @@ Indentation
@@ -4170,13 +4233,13 @@ IndentationSuppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:indent")
+
Enable rule via .editorconfig
- ktlint_standard_indent = enabled
+
Disable rule via .editorconfig
- ktlint_standard_indent = disabled
+
Naming¶
@@ -4185,24 +4248,24 @@ Backing property naming
-class Bar {
- // Backing property
- private val _elementList = mutableListOf<Element>()
- val elementList: List<Element>
- get() = _elementList
-}
+
-class Bar {
- // Incomplete backing property as public property 'elementList1' is missing
- private val _elementList1 = mutableListOf<Element>()
-
- // Invalid backing property as '_elementList2' is not a private property
- val _elementList2 = mutableListOf<Element>()
- val elementList2: List<Element>
- get() = _elementList2
-}
+class Bar {
+ // Incomplete backing property as public property 'elementList1' is missing
+ private val _elementList1 = mutableListOf<Element>()
+
+ // Invalid backing property as '_elementList2' is not a private property
+ val _elementList2 = mutableListOf<Element>()
+ val elementList2: List<Element>
+ get() = _elementList2
+}
@@ -4211,13 +4274,13 @@ Backing property namingSuppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:backing-property-naming")
+
Enable rule via .editorconfig
- ktlint_standard_backing-property-naming = enabled
+
Disable rule via .editorconfig
- ktlint_standard_backing-property-naming = disabled
+
Class naming¶
@@ -4225,27 +4288,27 @@ Class naming
-
-@Nested
-inner class `Some descriptive class name` {
- @Test
- fun `Some descriptive test name`() {
- // do something
- }
-}
+
-
@@ -4259,13 +4322,13 @@ Class namingSuppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:class-naming")
+
Enable rule via .editorconfig
- ktlint_standard_class-naming = enabled
+
Disable rule via .editorconfig
- ktlint_standard_class-naming = disabled
+
Function naming¶
@@ -4273,26 +4336,26 @@ Function naming
-fun foo() {}
-
-fun fooBar() {}
-
-fun `fun`() {} // Any keyword is allowed when wrapped between backticks
+
-
-
@@ -4328,13 +4391,13 @@ Function namingSuppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:function-naming")
+
Enable rule via .editorconfig
- ktlint_standard_function-naming = enabled
+
Disable rule via .editorconfig
- ktlint_standard_function-naming = disabled
+
Package name¶
@@ -4342,15 +4405,15 @@ Package name
-
-
@@ -4359,13 +4422,13 @@ Package nameSuppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:package-name")
+
Enable rule via .editorconfig
- ktlint_standard_package-name = enabled
+
Disable rule via .editorconfig
- ktlint_standard_package-name = disabled
+
Property naming¶
@@ -4377,50 +4440,50 @@ Property naming
-val foo1 = Foo() // In case developers want to tell that Foo is mutable
-val FOO1 = Foo() // In case developers want to tell that Foo is deeply immutable
-
-const val FOO_BAR = "FOO-BAR" // By definition deeply immutable
-
-var foo2: Foo = Foo() // By definition not immutable
-
-class Bar {
- val foo1 = "foo1" // Class properties always start with lowercase, const is not allowed
-
- const val FOO_BAR = "FOO-BAR" // By definition deeply immutable
-
- var foo2: Foo = Foo() // By definition not immutable
-
- // Backing property
- private val _elementList = mutableListOf<Element>()
- val elementList: List<Element>
- get() = _elementList
-
- companion object {
- val foo1 = Foo() // In case developer want to communicate that Foo is mutable
- 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
-
-
-
-const val fooBar = "FOO-BAR" // By definition deeply immutable
-
-var FOO2: Foo = Foo() // By definition not immutable
-
-class Bar {
- val FOO_BAR = "FOO-BAR" // Class properties always start with lowercase, const is not allowed
+val foo1 = Foo() // In case developers want to tell that Foo is mutable
+val FOO1 = Foo() // In case developers want to tell that Foo is deeply immutable
+
+const val FOO_BAR = "FOO-BAR" // By definition deeply immutable
+
+var foo2: Foo = Foo() // By definition not immutable
- // Incomplete backing property as public property 'elementList1' is missing
- private val _elementList1 = mutableListOf<Element>()
+class Bar {
+ val foo1 = "foo1" // Class properties always start with lowercase, const is not allowed
- // Invalid backing property as '_elementList2' is not a private property
- val _elementList2 = mutableListOf<Element>()
- val elementList2: List<Element>
- get() = _elementList2
-}
+ const val FOO_BAR = "FOO-BAR" // By definition deeply immutable
+
+ var foo2: Foo = Foo() // By definition not immutable
+
+ // Backing property
+ private val _elementList = mutableListOf<Element>()
+ val elementList: List<Element>
+ get() = _elementList
+
+ companion object {
+ val foo1 = Foo() // In case developer want to communicate that Foo is mutable
+ 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
+
+
+
+const val fooBar = "FOO-BAR" // By definition deeply immutable
+
+var FOO2: Foo = Foo() // By definition not immutable
+
+class Bar {
+ val FOO_BAR = "FOO-BAR" // Class properties always start with lowercase, const is not allowed
+
+ // Incomplete backing property as public property 'elementList1' is missing
+ private val _elementList1 = mutableListOf<Element>()
+
+ // Invalid backing property as '_elementList2' is not a private property
+ val _elementList2 = mutableListOf<Element>()
+ val elementList2: List<Element>
+ get() = _elementList2
+}
@@ -4430,13 +4493,13 @@ Property namingSuppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:property-naming")
+
Enable rule via .editorconfig
- ktlint_standard_property-naming = enabled
+
Disable rule via .editorconfig
- ktlint_standard_property-naming = disabled
+
No blank lines in list¶
@@ -4445,23 +4508,23 @@ No blank lines in list
-
-
@@ -4470,20 +4533,20 @@ No blank lines in list
-
-
@@ -4492,28 +4555,28 @@ No blank lines in list
-class BiAdapter<C : RecyclerView.ViewHolder, V1 : C, V2 : C, out A1, out A2>(
- val adapter1: A1,
- val adapter2: A2,
-) : RecyclerView.Adapter<C>()
- where A1 : RecyclerView.Adapter<V1>, A1 : ComposableAdapter.ViewTypeProvider,
- A2 : RecyclerView.Adapter<V2>, A2 : ComposableAdapter.ViewTypeProvider {
- // body
-}
-
-
-
class BiAdapter<C : RecyclerView.ViewHolder, V1 : C, V2 : C, out A1, out A2>(
val adapter1: A1,
- val adapter2: A2
+ val adapter2: A2,
) : RecyclerView.Adapter<C>()
- where
- A1 : RecyclerView.Adapter<V1>, A1 : ComposableAdapter.ViewTypeProvider,
-
- A2 : RecyclerView.Adapter<V2>, A2 : ComposableAdapter.ViewTypeProvider
-{
- // body
-}
+ where A1 : RecyclerView.Adapter<V1>, A1 : ComposableAdapter.ViewTypeProvider,
+ A2 : RecyclerView.Adapter<V2>, A2 : ComposableAdapter.ViewTypeProvider {
+ // body
+}
+
+
+
+class BiAdapter<C : RecyclerView.ViewHolder, V1 : C, V2 : C, out A1, out A2>(
+ val adapter1: A1,
+ val adapter2: A2
+) : RecyclerView.Adapter<C>()
+ where
+ A1 : RecyclerView.Adapter<V1>, A1 : ComposableAdapter.ViewTypeProvider,
+
+ A2 : RecyclerView.Adapter<V2>, A2 : ComposableAdapter.ViewTypeProvider
+{
+ // body
+}
@@ -4522,20 +4585,20 @@ No blank lines in list
-
@@ -4544,22 +4607,22 @@ No blank lines in list
-
-
@@ -4568,20 +4631,20 @@ No blank lines in list
-
-
@@ -4590,13 +4653,13 @@ No blank lines in listSuppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:no-blank-line-in-list")
+
Enable rule via .editorconfig
- ktlint_standard_no-blank-line-in-list = enabled
+
Disable rule via .editorconfig
- ktlint_standard_no-blank-line-in-list = disabled
+
@@ -4612,36 +4675,36 @@ No consecutive comments
-// An EOL comment
-// may be followed by another EOL comment
-val foo = "foo"
-
-// Different comment types (including KDoc) may be consecutive ..
-
-/*
- * ... but do need to be separated by a blank line ...
- */
-
-/**
- * ... but a KDoc can not be followed by an EOL or a block comment or another KDoc
- */
-fun bar() = "bar"
+// An EOL comment
+// may be followed by another EOL comment
+val foo = "foo"
+
+// Different comment types (including KDoc) may be consecutive ..
+
+/*
+ * ... but do need to be separated by a blank line ...
+ */
+
+/**
+ * ... but a KDoc can not be followed by an EOL or a block comment or another KDoc
+ */
+fun bar() = "bar"
-
@@ -4650,13 +4713,13 @@ No consecutive commentsSuppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:no-consecutive-comments")
+
Enable rule via .editorconfig
- ktlint_standard_no-consecutive-comments = enabled
+
Disable rule via .editorconfig
- ktlint_standard_no-consecutive-comments = disabled
+
@@ -4669,13 +4732,13 @@ No empty fileSuppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:no-empty-file")
+
Enable rule via .editorconfig
- ktlint_standard_no-empty-file = enabled
+
Disable rule via .editorconfig
- ktlint_standard_no-empty-file = disabled
+
No empty first line at start in class body¶
@@ -4683,16 +4746,16 @@ No empty first line at start
-
@@ -4701,13 +4764,13 @@ No empty first line at start
Suppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:no-empty-first-line-in-class-body")
+
Enable rule via .editorconfig
- ktlint_standard_no-empty-first-line-in-class-body = enabled
+
Disable rule via .editorconfig
- ktlint_standard_no-empty-first-line-in-class-body = disabled
+
@@ -4719,16 +4782,16 @@ No single line block comment
-
-
@@ -4737,13 +4800,13 @@ No single line block commentSuppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:no-single-line-block-comment")
+
Enable rule via .editorconfig
- ktlint_standard_no-single-line-block-comment = enabled
+
Disable rule via .editorconfig
- ktlint_standard_no-single-line-block-comment = disabled
+
Ktlint-suppression rule¶
@@ -4752,39 +4815,39 @@ Ktlint-suppression rule
-
-
-
-/* ktlint-disable standard:no-wildcard-imports */
+@file:Suppress("ktlint:standard:no-wildcard-imports")
class FooBar {
- val foo = "some longggggggggggggggggggg text" // ktlint-disable standard:max-line-length
-
- fun bar() =
- listOf(
- /* ktlint-disable standard:no-multi-spaces */
- "1 One",
- "10 Ten",
- "100 Hundred",
- /* ktlint-enable standard:no-multi-spaces */
+ @Suppress("ktlint:standard:max-line-length")
+ val foo = "some longggggggggggggggggggg text"
+
+ fun bar() =
+ @Suppress("ktlint:standard:no-multi-spaces")
+ listOf(
+ "1 One",
+ "10 Ten",
+ "100 Hundred",
)
}
+
+/* ktlint-disable standard:no-wildcard-imports */
+
+class FooBar {
+ val foo = "some longggggggggggggggggggg text" // ktlint-disable standard:max-line-length
+
+ fun bar() =
+ listOf(
+ /* ktlint-disable standard:no-multi-spaces */
+ "1 One",
+ "10 Ten",
+ "100 Hundred",
+ /* ktlint-enable standard:no-multi-spaces */
+ )
+}
+
+
Rule id: standard:ktlint-suppression
@@ -4798,32 +4861,32 @@ Max line length
-// Assume that the last allowed character is
-// at the X character on the right X
-// Lines below are accepted although the max
-// line length is exceeded.
-package com.toooooooooooooooooooooooooooo.long
-import com.tooooooooooooooooooooooooooooo.long
-
-val foo1 =
- """
- fooooooooooooooooooooooooooooooooooooooooo
- """
-
-val foo2 =
- "fooooooooooooooooooooooooooooooooooooooo"
-
-@Test
-fun `Test description which is toooooooooooo long`() {
-}
+// Assume that the last allowed character is
+// at the X character on the right X
+// Lines below are accepted although the max
+// line length is exceeded.
+package com.toooooooooooooooooooooooooooo.long
+import com.tooooooooooooooooooooooooooooo.long
+
+val foo1 =
+ """
+ fooooooooooooooooooooooooooooooooooooooooo
+ """
+
+val foo2 =
+ "fooooooooooooooooooooooooooooooooooooooo"
+
+@Test
+fun `Test description which is toooooooooooo long`() {
+}
-
@@ -4856,13 +4919,13 @@ Max line lengthSuppress or disable rule (1)
- Suppress rule in code with annotation below:
-
@Suppress("ktlint:standard:max-line-length")
+
Enable rule via .editorconfig
- ktlint_standard_max-line-length = enabled
+
Disable rule via .editorconfig
- ktlint_standard_max-line-length = disabled
+
Modifier order¶
@@ -4870,38 +4933,38 @@ Modifier order
-
-
-
+
Rule id: standard:modifier-order
Suppress or disable rule (1)