Skip to content

Commit

Permalink
### Whats added:
Browse files Browse the repository at this point in the history
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified 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)
  • Loading branch information
Arrgentum committed May 24, 2022
1 parent 6854102 commit 544011f
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class LineLength(configRules: List<RulesConfig>) : DiktatRule(

@Suppress(
"TOO_LONG_FUNCTION",
"LongMethod",
"ComplexMethod",
"GENERIC_VARIABLE_WRONG_DECLARATION",
)
Expand Down Expand Up @@ -221,7 +222,7 @@ class LineLength(configRules: List<RulesConfig>) : DiktatRule(
): LongLineFixableCases {
funOrPropertyNode?.let {
if (it.hasChildOfType(EQ)) {
val positionByOffset = positionByOffset(it.getFirstChildWithType(EQ)!!.startOffset).second
val positionByOffset = positionByOffset(it.getFirstChildWithType(EQ)?.startOffset ?: 0).second
if (positionByOffset < configuration.lineLength / 2) {
val returnedClass = parserStringAndDot(node, configuration)
if (returnedClass !is None) {
Expand Down Expand Up @@ -374,22 +375,23 @@ class LineLength(configRules: List<RulesConfig>) : DiktatRule(
node.appendNewlineMergingWhiteSpace(dot, dot)
}

@Suppress("UnsafeCallOnNullableType")
private fun fixArgumentsListFirstArgument(wrongArgumentList: ValueArgumentList): Int {
val lineLength = wrongArgumentList.maximumLineLength.lineLength
val node = wrongArgumentList.node
var offset = 0
var startOffset = 0
node.getFirstChildWithType(COMMA)?.let {
if (positionByOffset(it.startOffset).second > lineLength) {
node.appendNewlineMergingWhiteSpace(node.findChildByType(LPAR)!!.treeNext, node.findChildByType(LPAR)!!.treeNext)
node.appendNewlineMergingWhiteSpace(node.findChildByType(RPAR), node.findChildByType(RPAR))
offset = 50
startOffset = 50
}
} ?: node.getFirstChildWithType(RPAR)?.let {
node.appendNewlineMergingWhiteSpace(node.findChildByType(LPAR)!!.treeNext, node.findChildByType(LPAR)!!.treeNext)
node.appendNewlineMergingWhiteSpace(node.findChildByType(RPAR), node.findChildByType(RPAR))
offset = 50
startOffset = 50
}
return offset
return startOffset
}

/**
Expand Down

0 comments on commit 544011f

Please sign in to comment.