Skip to content

Commit 75bf80f

Browse files
authored
Added this operator references to the list with similar operator references (#1393)
### Whats added: * Add 2 operator references * Corrected comment ### Issue(#1393)
1 parent b4fed8f commit 75bf80f

File tree

1 file changed

+14
-10
lines changed
  • diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3

1 file changed

+14
-10
lines changed

diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ import com.pinterest.ktlint.core.ast.ElementType.ELVIS
2828
import com.pinterest.ktlint.core.ast.ElementType.EOL_COMMENT
2929
import com.pinterest.ktlint.core.ast.ElementType.EQ
3030
import com.pinterest.ktlint.core.ast.ElementType.EQEQ
31+
import com.pinterest.ktlint.core.ast.ElementType.EQEQEQ
3132
import com.pinterest.ktlint.core.ast.ElementType.EXCL
3233
import com.pinterest.ktlint.core.ast.ElementType.EXCLEQ
34+
import com.pinterest.ktlint.core.ast.ElementType.EXCLEQEQEQ
3335
import com.pinterest.ktlint.core.ast.ElementType.FILE
3436
import com.pinterest.ktlint.core.ast.ElementType.FLOAT_CONSTANT
3537
import com.pinterest.ktlint.core.ast.ElementType.FUN
@@ -570,8 +572,8 @@ class LineLength(configRules: List<RulesConfig>) : DiktatRule(
570572
) : LongLineFixableCases(node) {
571573
/**
572574
* Fix a binary expression -
573-
* If the transfer is done on the Elvis operator, then transfers it to a new line
574-
* If not on the Elvis operator, then transfers it to a new line after the operation reference
575+
* - If the transfer is done on the Elvis operator, then transfers it to a new line
576+
* - If not on the Elvis operator, then transfers it to a new line after the operation reference
575577
*/
576578
@Suppress("UnsafeCallOnNullableType")
577579
override fun fix() {
@@ -595,16 +597,18 @@ class LineLength(configRules: List<RulesConfig>) : DiktatRule(
595597
}
596598

597599
/**
598-
* This method stored all the nodes that have BINARY_EXPRESSION or PREFIX_EXPRESSION element type.
599-
* Return List of the Pair <node, offset>
600-
* First elem in List - Logic Binary Expression (&& ||)
601-
* Second elem in List - Comparison Binary Expression (> < == >= <= !=)
602-
* Other types (Arithmetical and Bit operation) (+ - * / % >> << *= += -= /= %= ++ -- ! in !in etc)
600+
* This method stored all the nodes that have [BINARY_EXPRESSION] or [PREFIX_EXPRESSION] element type.
601+
* - First elem in List - Logic Binary Expression (`&&`, `||`)
602+
* - Second elem in List - Comparison Binary Expression (`>`, `<`, `==`, `>=`, `<=`, `!=`, `===`, `!==`)
603+
* - Other types (Arithmetical and Bitwise operation) (`+`, `-`, `*`, `/`, `%`, `>>`, `<<`, `&`, `|`, `~`, `^`, `>>>`, `<<<`,
604+
* `*=`, `+=`, `-=`, `/=`, `%=`, `++`, `--`, `in` `!in`, etc.)
605+
*
606+
* @return the list of node-to-offset pairs.
603607
*/
604608
@Suppress("TYPE_ALIAS")
605609
private fun searchSomeSplitInBinaryExpression(parent: ASTNode, configuration: LineLengthConfiguration): List<Pair<ASTNode, Int>?> {
606610
val logicListOperationReference = listOf(OROR, ANDAND)
607-
val compressionListOperationReference = listOf(GT, LT, EQEQ, GTEQ, LTEQ, EXCLEQ)
611+
val compressionListOperationReference = listOf(GT, LT, EQEQ, GTEQ, LTEQ, EXCLEQ, EQEQEQ, EXCLEQEQEQ)
608612
val binList: MutableList<ASTNode> = mutableListOf()
609613
searchBinaryExpression(parent, binList)
610614
val rightBinList = binList.map {
@@ -752,8 +756,8 @@ class LineLength(configRules: List<RulesConfig>) : DiktatRule(
752756

753757
/**
754758
* Class WhenEntry show that line should be split in WhenEntry node:
755-
* Added [LBRACE] and [RBRACE] nodes
756-
* Split line in space after [LBRACE] node and before [RBRACE] node
759+
* - Added [LBRACE] and [RBRACE] nodes
760+
* - Split line in space after [LBRACE] node and before [RBRACE] node
757761
*/
758762
private class WhenEntry(node: ASTNode) : LongLineFixableCases(node) {
759763
override fun fix() {

0 commit comments

Comments
 (0)