-
Notifications
You must be signed in to change notification settings - Fork 14.4k
MINOR; Update scalafmt to latest version #12475
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
Conversation
build.gradle
Outdated
@@ -30,7 +30,7 @@ buildscript { | |||
} | |||
|
|||
plugins { | |||
id 'com.diffplug.spotless' version '5.12.5' | |||
id 'com.diffplug.spotless' version '6.9.0' |
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 version needed to be updated otherwise spotless would bring resolve the wrong Scala version for scalafmt.
3e7c51f
to
9687494
Compare
version = 3.5.8 | ||
runner.dialect = scala213 | ||
docstrings.style = Asterisk | ||
docstrings.wrap = false |
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 forces scalafmt to ignore docstrings when formatting code. The new version of scalafmt works on docstrings however it doesn't support manual html formatting which is done in kafka scala streams.
@divijvaidya This is one of the first PR's in adding the linting/formatting using scalafmt/scalafix for the Scala sources within Kafka that you talked about here #12471 (comment). @cadonna Do you want to have a look as well since its part of kafka scala streams? |
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 making this change.
- Note that build is failing related to changes in this PR. We would probably need to fix the error but I think I might have already fixed it in MINOR: Catch InvocationTargetException explicitly and propagate underlying cause #12230 If that lands, then the check should pass here.
[2022-08-02T22:58:41.580Z] * What went wrong:
[2022-08-02T22:58:41.580Z] Execution failed for task ':spotlessScala'.
[2022-08-02T22:58:41.580Z] > java.lang.reflect.InvocationTargetException
- I have verified that the style guide we follow for this project is not prescriptive about formatting of the docs. Hence, your change should be ok.
@@ -12,7 +12,10 @@ | |||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
docstrings = JavaDoc | |||
version = 3.5.8 | |||
runner.dialect = scala213 |
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.
We still support scala 2.12 in this project.
By specifying the dialect as 2.13, would we fail where syntax for 2.12 is used? If yes, are there any such cases in the project? (The build should tell us that after the existing spotless check passes).
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 Scala 2.13 dialect is backwards compatible with 2.12. I have applied the dialect when updating from scalafmt 2 to scalafmt 3 with various popular OSS Scala projects and there isn't any issues (in any case the Scala code that is used im Kafka is quite conservative)
I have verified that the style guide we follow for this project is not prescriptive about formatting of the docs. Hence, your change should be ok.
Do you think it makes sense to format the docs or should I leave the PR as is?
Note that build is failing related to changes in this PR. We would probably need to fix the error but I think I might have already fixed it in MINOR: Catch InvocationTargetException explicitly and propagate underlying cause #12230 If that lands, then the check should pass here.
In that case it's sensible to wait for your PR to land and then I can rebase.
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.
Do you think it makes sense to format the docs or should I leave the PR as is?
I think we should leave the PR as is. Converting the docs in the entire project will be cumbersome without any benefit.
In that case it's sensible to wait for your PR to land and then I can rebase.
Thanks, in that case, would you kindly review that PR please if you get some time? It's been pending for a while now waiting to get some attention.
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, in that case, would you kindly review that PR please if you get some time? It's been pending for a while now waiting to get some attention.
I just landed a review of the PR.
The scala 2.12 build failed https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-12475/ |
@ijuma Thanks for the pickup. I have investigated the root cause of the problem, basically when you specify the scala version with I created an issue upstream at diffplug/spotless#1273 |
a4e4dd9
to
a949f92
Compare
a949f92
to
938aea6
Compare
Actually lets wait on merging this PR, it may be possible to fix the underlying problem in spotless (see diffplug/spotless#1273 (comment)) |
938aea6
to
db674ed
Compare
@ijuma So I have some good news, I managed to completely the solve the underlying problem upstream (see diffplug/spotless#1273 (comment)). The PR has been updated/rebased with the newest spotless and as you can see ./gradlew -PscalaVersion=2.12 :spotlessScalaCheck Also tagging @mimaison for visibility |
db674ed
to
553e87b
Compare
Tagging @C0urante for visibility |
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 Matthew! One small question about the changes.
I should note that I wasn't a fan of the import shuffling initially, but it does seem like we wanted import sorting when we originally introduced Scala formatting in #4965 and included the SortImports
rule. So although someone else more familiar with this part of the code base may feel differently, at least from my perspective these changes are fine.
I've kicked off another Jenkins run to see if we can get at least one green build with Scala 2.12.
Updates scalafmt to the latest version. This not only means migrating the checkstyle/.scalafmt.conf file but updating spotless as well. Due to improvements in the new version of scalafmt, it now also alphabetically sorts imports.
553e87b
to
8578153
Compare
So Jenkins did in fact pass this PR as green build. I have just pushed to this PR so another build has been triggered but https://ci-builds.apache.org/blue/organizations/jenkins/Kafka%2Fkafka-pr/detail/PR-12475/8/pipeline is the build that passed. |
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! I'd like it if someone more familiar with Streams could also take a look before merging, though.
Updates scalafmt to the latest version. This not only means migrating
the checkstyle/.scalafmt.conf file but updating spotless as well. Due
to improvements in the new version of scalafmt, it now also
alphabetically sorts imports.
The diff to the actual .scala source files is due to the alphabetical sorting of imports. I verified that this PR passes spotless/scalacheck by running
./gradlew :spotlessScalaCheck
locally.Committer Checklist (excluded from commit message)