Navigation Menu

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

Enforce trailing commas at call site by default #1670

Merged
merged 6 commits into from Nov 6, 2022

Conversation

3flex
Copy link
Contributor

@3flex 3flex commented Oct 7, 2022

Description

The Kotlin Coding Conventions says re: trailing commas:

The Kotlin style guide... leaves it at your discretion for the call site.

However it also says:

Using trailing commas has several benefits:

  • It makes version-control diffs cleaner – as all the focus is on the changed value.
  • It makes it easy to add and reorder elements – there is no need to add or delete the comma if you manipulate elements.
  • It simplifies code generation, for example, for object initializers. The last element can also have a comma.

This suggests only benefits but no downsides (other than personal taste) to enforcing the use of trailing commas by default.

ktlint currently enforces no commas at call sites by default, which is opinionated in a way that conflicts with this guidance and the rationale for using trailing commas in all cases.

Checklist

  • PR description added
  • tests are added
  • KtLint has been applied on source code itself and violations are fixed
  • documentation is updated
  • CHANGELOG.md is updated

In case of adding a new rule:

@paul-dingemans
Copy link
Collaborator

Tnx for your patch. For this setting I have some more diffculty with setting true as default setting. As of that it should be explained in documentation and changelog that for consistency reasons the default is changed. For Android, I can not find such a recommendation and as of that it should not change (set androidDefaultValue to false). Please also update the documentation and changelog.

@paul-dingemans paul-dingemans merged commit 758708d into pinterest:master Nov 6, 2022
@3flex 3flex deleted the patch-2 branch November 6, 2022 21:16
valfirst added a commit to vividus-framework/vividus-test-site that referenced this pull request Jan 18, 2023
valfirst added a commit to vividus-framework/vividus-test-site that referenced this pull request Jan 18, 2023
* Bump com.diffplug.spotless from 6.12.0 to 6.13.0

Bumps com.diffplug.spotless from 6.12.0 to 6.13.0.

---
updated-dependencies:
- dependency-name: com.diffplug.spotless
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix Spotless violations from ktlint

New default behaviour: pinterest/ktlint#1670

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Valery Yatsynovich <valery_yatsynovich@epam.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants