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

Regression: more builder chaining being off #650

Open
xenoterracide opened this issue Feb 27, 2024 · 0 comments · May be fixed by #653
Open

Regression: more builder chaining being off #650

xenoterracide opened this issue Feb 27, 2024 · 0 comments · May be fixed by #653

Comments

@xenoterracide
Copy link

xenoterracide commented Feb 27, 2024

Prettier-Java 2.6.0

Input:

2.5.0

      .map(v ->
        v
          .getPreRelease()
          .stream()
          .filter(p -> p.matches("^\\d+-+g\\p{XDigit}{7}$"))
          .findFirst()
          .map(p -> v.withClearedPreRelease().withPreRelease(SNAPSHOT).withBuild(p))
          .orElse(v)

Output:
2.6.0

      .map(
        v ->
          v
            .getPreRelease()
            .stream()
            .filter(p -> p.matches("^\\d+-+g\\p{XDigit}{7}$"))
            .findFirst()
            .map(p -> v.withClearedPreRelease().withPreRelease(SNAPSHOT).withBuild(p))
            .orElse(v)

Expected behavior:
Prettier TS

    .map(v ->
      v
        .getPreRelease()
        .stream()
        .filter((p) => p.matches("^\\d+-+g\\p{XDigit}{7}$"))
        .findFirst()
        .map((p) => v.withClearedPreRelease().withPreRelease(SNAPSHOT).withBuild(p))
        .orElse(v),
    )

oddly, I think that this would be better, but doesn't really match typescript, I find it weird to have v by itself on a line

    .map(v ->
      v.getPreRelease()
        .stream()
        .filter((p) => p.matches("^\\d+-+g\\p{XDigit}{7}$"))
        .findFirst()
        .map((p) => v.withClearedPreRelease().withPreRelease(SNAPSHOT).withBuild(p))
        .orElse(v),
    )

Here's the complete method (as per 2.6.0), I line break at 120

 public Semver getMaven() {
    return describe()
      .map(v -> null == v ? PRE_VERSION : v)
      .map(Semver::coerce)
      .map(v -> Objects.equals(v.getVersion(), PRE_VERSION) ? v.withPreRelease(SNAPSHOT) : v)
      .map(
        v ->
          v
            .getPreRelease()
            .stream()
            .filter(p -> p.matches("^\\d+-+g\\p{XDigit}{7}$"))
            .findFirst()
            .map(p -> v.withClearedPreRelease().withPreRelease(SNAPSHOT).withBuild(p))
            .orElse(v)
      )
      .map(v -> new MavenSemver(v.getVersion()))
      .get();
  }
@xenoterracide xenoterracide changed the title more builder chaining being off Regression: more builder chaining being off Feb 27, 2024
@jtkiesel jtkiesel linked a pull request Mar 5, 2024 that will close this issue
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 a pull request may close this issue.

1 participant