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

False positive "Unexpected indentation" for a closure parameters #1936

Closed
artour-bakiev opened this issue Apr 12, 2023 · 2 comments
Closed
Assignees
Milestone

Comments

@artour-bakiev
Copy link

Expected Behavior

The code fragment (below) formatted with the default IDE settings. It shouldn't raise "Unexpected indentation" error.

Observed Behavior

ktlint reports the following errors:

test.kt:413:1: Unexpected indentation (25) (should be 16) (indent)

Steps to Reproduce

Code example:

    private fun test() {
        val closureA = { a: Int,
                         b: Int ->
            a * b
        }
    }

test.kt:413 corresponds to the b: Int -> line.

Your Environment

  • Version of ktlint used - 0.48.2
  • Android Studio - Electric Eel | 2022.1.1 Patch 2
  • A custom gradle task for Gradle 7.6
  • Operating System and version - MacOS 13.3.1

Content of . editorconfig

[*.{kt,kts}]
indent_size=4
insert_final_newline=true
max_line_length=120
ktlint_standard_wrapping = disabled
ktlint_standard_import-ordering = disabled

P.S. Not sure if it's a duplicate for #1935

@paul-dingemans
Copy link
Collaborator

paul-dingemans commented Jul 13, 2023

Currently the Kotlin Coding conventions state following:

If the parameter list is too long to fit on a line, put the arrow on a separate line:

  foo {
     context: Context,
     environment: Env
     ->
     context.configureEnv(environment)
  }

Sample above is also accepted by the IntelliJ IDEA default code formatter. In #2121 a new rule is to be created which will wrap the first parameter of the lambda in case the lambda has multiline parameters list, or in case the single line parameter list does not fit on the same as the opening brace of the lambda.

@paul-dingemans paul-dingemans self-assigned this Jul 13, 2023
@paul-dingemans paul-dingemans added this to the 1.0 (Yeah!) milestone Jul 13, 2023
@paul-dingemans
Copy link
Collaborator

Solved by #2137

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

No branches or pull requests

2 participants