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

cmd/gofmt: last call in fluent API call chain not indented correctly #61331

Closed
willfaught opened this issue Jul 13, 2023 · 5 comments
Closed
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@willfaught
Copy link
Contributor

What did you do?

Formatted this code in the playground:

func (ChannelReview) Edges() []ent.Edge {
	return []ent.Edge{
		edge.From("channel", Channel.Type).
			Unique().
			Required().
			Immutable().
			Ref("reviews").
			Field("channel_id").
			Annotations(entgql.Annotation{
				Skip: entgql.SkipType,
			}),
		edge.To("channel_local_reviews", ChannelLocalReview.Type).
			Annotations(entgql.Annotation{
				RelayConnection: true,
				Skip:            entgql.SkipMutationCreateInput,
			}).Annotations(entsql.Annotation{
			OnDelete: entsql.Cascade,
		}),
	}
}

https://go.dev/play/p/gyGabF-mcGX

What did you expect to see?

func (ChannelReview) Edges() []ent.Edge {
	return []ent.Edge{
		edge.From("channel", Channel.Type).
			Unique().
			Required().
			Immutable().
			Ref("reviews").
			Field("channel_id").
			Annotations(entgql.Annotation{
				Skip: entgql.SkipType,
			}),
		edge.To("channel_local_reviews", ChannelLocalReview.Type).
			Annotations(entgql.Annotation{
				RelayConnection: true,
				Skip:            entgql.SkipMutationCreateInput,
			}).Annotations(entsql.Annotation{
				OnDelete: entsql.Cascade, // indentation different
			}), // indentation different
	}
}

What did you see instead?

func (ChannelReview) Edges() []ent.Edge {
	return []ent.Edge{
		edge.From("channel", Channel.Type).
			Unique().
			Required().
			Immutable().
			Ref("reviews").
			Field("channel_id").
			Annotations(entgql.Annotation{
				Skip: entgql.SkipType,
			}),
		edge.To("channel_local_reviews", ChannelLocalReview.Type).
			Annotations(entgql.Annotation{
				RelayConnection: true,
				Skip:            entgql.SkipMutationCreateInput,
			}).Annotations(entsql.Annotation{
			OnDelete: entsql.Cascade,
		}),
	}
}
@gopherbot gopherbot added this to the Unreleased milestone Jul 13, 2023
@fzipp
Copy link
Contributor

fzipp commented Jul 13, 2023

The playground is correct since gofmt does it the same.

@cherrymui cherrymui changed the title x/playground: last call in fluent API call chain not indented correctly cmd/gofmt: last call in fluent API call chain not indented correctly Jul 13, 2023
@cherrymui
Copy link
Member

As @fzipp pointed out, the playground correctly provides the result of gofmt. That said, that indentation indeed looks a bit weird to me.

cc @griesemer @mvdan

@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 13, 2023
@cherrymui cherrymui modified the milestones: Unreleased, Backlog Jul 13, 2023
@fzipp
Copy link
Contributor

fzipp commented Jul 13, 2023

To make it look more regular to the human eye when formatted, you can add a line break after the dot: https://go.dev/play/p/YuCrLRRSr3p

func (ChannelReview) Edges() []ent.Edge {
	return []ent.Edge{
		edge.From("channel", Channel.Type).
			Unique().
			Required().
			Immutable().
			Ref("reviews").
			Field("channel_id").
			Annotations(entgql.Annotation{
				Skip: entgql.SkipType,
			}),
		edge.To("channel_local_reviews", ChannelLocalReview.Type).
			Annotations(entgql.Annotation{
				RelayConnection: true,
				Skip:            entgql.SkipMutationCreateInput,
			}).
			Annotations(entsql.Annotation{
				OnDelete: entsql.Cascade,
			}),
	}
}

@willfaught
Copy link
Contributor Author

willfaught commented Jul 13, 2023

Yep, I knew that, but as @cherrymui said, it looks wrong when you don't do that.

@seankhliao
Copy link
Member

Duplicate of #41889

@seankhliao seankhliao marked this as a duplicate of #41889 Jul 14, 2023
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants