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

Reformat Kotlin code to upgrade ktlint version #4488

Merged
merged 6 commits into from
Dec 2, 2022

Conversation

ks-yim
Copy link
Contributor

@ks-yim ks-yim commented Oct 18, 2022

Motivation:

To upgrade ktlint version from 0.36.0 to ktlint-gradle plugin's default (0.43.2).
Armeria's some kotlin code violates the new ktlint version's default ruleset, especially, when it comes to adding newlines.

Modifications:

  • Run ./gradlew ktlintFormat task once.
  • Manually reformat some code for better readability.

@codecov
Copy link

codecov bot commented Oct 18, 2022

Codecov Report

Base: 74.05% // Head: 74.03% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (eac8378) compared to base (8bc6f19).
Patch coverage: 7.31% of modified lines in pull request are covered.

❗ Current head eac8378 differs from pull request most recent head 7823909. Consider uploading reports for the commit 7823909 to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4488      +/-   ##
============================================
- Coverage     74.05%   74.03%   -0.02%     
+ Complexity    18167    18159       -8     
============================================
  Files          1536     1536              
  Lines         67378    67380       +2     
  Branches       8520     8520              
============================================
- Hits          49894    49885       -9     
- Misses        13412    13423      +11     
  Partials       4072     4072              
Impacted Files Coverage Δ
...rp/armeria/client/ClientRequestContextWrapper.java 8.10% <0.00%> (ø)
...linecorp/armeria/common/RequestContextWrapper.java 9.75% <0.00%> (-2.44%) ⬇️
...ver/annotated/kotlin/MarkdownDescriptionService.kt 29.41% <0.00%> (ø)
...rver/annotated/kotlin/MermaidDescriptionService.kt 66.66% <ø> (ø)
...e/armeria/contextpropagation/kotlin/MainService.kt 0.00% <0.00%> (ø)
...p/armeria/server/ServiceRequestContextWrapper.java 9.43% <2.77%> (ø)
...rmeria/internal/common/kotlin/ArmeriaKotlinUtil.kt 39.47% <31.25%> (+3.36%) ⬆️
...n/java/com/linecorp/armeria/server/HttpServer.java 40.00% <0.00%> (-20.00%) ⬇️
...armeria/internal/common/stream/SubscriberUtil.java 72.22% <0.00%> (-11.12%) ⬇️
.../linecorp/armeria/client/retrofit2/PipeBuffer.java 84.44% <0.00%> (-4.45%) ⬇️
... and 19 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ks-yim ks-yim changed the title [TEST] line-gradle-script update Reformat Kotlin code to upgrade ktlint version Oct 24, 2022
@ks-yim
Copy link
Contributor Author

ks-yim commented Oct 24, 2022

@minwoox @ikhoon @jrhee17
I've updated the PR to reformat kotlin code as per the discussion in line/gradle-scripts#134.
PTAL 🙏. It would be nice if you can give some advice about the right process of updating line-gradle-scripts.

@minwoox
Copy link
Contributor

minwoox commented Oct 24, 2022

Thanks for updating it. 😄

It would be nice if you can give some advice about the right process of updating line-gradle-scripts.

We use git-subrepo.
https://github.com/line/armeria/blob/master/gradle/scripts/.gitrepo#L4
The process is:

  • Sending a PR to /line/armeria to check if it works.
  • Sending a PR to /line/gradle-scripts that contains the changes of Gradle scripts.
  • Merging the gradle-scripts PR.
  • Updating the Armeria PR using git-subrepo. (In the root directory, you can just execute git subrepo pull gradle/scripts)
  • Merging and Done.

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

Thanks!! 🙇‍♂️

@ikhoon ikhoon added the cleanup label Oct 31, 2022
@ikhoon ikhoon added this to the 1.21.0 milestone Oct 31, 2022
Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Looks good! Left a minor question. Thanks for the cleanup @ks-yim 🙇 👍 🙇

@@ -27,7 +25,7 @@ configure(projectsWithFlags('kotlin')) {
disabledRules = ["import-ordering"]

filter {
exclude("**/gen-src/**")
exclude { it.file.path.contains("gen-src/") }
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor Question) What kind of patterns does the updated rule filter as opposed to the original pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure of the exact reason but the project I've recently setup won't build well without adding this directive.
It tries to lint the files in project-root/gen-src/main/kotlinGrpc/*.

The ktlint plugin states that this can happen for dynamically attaches sources that are located outside the project dir (ref. https://github.com/JLLeitschuh/ktlint-gradle#faq).

I will make a reproducer and share it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's interesting. Thanks for fixing it. 😄

I will make a reproducer and share it here.

Because it's obvious and the link clearly explains the limit, I think we don't need to check the reproducer unless you really want to share. 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jrhee17 @minwoox
Sorry I was late 😅. Made a reproducer at https://github.com/ks-yim/gradle-scripts-grpc-kotlin-ktlint-error-reproducer.
The build fails with the following error.

> Task :grpc-app:compileJava
Note: /Users/ks-yim/IdeaProjects/gradle-scripts-ktlint/grpc-app/gen-src/main/java/com/google/protobuf/compiler/PluginProtos.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :grpc-app:ktlintMainSourceSetCheck FAILED
/Users/ks-yim/IdeaProjects/gradle-scripts-ktlint/grpc-app/gen-src/main/kotlinGrpc/HelloGrpcKt.kt:1:1 object HelloServiceGrpcKt should be declared in a file named HelloServiceGrpcKt.kt (cannot be auto-corrected) (filename)
/Users/ks-yim/IdeaProjects/gradle-scripts-ktlint/grpc-app/gen-src/main/kotlinGrpc/HelloGrpcKt.kt:27:1 Unexpected indentation (2) (should be 4) (indent)
/Users/ks-yim/IdeaProjects/gradle-scripts-ktlint/grpc-app/gen-src/main/kotlinGrpc/HelloGrpcKt.kt:29:1 Unexpected indentation (2) (should be 4) (indent)
/Users/ks-yim/IdeaProjects/gradle-scripts-ktlint/grpc-app/gen-src/main/kotlinGrpc/HelloGrpcKt.kt:30:1 Unexpected indentation (2) (should be 4) (indent)
/Users/ks-yim/IdeaProjects/gradle-scripts-ktlint/grpc-app/gen-src/main/kotlinGrpc/HelloGrpcKt.kt:31:1 Unexpected indentation (4) (should be 8) (indent)
/Users/ks-yim/IdeaProjects/gradle-scripts-ktlint/grpc-app/gen-src/main/kotlinGrpc/HelloGrpcKt.kt:33:1 Unexpected indentation (2) (should be 4) (indent)
/Users/ks-yim/IdeaProjects/gradle-scripts-ktlint/grpc-app/gen-src/main/kotlinGrpc/HelloGrpcKt.kt:34:1 Unexpected indentation (4) (should be 8) (indent)
/Users/ks-yim/IdeaProjects/gradle-scripts-ktlint/grpc-app/gen-src/main/kotlinGrpc/HelloGrpcKt.kt:35:1 Unexpected indentation (4) (should be 8) (indent)
...

@minwoox
Copy link
Contributor

minwoox commented Nov 28, 2022

line/gradle-scripts#134
line/gradle-scripts#135
are merged. Could you pull the changes using subrepo, please?

subrepo:
  subdir:   "gradle/scripts"
  merged:   "10ef4cfa8"
upstream:
  origin:   "https://github.com/line/gradle-scripts"
  branch:   "master"
  commit:   "10ef4cfa8"
git-subrepo:
  version:  "0.4.5"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "dbb99be"
@ks-yim
Copy link
Contributor Author

ks-yim commented Nov 28, 2022

@minwoox
Pulled the new master!
But I couldn't just do git subrepo pull gradle/scripts and succeeded after adding -f flag.

It looks like the original parent SHA in .gitrepo file no longer exists.

@minwoox minwoox merged commit 75867ae into line:master Dec 2, 2022
@minwoox
Copy link
Contributor

minwoox commented Dec 2, 2022

@ks-yim, thanks soooooo much! 😄

@ks-yim ks-yim deleted the test-gradle-scripts branch December 2, 2022 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants