Repository: cqfn/diKTat (kotlin)

Issue:
Incorrect fix mode in LongLine rule
## Test

maximum linelength = 151

### Initial code:
```kotlin
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
```

### Expected behavior
```kotlin
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && 
        !isReferenceExpressionWithSameName
```

### Observed behavior
```kotlin
val elem = 
    (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
```

### With other values of maximum length, the rule gives the correct result

### Result - error in incorrect analysis first symbol in need to split word in BinaryExpression

## Environment information
* diktat version:  1.1.0
* kotlin version 1.6

Pull request:
## Description bug:
### Whats added:
 
* Corrected analysis if maximum lineLength drop in first symbol of the last word long binary expression
 * Delete 2 unused test in DiktatSmokeTest
 * Added 1 fix test split long binary expression with maximum lineLength = offset last word in binary expression

### This pull request closes #1385

Patch:
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt
index 546c99a53f..1156b36db8 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt
@@ -150,7 +150,7 @@ class LineLength(configRules: List<RulesConfig>) : DiktatRule(
                         splitOffset?.let {
                             val parentIsBiExprOrParenthesized = parent.treeParent.elementType in listOf(BINARY_EXPRESSION, PARENTHESIZED)
                             val parentIsFunOrProperty = parent.treeParent.elementType in listOf(FUN, PROPERTY)
-                            if (parentIsBiExprOrParenthesized || (parentIsFunOrProperty && splitOffset >= configuration.lineLength)) {
+                            if (parentIsBiExprOrParenthesized || (parentIsFunOrProperty && splitOffset > configuration.lineLength)) {
                                 parent = parent.treeParent
                             } else {
                                 return checkBinaryExpression(parent, configuration)


Test patch:
diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/LineLengthFixTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/LineLengthFixTest.kt
index 257d2710cc..2322b7910a 100644
--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/LineLengthFixTest.kt
+++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/LineLengthFixTest.kt
@@ -23,6 +23,10 @@ class LineLengthFixTest : FixTestBase("test/paragraph3/long_line", ::LineLength)
         RulesConfig(LONG_LINE.name, true,
             mapOf("lineLength" to "20"))
     )
+    private val rulesConfigListErrorLineLength1: List<RulesConfig> = listOf(
+        RulesConfig(LONG_LINE.name, true,
+            mapOf("lineLength" to "151"))
+    )
 
     @Test
     fun `should fix long comment`() {
@@ -98,4 +102,9 @@ class LineLengthFixTest : FixTestBase("test/paragraph3/long_line", ::LineLength)
     fun `fix long value arguments list`() {
         fixAndCompare("LongValueArgumentsListExpected.kt", "LongValueArgumentsListTest.kt", rulesConfigListLineLength)
     }
+
+    @Test
+    fun `fix bin expression first symbol last word`() {
+        fixAndCompare("LongBinaryExpressionLastWordExpected.kt", "LongBinaryExpressionLastWordTest.kt", rulesConfigListErrorLineLength1)
+    }
 }
diff --git a/diktat-rules/src/test/resources/test/paragraph3/long_line/LongBinaryExpressionLastWordExpected.kt b/diktat-rules/src/test/resources/test/paragraph3/long_line/LongBinaryExpressionLastWordExpected.kt
new file mode 100644
index 0000000000..71a98865d8
--- /dev/null
+++ b/diktat-rules/src/test/resources/test/paragraph3/long_line/LongBinaryExpressionLastWordExpected.kt
@@ -0,0 +1,10 @@
+package test.paragraph3.long_line
+
+val elem1 = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc &&
+ !isReferenceExpressionWithSameName
+
+val elem2 = (hasExplicitNotUnitReturnType || isFunWithExpressionBody1 && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc &&
+ isReferenceExpressionWithSameName
+
+val elem3 = "sdfghjkl;kjhgfdsdfghjkllkjhgfdsfghjkl;';lkiuytrdfghjklkjuhgfdsdfghnm,.lkjhgfdcvbnm,.lkjhgfdcvbnm,.lkjhgfdxcvbnm,lkjhgfdxcvbnm,lkgfdcvm" +
+ "hgfjdgdsvfmg.k,gfdsgbh.gkhjhmhgdf"
diff --git a/diktat-rules/src/test/resources/test/paragraph3/long_line/LongBinaryExpressionLastWordTest.kt b/diktat-rules/src/test/resources/test/paragraph3/long_line/LongBinaryExpressionLastWordTest.kt
new file mode 100644
index 0000000000..339627f187
--- /dev/null
+++ b/diktat-rules/src/test/resources/test/paragraph3/long_line/LongBinaryExpressionLastWordTest.kt
@@ -0,0 +1,7 @@
+package test.paragraph3.long_line
+
+val elem1 = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
+
+val elem2 = (hasExplicitNotUnitReturnType || isFunWithExpressionBody1 && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && isReferenceExpressionWithSameName
+
+val elem3 = "sdfghjkl;kjhgfdsdfghjkllkjhgfdsfghjkl;';lkiuytrdfghjklkjuhgfdsdfghnm,.lkjhgfdcvbnm,.lkjhgfdcvbnm,.lkjhgfdxcvbnm,lkjhgfdxcvbnm,lkgfdcvm" + "hgfjdgdsvfmg.k,gfdsgbh.gkhjhmhgdf"
diff --git a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/CheckLongLineExpected.kt b/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/CheckLongLineExpected.kt
deleted file mode 100644
index c7f575b940..0000000000
--- a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/CheckLongLineExpected.kt
+++ /dev/null
@@ -1,3 +0,0 @@
-package org.cqfn.diktat
-
-val A = This.Is.Veeeeryyyyyyy.Loooooong.Dot.Qualified.Expression
diff --git a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/CheckLongLineTest.kt b/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/CheckLongLineTest.kt
deleted file mode 100644
index 92665f2891..0000000000
--- a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/CheckLongLineTest.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.cqfn.diktat
-
-/**
- * @return
- */
-val A = This.Is.Veeeeryyyyyyy.Loooooong.Dot.Qualified.Expression
\ No newline at end of file