-
Notifications
You must be signed in to change notification settings - Fork 134
Wrapping and +/- operators #51
Comments
Anyone have thoughts on what should be done here? |
I searched the checkstyle rule on SourceForge doc for OperatorWrap, as default, the WrapOp for this rule is using NL, as it said on the checkstyle repo, google checkstyle rule and sun also use NL too, So our project also follow this rule for java code, so as the OperatorWrap default and google or sun defined for this, the correct option is: val s = "abc"
+ "def"
if (candition1
&& candition2) Although the above codestyle rule is for Java, but our project is developed with both Java and Kotlin, so if the rule is different, it is very confusing for our developers.. |
@Jacksgong This is not a code style issue, this is a language syntax issue. The confusion of your developers is unfortunate, but you do have to wrap after |
@yole okay, thanks for your response, I know that now, maybe because of there isn't val a = 1
-2 we can't know whether |
I'm not sure what you mean by "we can't know". You can know this; |
Yep, I mean as the expert kotlin lang engineer, they absolutely know what does this means, but for the beginner, especially from Java, they will confusing, because on the Java, the following code is means int a = 1
-2; |
The current guide says: "When a line is broken at a non-assignment operator the break comes before the symbol". Unfortunately this breaks semantics for +/- operators, which can be used in unary form. For example, this is a string concatenation:
This is a simple string initialization, followed by an unused expression that applies unary + to a string literal:
The wrapping rules should be changed to either break after all operators (preferably), or to make exceptions for +/-.
The text was updated successfully, but these errors were encountered: