open-policy-agent / opa

Open Policy Agent (OPA) is an open source, general-purpose policy engine.
https://www.openpolicyagent.org
Apache License 2.0
9.52k stars 1.32k forks source link

fmt: respect one-liner `if` expressions even when an `else` is present #6733

Open anderseknert opened 4 months ago

anderseknert commented 4 months ago

Whether else should be moved to a line of its own at all is debatable, but I think the formatter at minimum should respect simple one-liner constructs when else is involved:

This:

foo if input.bar else := false

Currently formats to this:

foo if input.bar

else := false

Which just makes the else look entirely detached from the if.

stale[bot] commented 3 months ago

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.