question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Closing parentheses placement for method calls does not match Kotlin style guide

See original GitHub issue

This came up in #10, but IIUC the changes made in that issue were only for method declarations, not method calls.

See e.g. https://kotlinlang.org/docs/reference/coding-conventions.html#method-call-formatting:

drawSquare(
    x = 10, y = 10,
    width = 100, height = 100,
    fill = true
)

One reason this might be worth reconsidering is the support for trailing commas that was added in Kotlin 1.4 (see KT-9476), which will allow writing:

 drawSquare(
     x = 10, y = 10,
     width = 100, height = 100,
-    fill = true
+    fill = true,
 )

Leaving the closing paren ) on the previous line seems like bad style:

 drawSquare(
     x = 10, y = 10,
     width = 100, height = 100,
     fill = true,)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
andrewparmetcommented, Jun 9, 2020

My vote is a new line, wasting the vertical space. IMO the consistency is what I value.

1reaction
cgrushkocommented, Jan 6, 2021

@JavierSegoviaCordoba I’m hesitant to introduce special formatting cases such as builder patterns. First, because I’m concerned it’ll complicate the code and make it less maintainable, and second because it might be difficult to correctly identify the pattern.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Closing parentheses placement for method calls does not match ...
At Google, we are using the first option (all parameters on separate lines, closing parens on its own line). This is also the...
Read more >
Coding conventions | Kotlin
Commonly known and easy-to-follow coding conventions are vital for any programming language. Here we provide guidelines on the code style ...
Read more >
Kotlin style guide | Android Developers
Braces follow the Kernighan and Ritchie style ("Egyptian brackets") for nonempty blocks and block-like constructs: No line break before the opening brace. Line ......
Read more >
Check for Balanced Brackets in an expression (well ...
Given an expression string, write a program to examine whether the pairs and the orders of parentheses are balanced in expression or not....
Read more >
Code Style. Java | IntelliJ IDEA Documentation - JetBrains
In this field, specify the number of spaces to be inserted between the elements of an array, in expressions, method declarations and method...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found