Skip to content

android [nfc]: Auto-format Kotlin code; apply "recommended" style settings#5267

Merged
chrisbobbe merged 6 commits intozulip:mainfrom
gnprice:pr-kotlin-formatting
Mar 2, 2022
Merged

android [nfc]: Auto-format Kotlin code; apply "recommended" style settings#5267
chrisbobbe merged 6 commits intozulip:mainfrom
gnprice:pr-kotlin-formatting

Conversation

@gnprice
Copy link
Copy Markdown
Member

@gnprice gnprice commented Mar 1, 2022

I'd been getting a prompt each time I opened Android Studio recently, reading:

Kotlin code style: Do you want to update your Kotlin code style settings to the recommended ones?

Sure, why not. Also take this as an occasion to get all our Kotlin code auto-format-clean; not much changes.

And while looking at the code-style settings, I discovered there is a setting to enable trailing commas! 🎉 Enable that, too.

@gnprice gnprice changed the title android [nfc]: Auto-format Kotlin code; apply " android [nfc]: Auto-format Kotlin code; apply "recommended" style settings Mar 1, 2022
@gnprice
Copy link
Copy Markdown
Member Author

gnprice commented Mar 1, 2022

Not sure quite what keystroke I hit that caused the PR to be created while I was still typing the title. Anyway, description all written now.

gnprice added 6 commits March 1, 2022 16:47
This simplifies future editing on these files, by letting auto-format
be used freely without adding unrelated changes to diffs.

Done like so:

 * In the breadcrumb list while I had open some file under
   android/app/src/main/, right-clicked on that directory and chose
   "Reformat Code".

 * Left "Optimize imports" unchecked; we'll do that separately.

 * Left scope at "All files", unfiltered.

 * After running that, reverted changes to XML files (I might try
   tweaking those format settings before rerunning there), and
   indentation changes to Java files (ditto; and if we contemplate
   big changes to those files we should just convert them to Kotlin.)
Following a prompt in Android Studio, which read:

  Kotlin code style: Do you want to update your Kotlin code style
    settings to the recommended ones?

Conveniently, this doesn't change much code of ours.
This avoids these blending in with the definitions inside the class.
With Android Studio, applied to the whole android/app/src/ tree.
This comes from using the "Reformat Code" dialog box, and this time
checking the "Cleanup code" (sic) box.

Most of these look like small formatting changes; I don't really
understand why reformatting before without that box checked didn't
already cover those.  Well, whatever.
@chrisbobbe chrisbobbe force-pushed the pr-kotlin-formatting branch from 14a1005 to 4d6b656 Compare March 2, 2022 00:54
@chrisbobbe chrisbobbe merged commit 4d6b656 into zulip:main Mar 2, 2022
@chrisbobbe
Copy link
Copy Markdown
Contributor

LGTM, thanks! Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants