-
Notifications
You must be signed in to change notification settings - Fork 151
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
Adopt scalafmt for Scala code style #3841
Conversation
ea8435b
to
b0960a8
Compare
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've skimmed through and this seems good to me; the pros of having a consistently-enforced Scala style outweigh any possible cons from a particular piece of code looking suboptimal.
I'd register a weak preference in favour of column alignment.
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.
A few nitpicks regarding comments.
I'm in favor of code alignment.
lgtm otherwise.
k-distribution/src/test/scala/org/kframework/backend/kore/KoreTest.scala
Show resolved
Hide resolved
case Rewrites(_, p1, p2) => symbols(p1) ++ symbols(p2) | ||
case _ => Seq() | ||
case _ => Seq() |
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 take it back. This looks nice.
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.
Indeed, it is much more readable!
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.
This looks really nice! Thanks for your work @Scott-Guest!
I would advocate for the column align as well!
I made some comments about comments😅!
I'm not sure if we want to enforce the column alignment on them as well, but if we want to, we need to make sure they look as readable as they were before and that their meaning is the same!
I'll request a change at least for the kore/src/main/scala/org/kframework/unparser/Unparse.scala
if you don't mind!
@dwightguth queries editor integrations - other than IntelliJ. |
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.
LGTM!
@Scott-Guest, do you know why the |
An admin (@ehildenb, @dwightguth, @F-WRunTime) will need to amend the branch protection rules |
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.
This looks good to me regarding the scala code itself. I'm bearish on formatting comments, I think it's outside the scope of what can be expected from a formatter and there can be specific ways a coder would want to format their comments that a formatter might contend against. Those are my two cents, it sounds like everyone else is fine with it.
Yeah, I agree with this basically @gtrepta and I think it's a reasonable concern - for the formatters we've chosen:
|
@gtrepta @Baltoli If need be, we can also configure spotless to disable formatting of certain sections using This is done at a higher level than the formatters (removing the section of code out of the file, running the formatter, then re-inserting it), so it works even with google-java-format which doesn't natively have this ability. |
In runtimeverification/k#3841, we adopted the `scalafmt` tool to auto-format the Scala code in the K frontend. This PR adopts a precisely identical formatting setup for the LLVM backend's Scala code.
Closes #3827.
This PR adopts scalafmt for Scala code formatting.
Specifically,
google-java-format
andscalafmt
are now handled by thespotless
Maven pluginmvn spotless:check
to check formatting (ormvn verify
)mvn spotless:apply
to auto-format all source files (ormvn process-sources
ormvn package
)mvn spotless:check
to enforce formattingIntellij has built-in support for
scalafmt
. Enable it by openingSettings > Editor > Code Style > Scala
and settingScalafmt
k/src/main/config/.scalafmt.conf
The documentation on the different configuration options can be found here: https://scalameta.org/scalafmt/docs/configuration.html.
Currently, I've formatted with my preferred settings, but committed two versions:
I'd appreciate if everyone who works on the frontend could skim through the files and let me know your thoughts!