-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into bugfix/LongLine_in_StringTemplate
# Conflicts: # diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt
- Loading branch information
Showing
15 changed files
with
400 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
499 changes: 266 additions & 233 deletions
499
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 28 additions & 15 deletions
43
diktat-rules/src/test/resources/test/paragraph3/long_line/LongBinaryExpressionExpected.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,48 @@ | ||
package test.paragraph3.long_line | ||
|
||
fun foo() { | ||
val veryLongExpression = Methoooooooooooooooood() + | ||
12345 | ||
val veryLongExpression = | ||
Methoooooooooooooooood() + 12345 | ||
|
||
val veryLongExpression = Methoooooooooooooooood() ?: | ||
null | ||
val veryLongExpression = | ||
Methoooooooooooooooood() ?: null | ||
|
||
val veryLongExpression = a.Methooooood() + | ||
b.field | ||
|
||
val variable = someField.filter { it.elementType == KDOC } | ||
val variable = someField.filter { | ||
it.elementType == KDOC | ||
} | ||
|
||
// limit at the left side | ||
val variable = a?.filter { it.elementType == KDOC } ?: | ||
null | ||
val variable = a?.filter { | ||
it.elementType == KDOC | ||
} ?: null | ||
|
||
// limit at the right side | ||
val variable = bar?.filter { it.b == c } ?: | ||
null | ||
val variable = bar?.filter { it.b == c } | ||
?: null | ||
|
||
// limit at the operation reference | ||
val variable = field?.filter { bar == foo } ?: | ||
null | ||
val variable = field?.filter { bar == foo } | ||
?: null | ||
|
||
val variable = Methoooooooooooooooooooooooooood() ?: | ||
"some loooooong string" | ||
val variable = field?.filter { bar == foo } | ||
?: null | ||
|
||
val variable = Methooood() * 2 + 12 + field | ||
?: 123 + Methood().linelength | ||
|
||
val variable = Methooood() * 2 + 12 + field | ||
?: 123 + Methood().linelength | ||
|
||
val variable = | ||
Methoooooooooooooooooooooooooood() ?: "some loooooong string" | ||
|
||
val variable = Methooooood() ?: "some" + | ||
" looong string" | ||
|
||
var headerKdoc = firstCodeNode.prevSibling { it.elementType == KDOC } ?: | ||
if (firstCodeNode == packageDirectiveNode) importsList?.prevSibling { it.elementType == KDOC } else null | ||
var headerKdoc = firstCodeNode.prevSibling { | ||
it.elementType == KDOC | ||
} ?: if (firstCodeNode == packageDirectiveNode) importsList?.prevSibling { it.elementType == KDOC } else null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...ules/src/test/resources/test/paragraph3/long_line/LongConditionInSmallFunctionExpected.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package test.paragraph3.long_line | ||
|
||
private fun isContainingRequiredPartOfCode(text: String): Boolean = | ||
text.contains("val ", true) || text.contains("var ", true) || text.contains("=", true) || (text.contains("{", true) && | ||
text.substringAfter("{").contains("}", true)) |
4 changes: 4 additions & 0 deletions
4
...at-rules/src/test/resources/test/paragraph3/long_line/LongConditionInSmallFunctionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package test.paragraph3.long_line | ||
|
||
private fun isContainingRequiredPartOfCode(text: String): Boolean = | ||
text.contains("val ", true) || text.contains("var ", true) || text.contains("=", true) || (text.contains("{", true) && text.substringAfter("{").contains("}", true)) |
18 changes: 18 additions & 0 deletions
18
...t-rules/src/test/resources/test/paragraph3/long_line/LongExpressionInConditionExpected.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package test.paragraph3.long_line | ||
|
||
fun foo() { | ||
val veryLooongStringName = "ASDFGHJKL" | ||
val veryLooooooongConstIntName1 = 12345 | ||
val veryLooooooongConstIntName2 = 54321 | ||
var carry = 1 | ||
if (veryLooooooongConstIntName1 > | ||
veryLooooooongConstIntName2) { | ||
carry++ | ||
} else if (veryLooooooongConstIntName2 > | ||
123 * 12 && veryLooongStringName != "asd") { | ||
carry+=2 | ||
} else if (1234 + 1235 + 1236 + 1237 + 1238 > | ||
124 * 12) { | ||
carry+=3 | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
diktat-rules/src/test/resources/test/paragraph3/long_line/LongExpressionInConditionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package test.paragraph3.long_line | ||
|
||
fun foo() { | ||
val veryLooongStringName = "ASDFGHJKL" | ||
val veryLooooooongConstIntName1 = 12345 | ||
val veryLooooooongConstIntName2 = 54321 | ||
var carry = 1 | ||
if (veryLooooooongConstIntName1 > veryLooooooongConstIntName2) { | ||
carry++ | ||
} else if (veryLooooooongConstIntName2 > 123 * 12 && veryLooongStringName != "asd") { | ||
carry+=2 | ||
} else if (1234 + 1235 + 1236 + 1237 + 1238 > 124 * 12) { | ||
carry+=3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
diktat-rules/src/test/resources/test/paragraph3/long_line/LongLineExpressionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters