Skip to content
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

Line break and infix operators #45

Closed
lorenzwalthert opened this issue Oct 29, 2017 · 2 comments
Closed

Line break and infix operators #45

lorenzwalthert opened this issue Oct 29, 2017 · 2 comments

Comments

@lorenzwalthert
Copy link
Contributor

In styler, we were wondering whether it would make sense to add a rule to the style guide that says

If you use infix operators (such as |, & etc.) and you decide to break the line around them, the
line break should occur after the infix operator, not before it.

# good
if (a_long_condition & and_another_long_condition &
  one_more) {
    # do something
}

# bad
if (a_long_condition & and_another_long_condition
  & one_more) {
    # do something
}

Or whether conditions should not be that long anyways so the problem does not occur and / or it is an edge case not worth mentioning.

In any case, we would probably implement a rule in styler that moves the infix operator one line up to change # bad above to # good.
cc: @krlmlr.

@hadley
Copy link
Member

hadley commented Oct 30, 2017

I don't think there's a good way to style that without rewriting.

@lorenzwalthert
Copy link
Contributor Author

lorenzwalthert commented Nov 2, 2017

Ok, thanks anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants