-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update scalafmt-core to 3.3.3 #4116
Update scalafmt-core to 3.3.3 #4116
Conversation
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.
I'm not in love with these changes, but I'm tired of fighting defaults.
I guess we could wrap it in a no-format block?
I created an issue about it: scalameta/scalafmt#3079 |
FWIW I'm not sure it's an upstream issue. I vote for the no-format block. |
Perhaps there's a global configuration option that can disable such formatting at once, but it is not described in the docs yet. It would be a better solution I think. |
I mean, I really DO think that formatting any kind of template code is a bad idea. Therefore even if scalafmt guys decide to push it by default, it would be fair to allow disabling it in the config. |
How does scalafmt know that this happens to be template code? |
All code which is enclosed in multiline string blocks is supposed to be some sort of template. At least it is quite reasonable to assume it. It seems that previously scalafmt ignored code inside multiline strings. I wonder why they decided to start formatting it. |
project/KernelBoiler.scala
Outdated
| implicit def catsKernelStdOrderForTuple${arity}[${`A..N`}](implicit ${constraints( | ||
"Order" | ||
)}): Order[${`(A..N)`}] = |
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.
@armanbilge, check out that the formatting breaks code block margins. I believe it should not work in this way. I would suppose it is a bug – the formatter either should be smarter preserving the block margins or don't attempt to format it at all.
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.
That's a good point. Out of curiosity, do these changes affect the output?
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.
- line 146 above: definitely not new
- in normal interpolated strings, everything between
${
and}
is evaluated and interpolated, no newlines are material
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.
@kitbellew oh, I see what you're saying now. Indeed, there was formatting in interpolated strings already applied by one of the previous scalafmt versions. Seems that with this release scalafmt begins applying such a formatting more meticulously. More likely that it is not a new bug has been introduced but rather an older bug has been fixed with this release.
Although I still feel uncertain whether it was initially a good idea of adding line breaks inside pre-formatted blocks (even though solely inside interpolated strings). Is it configurable somehow?
UPD: I found out that there is scalameta/scalafmt#3080 already that you created which should help to avoid unexpected line breaks in interpolated strings. Thank you for looking into it!
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.
Although I still feel uncertain whether it was initially a good idea of adding line breaks inside pre-formatted blocks...
the formatter by design applies high penalties to solutions which are not staying within maxColumn
.
UPD: I found out that there is scalameta/scalafmt#3080 already that you created which should help to avoid unexpected line breaks...
as you could see, the only solution was to apply a higher penalty for line breaks.
in this case, i would have increased maxColumn
or rewrote the code so that it doesn't overflow. after all, exceeding the margins impedes readability, especially since you're using string constants to build code templates.
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.
or rewrote the code so that it doesn't overflow.
I bet this should be the best option.
I wonder, can I change this @scala-steward 's PR somehow? |
Ok, seems I figured it out. I can just push directly into the scala-steward's branch and inject the changes I'd like to make. |
@rossabaker @armanbilge I reformatted the affected files manually to make ScalaFmt happy about the template code and not tempting to insert line breaks inside interpolated stings (although there are two cases which seems impossible to improve). I would say, this change makes both the template code blocks and result generated code looking cleaner and easier to read. |
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.
Thanks for shaving this yak—I skimmed through and I like the changes you made, and more importantly scalafmt likes them 👍 (for now!)
@armanbilge thank you for the feedback. I'm going to merge this in a day so if someone has any objections or concerns, please speak up! |
Updates org.scalameta:scalafmt-core from 3.3.0 to 3.3.3.
GitHub Release Notes - Version Diff
I'll automatically update this PR to resolve conflicts as long as you don't change it yourself.
If you'd like to skip this version, you can just close this PR. If you have any feedback, just mention me in the comments below.
Configure Scala Steward for your repository with a
.scala-steward.conf
file.Have a fantastic day writing Scala!
Ignore future updates
Add this to your
.scala-steward.conf
file to ignore future updates of this dependency:labels: library-update, early-semver-patch, semver-spec-patch, commit-count:n:2