[ 
https://issues.apache.org/jira/browse/CASSANDRA-19276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17808649#comment-17808649
 ] 

Stefan Miklosovic edited comment on CASSANDRA-19276 at 1/19/24 1:06 PM:
------------------------------------------------------------------------

_Unfortunately I can't seem to find a way to allow this particular use while 
also forbidding multi-line methods that have left braces in the declaration 
line, but i'll keep looking._

Yeah, that is unfortunate, that pattern seems to be used quite frequently.


was (Author: smiklosovic):
_ Unfortunately I can't seem to find a way to allow this particular use while 
also forbidding multi-line methods that have left braces in the declaration 
line, but i'll keep looking._

Yeah, that is unfortunate, that pattern seems to be used quite frequently.

> Add 'LeftCurly' checkstyle rule to enforce braces on next line on build
> -----------------------------------------------------------------------
>
>                 Key: CASSANDRA-19276
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-19276
>             Project: Cassandra
>          Issue Type: Task
>          Components: Build
>            Reporter: Andy Tolbert
>            Assignee: Andy Tolbert
>            Priority: Low
>         Attachments: checkstyle_lcurly_output.zip
>
>
> It came up in a review that I had missed some style changes in 
> [CASSANDRA-18857] 
> (https://github.com/apache/cassandra/pull/2969#pullrequestreview-1810999533). 
>  Chatting with [~smiklosovic] we agreed that it would be nice if we could 
> enforce this in checkstyle, so we wouldn't need to be dependent on this being 
> caught in review.
> The change for this is effectively:
> {code}
> index 8b81f21281..9bd22dc1ac 100644
> --- a/.build/checkstyle.xml
> +++ b/.build/checkstyle.xml
> @@ -179,6 +179,10 @@
>        <message key="matchxpath.match"
>                 value="'Deprecated annotation must provide 'since' value."/>
>      </module>
> +    <module name="LeftCurly">
> +        <property name="option" value="nl"/>
> +        <property name="tokens" 
> value="ANNOTATION_DEF,CLASS_DEF,CTOR_DEF,ENUM_CONSTANT_DEF,INTERFACE_DEF,LITERAL_CASE,LITERAL_CATCH,LITERAL_DEFAULT,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_SWITCH,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,METHOD_DEF,OBJBLOCK,STATIC_INIT,RECORD_DEF,COMPACT_CTOR_DEF"/>
> +    </module>
>    </module>
>  </module>
> {code}
> Notably, we would allow braces on the same lines for lambdas as per the 
> [project 
> guidelines|https://cassandra.apache.org/_/development/code_style.html] on 
> code formatting:
> {quote}
>  {{{}} and {{}}} are placed on a new line except when empty or opening a 
> multi-line lambda expression. Braces may be elided to a depth of one if the 
> condition or loop guards a single expression.
> {quote}
> There are 594 violations and 211 source files that would need to be adjusted. 
>   I may play with the rules a little bit more to get this right.
> I would like to propose that we change all files that are not imported from 
> other projects (there are a few, such as 
> src/java/org/apache/cassandra/utils/obs/BitUtil.java, which we can suppress 
> changes for), but we would change others.  
> I'll make a patch with the changes send a small proposal to the mailing list 
> as it could be disruptive to make a bunch of tiny changes, and depending on 
> timing there may be a better time to make a change like this.
> We should make this change only on trunk.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to