-
-
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
Introduce Scalafmt #2562
Introduce Scalafmt #2562
Conversation
43846cd
to
6a802c9
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.
There's a lot of potential bikeshedding here but I'll limit it to arg lists for round 1. Thanks for taking this on!
EqFA: Eq[F[A]]): RuleSet = | ||
new DefaultRuleSet(name = "flatMapTailRec", | ||
parent = None, | ||
"tailRecM consistent flatMap" -> forAll(laws.tailRecMConsistentFlatMap[A] _)) |
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 prefer a tighter wrapping style.
def tailRecM[A: Arbitrary](
implicit ArbFA: Arbitrary[F[A]],
ArbAFA: Arbitrary[A => F[A]],
EqFA: Eq[F[A]]
): RuleSet =
new DefaultRuleSet(
name = "flatMapTailRec",
parent = None,
"tailRecM consistent flatMap" -> forAll(laws.tailRecMConsistentFlatMap[A] _)
)
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 lets you do this if you'd like, you just need to add the returns at the beginning and at the end. I'm not going to go though all of them tho.
d5948b1
to
b66681f
Compare
Codecov Report
@@ Coverage Diff @@
## master #2562 +/- ##
==========================================
- Coverage 95.21% 95.14% -0.07%
==========================================
Files 361 361
Lines 6598 6630 +32
Branches 280 289 +9
==========================================
+ Hits 6282 6308 +26
- Misses 316 322 +6
Continue to review full report at Codecov.
|
299b77a
to
4cfc2da
Compare
so is scalafmt applied on every compile? |
@kailuowang No, you need to run |
@joan38 I saw some people use vscode, vim and other editors. 😀 neo-sbt-scalafmt automatically reformat code on every compile with some configuration. |
Sorry I missed the previous discussion on this, what did we decide to do IRT enforcing this? add to commit hook? or is there a way to run scalafmt only against changed file (using git)? |
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 so much @joan38!
I am definitely more concerned about consistency and not having to think about formatting then I am about what the formatting itself is. We'll never be able to find something that everyone is 100% in agreement on.
I left a comment about validateJVM
that I think should be addressed in one way or another before we merge this to ensure that in the future CI catches formatting issues.
build.sbt
Outdated
else | ||
Seq( | ||
"-Ymacro-annotations" | ||
)), |
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 seems a bit excessive with respect to whitespace to me, but I don't know if this is something that's easily configurable?
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 just wants the closing bracket to be on the same indent as the opening one or on a single line.
We just need to put it on a single line the thing. Tho I'm not going to do it for all of them.
build.sbt
Outdated
addCommandAlias("validateFreeJS", "freeJS/test") //separated due to memory constraint on travis | ||
|
||
addCommandAlias("validate", ";clean;validateJS;validateKernelJS;validateFreeJS;validateJVM") | ||
addCommandAlias("validate", ";clean;scalastyle;fmtCheck;validateJS;validateKernelJS;validateFreeJS;validateJVM") |
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 think that it might be better to move the scalastyle and format check back to validateJVM
. While it's not JVM-specific, our build runs validateJVM
or validateJS
depending on whether it's a JVM or JS build (combining both in a single build leads to more memory issues). So to make sure that this is run, I think that we need to choose one for it to run in, and validateJVM
is what we were using.
Our builds probably need a bit of an overhaul, but I don't think that we should try to tackle that in a PR that has this big of a changeset, or we'll never get either merged :)
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.
👍
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 reverted this
* res1: Option[String] = None | ||
* }}} | ||
*/ | ||
* Return ().pure[F] if `condition` is true, `empty` otherwise |
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.
While we probably haven't been entirely consistent, I think that we've been using javadoc-style comments, so I think that docstrings = JavaDoc
might be a good setting for us. Unless I'm wrong and that actually generates a bigger diff...
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.
👍
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.
The diff is much smaller now :)
@ikhoon not only neo-sbt-scalafmt can do it. |
@kailuowang my vote would be to run the scalafmt check as part of This looks good to me. My only concern is that some builds have been timing out, but I don't know how much that's exacerbated by this PR. I'm checking out a few things locally, but I think that I'd be good with this being merged in its current form. |
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 just ran this locally, and running fmtCheck
took less than a minute, so it shouldn't be contributing too much to builds taking too long.
I am still a bit concerned that people will keep pushing unformatted code (this new rule is stricter than the previous scalastyle) that fails the build. This may cause more traffic in build queue. I suggest that we add a sbt task that runs some sanity test (like |
@kailuowang yeah, I can see that concern. It's possible that running format on compile would be just fine; I'm not sure. And maybe we could switch things around a bit so BUT since this PR has a huge changeset that's likely to cause merge conflicts, I'm inclined to get this merged and figure that out afterwards. |
Thanks guys for your comments. Let me if I can do anything. |
follow up PR #2567 |
This is with mostly the default settings.
I removed some overlapping scalastyle settings.
I raised the scalastyle method line limit from 50 to 55, because I don't see how to decompose those functions like in
NonEmptyTraverseTests.nonEmptyTraverse
.The important files are:
project/plugins.sbt
build.sbt
.scalafmt
scalastyle-config.xml
The rest is applied formatting.
Let me know your thoughts.