Enabled `*,+,-,/,%,&&,||` wrapping check
diff --git a/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/ChainWrappingRule.kt b/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/ChainWrappingRule.kt
index 63549b1..dd095ad 100644
--- a/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/ChainWrappingRule.kt
+++ b/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/ChainWrappingRule.kt
@@ -5,18 +5,22 @@
import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafPsiElement
import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl
import org.jetbrains.kotlin.com.intellij.psi.tree.TokenSet
+import org.jetbrains.kotlin.lexer.KtTokens.ANDAND
+import org.jetbrains.kotlin.lexer.KtTokens.DIV
import org.jetbrains.kotlin.lexer.KtTokens.DOT
import org.jetbrains.kotlin.lexer.KtTokens.ELVIS
+import org.jetbrains.kotlin.lexer.KtTokens.MINUS
+import org.jetbrains.kotlin.lexer.KtTokens.MUL
+import org.jetbrains.kotlin.lexer.KtTokens.OROR
+import org.jetbrains.kotlin.lexer.KtTokens.PERC
+import org.jetbrains.kotlin.lexer.KtTokens.PLUS
import org.jetbrains.kotlin.lexer.KtTokens.SAFE_ACCESS
import org.jetbrains.kotlin.psi.psiUtil.nextLeaf
import org.jetbrains.kotlin.psi.psiUtil.prevLeaf
class ChainWrappingRule : Rule("chain-wrapping") {
- // *,+,-,/,% position differ in
- // https://github.com/yole/kotlin-style-guide/issues/9
- // https://android.github.io/kotlin-guides/style.html#where-to-break
- private val sameLineTokens = TokenSet.EMPTY // TokenSet.create(MUL, PLUS, MINUS, DIV, PERC)
+ private val sameLineTokens = TokenSet.create(MUL, PLUS, MINUS, DIV, PERC, ANDAND, OROR)
private val nextLineTokens = TokenSet.create(DOT, SAFE_ACCESS, ELVIS)
private val noSpaceAroundTokens = TokenSet.create(DOT, SAFE_ACCESS)
diff --git a/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/format-expected.kt.spec b/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/format-expected.kt.spec
index 1724690..afc8dc7 100644
--- a/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/format-expected.kt.spec
+++ b/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/format-expected.kt.spec
@@ -6,4 +6,8 @@
?: bar
val s = foo()
?.bar
+ val s = "foo" +
+ "bar"
+ val s = true &&
+ false
}
diff --git a/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/format.kt.spec b/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/format.kt.spec
index 68b0dc3..7bf40f8 100644
--- a/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/format.kt.spec
+++ b/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/format.kt.spec
@@ -6,4 +6,8 @@
bar
val s = foo()?.
bar
+ val s = "foo"
+ + "bar"
+ val s = true
+ && false
}
diff --git a/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/lint.kt.spec b/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/lint.kt.spec
index f6a1f0c..bb0c528 100644
--- a/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/lint.kt.spec
+++ b/ktlint-ruleset-standard/src/test/resources/spec/chain-wrapping/lint.kt.spec
@@ -6,8 +6,10 @@
bar
val s = foo()?.
bar
-// val s = "foo"
-// + "bar"
+ val s = "foo"
+ + "bar"
+ val s = true
+ && false
}
// expect
@@ -15,3 +17,5 @@
// 3:33:Line must not end with "."
// 5:19:Line must not end with "?:"
// 7:18:Line must not end with "?."
+// 10:9:Line must not begin with "+"
+// 12:9:Line must not begin with "&&"