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

Remove statically analyzable dead-code #1719

Open
jzelinskie opened this issue Jan 23, 2024 · 4 comments
Open

Remove statically analyzable dead-code #1719

jzelinskie opened this issue Jan 23, 2024 · 4 comments
Labels
area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) good first issue hint/good first issue Someone new could handle this kind/tech debt Addresses legacy code/decisions priority/3 low This would be nice to have

Comments

@jzelinskie
Copy link
Member

What platforms are affected?

linux, macos, windows, others

What architectures are affected?

amd64, arm64, others

What SpiceDB version are you using?

main

Steps to Reproduce

  1. go install golang.org/x/tools/cmd/deadcode@latest
  2. deadcode -test ./...

Expected Result

No output

Actual Result

internal/datasets/subjectset.go:39:22: unreachable func: SubjectSet.UnionWithSet
internal/datasets/subjectsetbytype.go:86:28: unreachable func: SubjectByTypeSet.Len
internal/datastore/common/jitter.go:12:6: unreachable func: WithJitter
internal/datastore/mysql/options.go:204:6: unreachable func: DebugAnalyzeBeforeStatistics
internal/datastore/postgres/options.go:315:6: unreachable func: DebugAnalyzeBeforeStatistics
internal/datastore/postgres/options.go:322:6: unreachable func: WithQueryInterceptor
internal/developmentmembership/trackingsubjectset.go:59:32: unreachable func: TrackingSubjectSet.RemoveFrom
internal/dispatch/combined/combined.go:119:6: unreachable func: RemoteDispatchTimeout
internal/graph/errors.go:59:6: unreachable func: NewAlwaysFailErr
internal/graph/errors.go:73:32: unreachable func: ErrRelationNotFound.NamespaceName
internal/graph/errors.go:78:32: unreachable func: ErrRelationNotFound.NotFoundRelationName
internal/graph/errors.go:82:32: unreachable func: ErrRelationNotFound.MarshalZerologObject
internal/graph/errors.go:87:32: unreachable func: ErrRelationNotFound.DetailsMetadata
internal/graph/errors.go:95:6: unreachable func: NewRelationNotFoundErr
internal/graph/errors.go:136:6: unreachable func: NewRelationMissingTypeInfoErr
internal/graph/errors.go:166:6: unreachable func: NewUnimplementedErr
internal/graph/graph.go:51:6: unreachable func: AlwaysFailExpand
internal/logging/logger.go:39:6: unreachable func: Log
internal/logging/logger.go:43:6: unreachable func: Print
internal/logging/logger.go:47:6: unreachable func: Printf
internal/middleware/dispatcher/dispatcher.go:28:6: unreachable func: FromContext
internal/middleware/dispatcher/dispatcher.go:38:6: unreachable func: MustFromContext
internal/services/shared/errors.go:109:6: unreachable func: AsValidationError
internal/services/shared/interceptor.go:16:50: unreachable func: WithUnaryServiceSpecificInterceptor.UnaryInterceptor
internal/services/v0/developer.go:26:6: unreachable func: RegisterDeveloperServer
internal/testfixtures/generator.go:18:6: unreachable func: RandomObjectID
pkg/caveats/types/types.go:48:6: unreachable func: TypeKeywords
pkg/cmd/server/middleware.go:280:41: unreachable func: StreamOrderEnforcerBuilder.EnsureWrapperNotExecuted
pkg/cmd/server/middleware.go:290:41: unreachable func: StreamOrderEnforcerBuilder.EnsureInterceptorNotExecuted
pkg/cmd/server/middleware.go:371:40: unreachable func: UnaryOrderEnforcerBuilder.EnsureNotExecuted
pkg/datastore/relationshipquerytree.go:17:6: unreachable func: NewRelationshipQueryTree
pkg/datastore/revisionparsing/revisionparsing.go:27:6: unreachable func: MustParseRevisionForTest
pkg/datastore/test/datastore.go:32:30: unreachable func: DatastoreTesterFunc.New
pkg/datastore/test/datastore.go:154:6: unreachable func: All
pkg/development/devcontext.go:168:23: unreachable func: DevContext.Dispose
pkg/genutil/slicez/slicez.go:4:6: unreachable func: Concat
pkg/middleware/datastore/datastore.go:12:6: unreachable func: FromContext
pkg/middleware/datastore/datastore.go:18:6: unreachable func: MustFromContext
pkg/middleware/dispatcher/dispatcher.go:12:6: unreachable func: FromContext
pkg/middleware/dispatcher/dispatcher.go:18:6: unreachable func: MustFromContext
pkg/middleware/requestid/requestid.go:37:6: unreachable func: WithIDGenerator
pkg/middleware/requestid/requestid.go:50:6: unreachable func: GetOrGenerateRequestID
pkg/middleware/usagemetrics/usagemetrics.go:11:6: unreachable func: FromContext
pkg/proto/core/v1/util.go:8:6: unreachable func: ToCoreRelationTuple
pkg/proto/core/v1/util.go:16:6: unreachable func: ToCoreRelationTuples
pkg/proto/core/v1/util.go:25:6: unreachable func: ToCoreObjectAndRelation
pkg/proto/core/v1/util.go:34:6: unreachable func: ToCoreRelationReference
pkg/proto/core/v1/util.go:42:6: unreachable func: ToV0RelationTuple
pkg/proto/core/v1/util.go:62:6: unreachable func: ToV0RelationTuples
pkg/releases/releases.go:17:6: unreachable func: GetSourceRepository
pkg/schemadsl/compiler/compiler.go:55:6: unreachable func: RequirePrefixedObjectType
pkg/schemadsl/input/sourcepositionmapper.go:21:6: unreachable func: EmptySourcePositionMapper
pkg/schemadsl/lexer/lex_def.go:84:6: unreachable func: IsKeyword
pkg/schemautil/schemautil.go:15:6: unreachable func: ValidateSchemaChanges
pkg/schemautil/schemautil.go:22:6: unreachable func: ApplySchemaChanges
pkg/spiceerrors/bug.go:23:6: unreachable func: MustPanic
pkg/spiceerrors/termination.go:51:25: unreachable func: ErrorBuilder.Timestamp
pkg/tuple/tuple.go:444:6: unreachable func: MustFromRelationships
pkg/typesystem/errors.go:201:32: unreachable func: ErrPermissionsCycle.MarshalZerologObject
pkg/typesystem/errors.go:206:32: unreachable func: ErrPermissionsCycle.DetailsMetadata
pkg/typesystem/errors.go:243:37: unreachable func: ErrUnusedCaveatParameter.MarshalZerologObject
pkg/typesystem/errors.go:248:37: unreachable func: ErrUnusedCaveatParameter.DetailsMetadata
pkg/typesystem/errors.go:338:6: unreachable func: NewPermissionsCycleErr
pkg/typesystem/errors.go:347:6: unreachable func: NewUnusedCaveatParameterErr
pkg/typesystem/reachabilitygraph.go:126:30: unreachable func: ReachabilityGraph.RelationsEncountered
pkg/typesystem/resolver.go:55:6: unreachable func: ResolverForSchema
@jzelinskie jzelinskie added hint/good first issue Someone new could handle this priority/3 low This would be nice to have area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) kind/tech debt Addresses legacy code/decisions labels Jan 23, 2024
@Linkinlog
Copy link

I think I can help, could I be assigned to this?

@jzelinskie
Copy link
Member Author

There are a few instances here that are actually being used by external projects.
Let one of the maintainers filter down the list and then you can absolutely help out!

@jzelinskie
Copy link
Member Author

cc @ecordell @vroldanbet

@vroldanbet
Copy link
Contributor

@jzelinskie I think the best course of action here would be to open a PR with the fix, and then gather the list that breaks our internal usages, and fix the PR.

I also noticed the linter identifies code that is only used on tests as dead code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) good first issue hint/good first issue Someone new could handle this kind/tech debt Addresses legacy code/decisions priority/3 low This would be nice to have
Projects
None yet
Development

No branches or pull requests

4 participants