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

Formatting of annotations on return statements #497

Closed
romainguy opened this issue Aug 2, 2024 · 3 comments
Closed

Formatting of annotations on return statements #497

romainguy opened this issue Aug 2, 2024 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@romainguy
Copy link

Original code:

@Suppress("AsCollectionCall")
return map.asMap()

After ktfmt:

@Suppress("AsCollectionCall") return map.asMap()

My issue with this is that it makes the return statement much harder to parse when reading code, especially if that statement isn't the last one in a method. This formatting makes sense for properties/variable declarations but a lot less for returns I think.

@darioseidl
Copy link

Also see #316 which is about annotations with parameters, so it would apply to your example too.

Personally, I feel all annotations should just be put on their own line. That would solve many poorly looking cases.

@hick209
Copy link
Contributor

hick209 commented Aug 13, 2024

That's a fair issue

@hick209 hick209 added bug Something isn't working good first issue Good for newcomers labels Aug 13, 2024
facebook-github-bot pushed a commit that referenced this issue Aug 14, 2024
Summary: Reported on [this issue](#497) which I thought was fair to "fix"

Reviewed By: cortinico

Differential Revision: D61208619

fbshipit-source-id: b244c84d00e340d244161bf594729d8c48e4e2a9
@hick209
Copy link
Contributor

hick209 commented Aug 14, 2024

Fixed with a1ffe3d

Should be released on v0.52

@hick209 hick209 closed this as completed Aug 14, 2024
github-merge-queue bot referenced this issue in slackhq/foundry Aug 28, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [com.facebook:ktfmt](https://togithub.com/facebookincubator/ktfmt) |
dependencies | minor | `0.51` -> `0.52` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>facebookincubator/ktfmt (com.facebook:ktfmt)</summary>

###
[`v0.52`](https://togithub.com/facebookincubator/ktfmt/blob/HEAD/CHANGELOG.md#052)

##### Fixed

- IntelliJ plugin crash
([https://github.com/facebook/ktfmt/pull/501](https://togithub.com/facebook/ktfmt/pull/501))
- Ordering of `@property` and `@param` in KDoc
([https://github.com/facebook/ktfmt/pull/498](https://togithub.com/facebook/ktfmt/pull/498))
- Annotation in return expressions
([https://github.com/facebook/ktfmt/issues/497](https://togithub.com/facebook/ktfmt/issues/497))

##### Changed

- KotlinLang style also managing trailing commas
([https://github.com/facebook/ktfmt/issues/216](https://togithub.com/facebook/ktfmt/issues/216),
[https://github.com/facebook/ktfmt/issues/442](https://togithub.com/facebook/ktfmt/issues/442))
- Converted IntelliJ plugin to Kotlin
([https://github.com/facebook/ktfmt/pull/502](https://togithub.com/facebook/ktfmt/pull/502))

##### Added

- More stability tests
([https://github.com/facebook/ktfmt/pull/488](https://togithub.com/facebook/ktfmt/pull/488))
- Custom profile in plugin settings, mirroring Gradle/Maven plugins
([https://github.com/facebook/ktfmt/pull/503](https://togithub.com/facebook/ktfmt/pull/503))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC40NS4wIiwidXBkYXRlZEluVmVyIjoiMzguNTIuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

---------

Co-authored-by: Zac Sweers <pandanomic@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants