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

Contradictory indentation errors with multiline type parameter list #680

Closed
bethcutler opened this issue Jan 2, 2020 · 2 comments · Fixed by #853
Closed

Contradictory indentation errors with multiline type parameter list #680

bethcutler opened this issue Jan 2, 2020 · 2 comments · Fixed by #853

Comments

@bethcutler
Copy link
Contributor

If a code snippet contains a multi-line type parameter list, ktlint may produce contradictory errors with the experimental indentation rule.

E.g. for this code snippet

object TestCase {
  inline fun <
    T1,
    T2,
    T3> create(
      t1: T1,
      t2: T2,
      t3: T3
  ) {
    // do things
  }
}

... ktlint produces this errors for each function parameter line (t1, t2, t3):

Unexpected indentation (6) (should be 4)

If the indentation on the function parameter lines is "corrected" like so

object TestCase {
  inline fun <
    T1,
    T2,
    T3> create(
    t1: T1,
    t2: T2,
    t3: T3
  ) {
    // do things
  }
}

... ktlint is still not satisfied, now producing this error on each of those lines:

Unexpected indentation (expected 6, actual 4)

@Tapchicoma Tapchicoma added the bug label Jan 8, 2020
@Tapchicoma
Copy link
Collaborator

Probably could be covered by #587

@AdamMTGreenberg
Copy link
Contributor

@Tapchicoma Added PR: #804 to enforce this behavior. However, it is unclear if we want to make this an enforced rule:

object TestCase {
  inline fun <
    T1,
    T2,
    T3> create(
    t1: T1,
    t2: T2,
    t3: T3
  ) {
    // do things
  }
}

to

object TestCase {
  inline fun <
    T1,
    T2,
    T3> create(
      t1: T1,
      t2: T2,
      t3: T3
  ) {
    // do things
  }
}

since the default spacing seems to leave the indentation flat.

If we want to leave it as is, then I think we can close out this issue.

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