New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider enum trailing commas in SeparatorWrap semicolons #3767
Comments
problem is part of misconception that Separator related Check use operator wrapping model - http://checkstyle.sourceforge.net/property_types.html#wrapOp It is be good to have the same as in http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceBefore @rnveach , please share your ideas on this issue. |
Yes, this property would not print violations for both cases. I am fine with doing that, but it seems the user might prefer a violation in one of these cases.
We can't meet this expectation with this check. The problem with these type of checks is they do a blind token match. Both areas are semi-colons and AST tree only knows them as a semi-colon. User wants that token but in a specific context - allow for enum definitions but disallow in field/method. If we did make some type of override, we would need to expand it to other areas like for loops and such. |
Issue is related to #3766 by used code. @cypai ,
This SeparatorWrap is general simple Check, we can not introduce in it logic for special ";" processing in different contexts, new Check should be created. |
@romani For builders, having the semicolon at |
@cypai , consider any other chain calls
keep in mind that you might have the same reason for such formatting as you you has in enum. |
@cypai , ping ! |
The main reason I had for this is similar to trailing commas in Arrays. It's easy to add/delete/sort elements by line, and if I do so at the end of the declaration, I won't need to go back to delete the semicolon, etc.
vs
So it's pretty much just a convenience issue. For chain calls, I would prefer the semicolon on the same line. The last line in chain calls is typically a terminal operation (like in builders or Java 8 streams), and therefore wouldn't have the same convenience issue when the semicolon is on the same line. If it is not a chain call like a builder or stream, it's probably a more complicated change than simply moving a semicolon around. However, I do agree that this extra logic probably should not be part of this simple check. It might be better to make it an experimental check. Most likely I will just keep using the current check and leave trailing commas in enums as a violation. |
There are such idea already sevntu-checkstyle/sevntu.checkstyle#464 If smb have time to finish , please feel free. |
http://checkstyle.sourceforge.net/config_whitespace.html#SeparatorWrap
It would be nice if SeparatorWrap would ignore the semicolon if it is on the line after a trailing comma in enums.
The text was updated successfully, but these errors were encountered: