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

Stop always wrapping chained function calls in Kotlin. #77

Merged
merged 1 commit into from
Aug 11, 2020
Merged

Stop always wrapping chained function calls in Kotlin. #77

merged 1 commit into from
Aug 11, 2020

Conversation

vRallev
Copy link
Collaborator

@vRallev vRallev commented Aug 11, 2020

The old setting used "Always wrap", the new setting uses "Chop down if long". The Java code style uses "Chop down if long", too.

The old setting made code harder to read in many scenarios:

// Old
assertThat(myList).containsExactly("a", "b", "c")
    .inOrder()

// New
assertThat(myList).containsExactly("a", "b", "c").inOrder()
// Old
if (project.file("src/debug")
        .exists() || project.file("src/release")
        .exists()
) {
  return
}

// New
if (project.file("src/debug").exists() || project.file("src/release").exists()) {
  return
}
// Old
val string = "The project path is ${
      project.path.substring(1)
          .replace(':', '/')
    }"

// New
val string = "The project path is ${project.path.substring(1).replace(':', '/')}"
// Old
stringList
    .filter {..}
    .map {
      it.trim()
          .substring(1)
    }

// New
stringList
    .filter {..}
    .map { it.trim().substring(1) }

…g used "Always wrap",

the new setting uses "Chop down if long". The Java code style uses "Chop down if long", too.

The old setting made code harder to read in many scenarios:

// Old
assertThat(myList).containsExactly("a", "b", "c")
    .inOrder()

// New
assertThat(myList).containsExactly("a", "b", "c").inOrder()

// Old
if (project.file("src/debug")
        .exists() || project.file("src/release")
        .exists()
) {
  return
}

// New
if (project.file("src/debug").exists() || project.file("src/release").exists()) {
  return
}

// Old
val string = "The project path is ${
      project.path.substring(1)
          .replace(':', '/')
    }"

// New
val string = "The project path is ${project.path.substring(1).replace(':', '/')}"

// Old
stringList
    .filter {..}
    .map {
      it.trim()
          .substring(1)
    }

// New
stringList
    .filter {..}
    .map { it.trim().substring(1) }
@swankjesse swankjesse merged commit 38002eb into square:master Aug 11, 2020
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.

3 participants