Skip to content

Commit e75580c

Browse files
author
Arrgentum
committed
### Whats added:
* corrected logic fix and warn String Template in LineLength rule * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule * added logic fix and warn Value Arguments List in LineLength rule * added and corrected fix and warn tests in LineLength rule * fix code with diktat:fix@diktat * added comments to classes and functions * correct code with running detect ### Issue (#1243)
1 parent ca89cbd commit e75580c

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,21 @@ class LineLength(configRules: List<RulesConfig>) : DiktatRule(
144144
splitOffset?.let {
145145
val parentIsBiExprOrParenthesized = parent.treeParent.elementType in listOf(BINARY_EXPRESSION, PARENTHESIZED)
146146
val parentIsFunOrProperty = parent.treeParent.elementType in listOf(FUN, PROPERTY)
147-
if (parentIsBiExprOrParenthesized) {
147+
if (parentIsBiExprOrParenthesized || (parentIsFunOrProperty && splitOffset >= configuration.lineLength)) {
148148
parent = parent.treeParent
149-
} else if (parentIsFunOrProperty && splitOffset >= configuration.lineLength) {
149+
} else {
150+
return checkBinaryExpression(parent, configuration)
151+
}
152+
}
153+
?: run {
150154
stringOrDot?.let {
151-
val returnElem = checkStringTemplateAndDotQualifiedExpression(parent, configuration)
155+
val returnElem = checkStringTemplateAndDotQualifiedExpression(it, configuration)
152156
if (returnElem !is None) {
153157
return returnElem
154158
}
155159
}
156160
parent = parent.treeParent
157-
} else {
158-
return checkBinaryExpression(parent, configuration)
159161
}
160-
}
161-
?: run { parent = parent.treeParent }
162162
}
163163
}
164164
FUN, PROPERTY -> return checkFunAndProperty(parent)

Diff for: diktat-rules/src/test/resources/test/paragraph3/long_line/LongStringTemplateExpected.kt

+3
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ class Foo() {
5151
}
5252
""".trimIndent()
5353
}
54+
55+
val stringName = "This is long string template with binary expression. test should be up in level binary" +
56+
" expression and cannot split in operation reference and should be split this long string template" + "this string should be after operated reference"
5457
}

Diff for: diktat-rules/src/test/resources/test/paragraph3/long_line/LongStringTemplateTest.kt

+2
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ class Foo() {
3838
}
3939
""".trimIndent()
4040
}
41+
42+
val stringName = "This is long string template with binary expression. test should be up in level binary expression and cannot split in operation reference and should be split this long string template" + "this string should be after operated reference"
4143
}

0 commit comments

Comments
 (0)