Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

feat: Prevent “dangling” returns and force braces #135

Merged
merged 4 commits into from
Dec 13, 2021

Conversation

mxdvl
Copy link
Contributor

@mxdvl mxdvl commented Dec 8, 2021

What does this change?

If a block contains only one statement, but it’s on a different line than the block start, force curly braces.

Turns:

if(
 conditionOne() &&
 conditionTwo() && 
 conditionThree()
)
  return true;

Into

if(
 conditionOne() &&
 conditionTwo() && 
 conditionThree()
) {
  return true;
}

Why?

This can easily introduce errors when refactoring code. Thanks @arelra for the suggestion

@mxdvl mxdvl requested a review from a team as a code owner December 8, 2021 14:16
@mxdvl mxdvl added the enhancement New feature or request label Dec 8, 2021
sndrs
sndrs previously approved these changes Dec 8, 2021
Copy link
Member

@sndrs sndrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have some formatting errors, but sounds sensible to me!

@mxdvl mxdvl requested review from sndrs and a team December 9, 2021 10:02
@sndrs
Copy link
Member

sndrs commented Dec 13, 2021

are the package bumps needed for this?

Copy link
Member

@sndrs sndrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it, nice one!

@sndrs sndrs merged commit c8af3e7 into main Dec 13, 2021
@sndrs sndrs deleted the mxdvl/curly-multi-line branch December 13, 2021 16:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants