pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.06k stars 504 forks source link

Names for call arguments for Java classes should be in same line #2663

Closed dmitry-oshurkov closed 1 month ago

dmitry-oshurkov commented 1 month ago

Expected Behavior

Rectangle(
    /* x = */ (x1 * width).roundToInt(),
    /* y = */ (y1 * height).roundToInt(),
    /* width = */ ((x2 - x1) * width).roundToInt(),
    /* height = */ ((y2 - y1) * height).roundToInt()
)

Rectangle(/* x = */ 1040, /* y = */ 321, /* width = */ 81, /* height = */ 96)

Observed Behavior

Rectangle(
      /* x = */
      (x1 * width).roundToInt(),
      /* y = */
      (y1 * height).roundToInt(),
      /* width = */
      ((x2 - x1) * width).roundToInt(),
      /* height = */
      ((y2 - y1) * height).roundToInt()
  )

// A block comment in between other elements on the same line is disallowed (cannot be auto-corrected) (standard:comment-wrapping)
Rectangle(/* x = */ 1040, /* y = */ 321, /* width = */ 81, /* height = */ 96)
paul-dingemans commented 1 month ago

This behavior is intentional.

You disable the rule comment-wrapping entirely in .editorconfig by setting:

root = true

[*.{kt,kts}]
ktlint_standard_comment-wrapping = disabled

Or suppress statements like below:

@Suppress("ktlint:standard:comment-wrapping")
Rectangle(
    /* x = */ (x1 * width).roundToInt(),
    /* y = */ (y1 * height).roundToInt(),
    /* width = */ ((x2 - x1) * width).roundToInt(),
    /* height = */ ((y2 - y1) * height).roundToInt(),
)