-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
format: keep new lines in between function arguments #3864
Merged
srenatus
merged 1 commit into
open-policy-agent:main
from
srenatus:sr/formatter/newlines-in-fun-arguments
Oct 6, 2021
Merged
format: keep new lines in between function arguments #3864
srenatus
merged 1 commit into
open-policy-agent:main
from
srenatus:sr/formatter/newlines-in-fun-arguments
Oct 6, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
anderseknert
previously approved these changes
Oct 6, 2021
|
||
p { | ||
x := count( | ||
[1, 2, 3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens to a comment after the array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's appended at the end, just like before. added it to the test case just to be sure.
This snippet, r = contains( input.x, "y", ) would have been formatted as r = contains(input.x, "y") before. Now, any new lines added between function arguments will be kept, and the snippet will not be reformatted. As a consequence, comments on the separate arguments we OK: r = contains( input.x, # haystack "y", # needle ) and don't freak out the formatter. Fixes open-policy-agent#3836. Signed-off-by: Stephan Renatus <[email protected]>
srenatus
force-pushed
the
sr/formatter/newlines-in-fun-arguments
branch
from
October 6, 2021 12:48
9d8afd5
to
183af7d
Compare
anderseknert
approved these changes
Oct 6, 2021
dolevf
pushed a commit
to dolevf/opa
that referenced
this pull request
Nov 4, 2021
…nt#3864) This snippet, r = contains( input.x, "y", ) would have been formatted as r = contains(input.x, "y") before. Now, any new lines added between function arguments will be kept, and the snippet will not be reformatted. As a consequence, comments on the separate arguments we OK: r = contains( input.x, # haystack "y", # needle ) and don't freak out the formatter. Fixes open-policy-agent#3836. Signed-off-by: Stephan Renatus <[email protected]> Signed-off-by: Dolev Farhi <[email protected]>
Trolloldem
added a commit
to Trolloldem/opa
that referenced
this pull request
May 30, 2023
Priot to this change, the `fmt` command panicked when rego files processed contained a comprehension written on multiple lines with comments in these lines. An example of such comprehension is presented in open-policy-agent#5798. After this change, comprehensions on multiple lines are not moved in a single line, in order to correcly handle comments, similarly to what has been already done in open-policy-agent#3864. Fixes: open-policy-agent#5798 Signed-off-by: Gianluca Oldani <[email protected]>
ashutosh-narkar
pushed a commit
that referenced
this pull request
May 30, 2023
Priot to this change, the `fmt` command panicked when rego files processed contained a comprehension written on multiple lines with comments in these lines. An example of such comprehension is presented in #5798. After this change, comprehensions on multiple lines are not moved in a single line, in order to correcly handle comments, similarly to what has been already done in #3864. Fixes: #5798 Signed-off-by: Gianluca Oldani <[email protected]>
ashutosh-narkar
pushed a commit
to ashutosh-narkar/opa
that referenced
this pull request
Jun 5, 2023
Priot to this change, the `fmt` command panicked when rego files processed contained a comprehension written on multiple lines with comments in these lines. An example of such comprehension is presented in open-policy-agent#5798. After this change, comprehensions on multiple lines are not moved in a single line, in order to correcly handle comments, similarly to what has been already done in open-policy-agent#3864. Fixes: open-policy-agent#5798 Signed-off-by: Gianluca Oldani <[email protected]> (cherry picked from commit 917dfc4)
ashutosh-narkar
pushed a commit
that referenced
this pull request
Jun 6, 2023
Priot to this change, the `fmt` command panicked when rego files processed contained a comprehension written on multiple lines with comments in these lines. An example of such comprehension is presented in #5798. After this change, comprehensions on multiple lines are not moved in a single line, in order to correcly handle comments, similarly to what has been already done in #3864. Fixes: #5798 Signed-off-by: Gianluca Oldani <[email protected]> (cherry picked from commit 917dfc4)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This snippet,
would have been formatted as
before. Now, any new lines added between function arguments will be kept, and
the snippet will not be reformatted.
As a consequence, comments on the separate arguments we OK:
and don't freak out the formatter.
Fixes #3836.
Changes to the formatter often have the potential to be annoying, but with this, anything that had been formatted with a previous version should still be formatted the same way. I.e., there would not be any breakage in people's CI running
opa fmt
on committed files.It does, however, broaden the domain of accepted inputs, by not forcing all function arguments to be on one line.