-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Don't split a short line static method to two lines. #626
Comments
I think it would be weird to have the |
maybe, although, now I find myself trying to recall if typescript has static functions on classes. usually if you want a static function it doesn't go into a class itself. Do what though wilt. I just thought it was odd, but it's not a huge deal. We were comparing style outputs between a few formatters, and I generally use this one ;) . |
I believe the TypeScript equivalent of the input you provided would roughly be: class Example {
private static createInstance<T extends Group>(entity: Group): (ctor: { newInstance: (...args: unknown[]) => unknown }) => T {
return ctor => Try.of(() => {
var ng = ctor.newInstance(entity.getId(), entity.getSystemGenerated(), entity.getVersionKey()) as T;
return ng;
})
.getOrElseThrow(ex => new RuntimeException(ex));
}
} Such an input yields the following output from Prettier (playground): class Example {
private static createInstance<T extends Group>(
entity: Group,
): (ctor: { newInstance: (...args: unknown[]) => unknown }) => T {
return ctor =>
Try.of(() => {
var ng = ctor.newInstance(entity.getId(), entity.getSystemGenerated(), entity.getVersionKey()) as T;
return ng;
}).getOrElseThrow(ex => new RuntimeException(ex));
}
} I think an appropriate action item for this issue would be to try to align Prettier Java's formatting of chained method invocations with lambda parameters more closely with Prettier TypeScript's. |
Yeah that looks closer (If not the same?) As what I said I was expecting. |
I think the difference is that the |
is this consistent with typescript? var result = ImmutableFindCustomerCommand
.builder()
.correlationId(UUID.randomUUID().toString())
.build()
.apply(customerApi)
.block(); again, I thought that formatter did var result = ImmutableFindCustomerCommand.builder()
.correlationId(UUID.randomUUID().toString())
.build()
.apply(customerApi)
.block(); thinking this is just another example of this same issue. P.S. Not to be an impatient jerk... is this ticket something you think will be fixed within the next few weeks, or is it a ways off. Only asking because I'm implementing prettier where java is the primary concern, and if anyone asks I'd love to have an answer if asked. |
Hey, thanks for the good work, I suspect the PR fixed this, but in case it didn't, I figured I'd share it now. Checkstyle alerted me. Although, I'm not certain if it's actually complaining about this issue, it thinks the indentation is wrong on line ... well 3 of the markdown excerpt. I have to refactor this code anyways. Might be a 2nd issue here though. Supplier<String> gitVersion = () ->
Optional
.ofNullable(porcelainGit.describe())
.map(v -> v.substring(1))
.map(v -> v.contains("g") ? v + "-SNAPSHOT" : v)
.orElse(null); |
putting
Try
andof
on separate lines here seems weird.Input:
Output:
Expected behavior:
or perhaps even this since the return is implicit.
Configuration:
The text was updated successfully, but these errors were encountered: