commandbox-cfformat icon indicating copy to clipboard operation
commandbox-cfformat copied to clipboard

Require curlies for if statement body

Open bdw429s opened this issue 6 years ago • 5 comments

I don't know how easy this one is or if it falls in the purview of CFFormat since it's actually adding code, not just whitespace. One of my big pet peeves is this:

if( condition )
  randomOrphan.codeThatCanGetSeperated();

I'd love to see an option to change it to this:

if( condition ) {
  niceCodeSecurley.insideIfBody();
}

bdw429s avatar May 22 '19 16:05 bdw429s

Interesting, I think this might be doable. If the code is correct to start with, it certainly should be.

jcberquist avatar May 22 '19 16:05 jcberquist

@bdw429s Just to clarify, you're looking for an option to make the curlies required, right? That is, the requirement could be turned off for those who prefer the more succinct code.

mjclemente avatar May 22 '19 17:05 mjclemente

@mjclemente If by "succinct code", you meant, "horrible lazy bad code", then yes exactly! :laughing: j/k if you like it the succinct way. It would be an optional formatting option to auto-add the curlies for people who wanted it.

bdw429s avatar May 22 '19 19:05 bdw429s

🤣

if( curliesAreNotNeeded )
    party.withoutThem();

Makes sense to me. I don't feel strongly, except about having options.

mjclemente avatar May 22 '19 20:05 mjclemente

I just want CFFormat to not take this:

if( condition )
  randomOrphan.codeThatCanGetSeperated();

and format it to this:

if( condition ) randomOrphan.codeThatCanGetSeperated();

onlyleura avatar Nov 24 '19 22:11 onlyleura