Open Cheshiriks opened 3 years ago
The reason, I believe, is that we don't allow line to start with operator (&&
in this case), but apparently we move the entire string on the previous line. We should only move the operator and let other rules handle operands placement.
Here is a peace of code:
val foo = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes)
&& !hasReturnKdoc && !isReferenceExpressionWithSameName
Here is what NewlinesRule does with this code:
val foo = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes)&&
!hasReturnKdoc && !isReferenceExpressionWithSameName
Here is what LongLine does with this code:
val foo = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType &&
hasNotExpressionBodyTypes)
&& !hasReturnKdoc && !isReferenceExpressionWithSameName
As far as I can see from tests, this problem is not caused by neither NewlinesRule nor LongLine.
Diktat: 1.1.0 + Kotlin: 1.6
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes)
&& !hasReturnKdoc && !isReferenceExpressionWithSameName
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc &&
!isReferenceExpressionWithSameName
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) &&
!hasReturnKdoc && !isReferenceExpressionWithSameName
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType &&
hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
val elem = (hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
val elem =
(hasExplicitNotUnitReturnType || isFunWithExpressionBody && !hasExplicitUnitReturnType && hasNotExpressionBodyTypes) && !hasReturnKdoc && !isReferenceExpressionWithSameName
The error of this issue has already been resolved But if the separator falls at the beginning of the last word - may be not correct fix
Example:
Diktat will glue two lines into one and break on warning LONG_LINE