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

Update scalafmt-core to 3.3.3 #4116

Merged
merged 5 commits into from
Jan 28, 2022

Conversation

scala-steward
Copy link
Contributor

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:

updates.ignore = [ { groupId = "org.scalameta", artifactId = "scalafmt-core" } ]

labels: library-update, early-semver-patch, semver-spec-patch, commit-count:n:2

Copy link
Member

@rossabaker rossabaker left a 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?

@satorg
Copy link
Contributor

satorg commented Jan 23, 2022

I created an issue about it: scalameta/scalafmt#3079

@armanbilge
Copy link
Member

FWIW I'm not sure it's an upstream issue. I vote for the no-format block.

@satorg
Copy link
Contributor

satorg commented Jan 23, 2022

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.

@satorg
Copy link
Contributor

satorg commented Jan 23, 2022

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.

@armanbilge
Copy link
Member

How does scalafmt know that this happens to be template code?

@satorg
Copy link
Contributor

satorg commented Jan 23, 2022

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.

Comment on lines 153 to 155
| implicit def catsKernelStdOrderForTuple${arity}[${`A..N`}](implicit ${constraints(
"Order"
)}): Order[${`(A..N)`}] =
Copy link
Contributor

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.

Copy link
Member

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?

Choose a reason for hiding this comment

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

  1. line 146 above: definitely not new
  2. in normal interpolated strings, everything between ${ and } is evaluated and interpolated, no newlines are material

Copy link
Contributor

@satorg satorg Jan 24, 2022

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!

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.

Copy link
Contributor

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.

@satorg
Copy link
Contributor

satorg commented Jan 25, 2022

I wonder, can I change this @scala-steward 's PR somehow?
I'd like to adjust the formatting in a nicer way...

@satorg
Copy link
Contributor

satorg commented Jan 25, 2022

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.

@satorg
Copy link
Contributor

satorg commented Jan 26, 2022

@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.
But all this is solely about code formatting – no real code changes should happen neither in the templates nor in the result code.

Copy link
Member

@armanbilge armanbilge left a 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!)

@satorg
Copy link
Contributor

satorg commented Jan 27, 2022

@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!

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

Successfully merging this pull request may close these issues.

5 participants