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

Use ktfmt for formatting #571

Merged
merged 7 commits into from
Sep 3, 2024
Merged

Use ktfmt for formatting #571

merged 7 commits into from
Sep 3, 2024

Conversation

rock3r
Copy link
Collaborator

@rock3r rock3r commented Aug 30, 2024

This PR switches our formatting both in Gradle and in the IDE to ktfmt.

Ktfmt has minimal configuration, and we use these settings:

  • Max line length 120
  • Indent and continuation indent: 4 spaces
  • Remove unused imports
  • Handle trailing commas

This is the closest possible to our existing style, minimizing change.

We decided to move from ktlint to ktfmt for formatting because, even tho the latter does not always produce the nicest looking code, it is at least deterministic across machines and OSes. This should eliminate issues where different team members get different formatting for the same code, which has been particularly annoying recently.

Important

This PR does not contain the actual reformatting. A follow-up is coming with the reformatting. This PR will briefly make main red until that is also merged.

This PR also disables ktlint's formatter in the IDE, and marks ktfmt, Kotlin, and KDoc formatter plugins as required. Lastly, this PR also upgrades the Kotlinter Gradle plugin.

rock3r added 6 commits August 30, 2024 15:28
* Make ktlint plugin required again, but set to manual
* Make ktlint not used for formatting in IDE
* Make ktfmt plugin required, used for formatting in IDE
* Make pre-push run config use ktfmt
* Add ktfmt Gradle plugin
* ktfmt uses kotlinlang style both in IDE and Gradle
Also sets a minimum version for the ktfmt plugin that supports custom
styles, and stores our style.
@rock3r rock3r added cleanup Improve the project/tooling and/or get rid of tech debt maintenance Rote maintenance tasks (e.g., dependency updates) labels Aug 30, 2024
@rock3r rock3r requested a review from hamen August 30, 2024 15:52
@rock3r rock3r self-assigned this Aug 30, 2024
@rock3r rock3r mentioned this pull request Aug 30, 2024
* Reformat everything with ktfmt

* Don't nag about ktlint suppressions in .editorconfig

* Suppress ktlint checks that clash with ktfmt

* Disable MergeSarifTask for now

* Disable upload-sarif CI step for now
@rock3r rock3r enabled auto-merge (squash) September 3, 2024 13:44
@rock3r rock3r merged commit fc4c9cb into main Sep 3, 2024
1 check passed
@rock3r rock3r deleted the use-ktfmt-for-formatting branch September 3, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Improve the project/tooling and/or get rid of tech debt maintenance Rote maintenance tasks (e.g., dependency updates)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants