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

Generated code in ent/gql_collection.go in *Query.collectField methods doesn't pass staticcheck #3996

Open
2 tasks done
willfaught opened this issue Apr 2, 2024 · 0 comments

Comments

@willfaught
Copy link
Contributor

In my project, staticcheck -tests ./... results in 90 such failures:

ent/gql_collection.go:228:2: this value of path is never used (SA4006)
ent/gql_collection.go:228:9: this result of append is never used, except maybe in other appends (SA4010)
ent/gql_collection.go:892:2: this value of path is never used (SA4006)
ent/gql_collection.go:892:9: this result of append is never used, except maybe in other appends (SA4010)
ent/gql_collection.go:1655:2: this value of path is never used (SA4006)
ent/gql_collection.go:1655:9: this result of append is never used, except maybe in other appends (SA4010)
ent/gql_collection.go:1769:2: this value of path is never used (SA4006)
ent/gql_collection.go:1769:9: this result of append is never used, except maybe in other appends (SA4010)
ent/gql_collection.go:1893:2: this value of path is never used (SA4006)
ent/gql_collection.go:1893:9: this result of append is never used, except maybe in other appends (SA4010)
ent/gql_collection.go:2037:2: this value of path is never used (SA4006)
ent/gql_collection.go:2037:9: this result of append is never used, except maybe in other appends (SA4010)
[snip]

These look like:

func (ai *AppInfoQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error {
	path = append([]string(nil), path...)
// snip

In my go.mod:

module foo

go 1.21

require (
	entgo.io/ent v0.13.1
// snip
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

*Query.collectField methods all start with a useless statement:

path = append([]string(nil), path...)

Also, their first parameter, ctx, is unused.

Also, *Query.load* parameter init is unused.

Also, *Query.sqlQuery parameter ctx is unused.

Expected Behavior 🤔

Generated code passes staticcheck, and doesn't have unused parameters.

Steps to Reproduce 🕹

Steps:

  1. Generate a gql_collection.go.

Your Environment 🌎

Tech Version
Go go version go1.22.1 darwin/arm64
Ent 0.13.1
Database PostgresQL
Driver github.com/lib/pq
staticcheck staticcheck 2023.1.6 (v0.4.6)
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

No branches or pull requests

1 participant