Skip to content

Commit 806ecc0

Browse files
authored
chore: clean up all unused parameters (#2931)
1 parent c3b75c9 commit 806ecc0

File tree

14 files changed

+68
-69
lines changed

14 files changed

+68
-69
lines changed

.golangci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ linters:
4040
- "tagalign"
4141
- "testifylint"
4242
- "tparallel"
43+
- "unparam"
4344
- "unconvert"
4445
- "usetesting"
4546
- "wastedassign"
@@ -95,6 +96,9 @@ linters:
9596
- linters:
9697
- "perfsprint"
9798
path: '(.+)_test\.go'
99+
- linters:
100+
- "unparam"
101+
text: "result .* is always|result .* is never used|always receives"
98102
paths:
99103
- "third_party$"
100104
- "builtin$"

internal/caveats/run.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ func (cr *CaveatRunner) RunCaveatExpression(
8282
return nil, err
8383
}
8484

85-
env := caveats.NewEnvironmentWithTypeSet(cr.caveatTypeSet)
86-
return cr.runExpressionWithCaveats(ctx, env, expr, context, debugOption)
85+
return cr.runExpressionWithCaveats(ctx, expr, context, debugOption)
8786
}
8887

8988
// PopulateCaveatDefinitionsForExpr populates the CaveatRunner's cache with the definitions
@@ -167,7 +166,6 @@ func collectCaveatNames(expr *core.CaveatExpression, caveatNames *mapz.Set[strin
167166

168167
func (cr *CaveatRunner) runExpressionWithCaveats(
169168
ctx context.Context,
170-
env *caveats.Environment,
171169
expr *core.CaveatExpression,
172170
context map[string]any,
173171
debugOption RunCaveatExpressionDebugOption,
@@ -320,7 +318,7 @@ func (cr *CaveatRunner) runExpressionWithCaveats(
320318
}
321319

322320
for _, child := range cop.Children {
323-
childResult, err := cr.runExpressionWithCaveats(ctx, env, child, context, debugOption)
321+
childResult, err := cr.runExpressionWithCaveats(ctx, child, context, debugOption)
324322
if err != nil {
325323
return nil, err
326324
}

internal/dispatch/caching/cachingdispatch_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ func TestConcurrentDebugInfoAccess(t *testing.T) {
184184
errors := make(chan error, numGoroutines)
185185

186186
var wg sync.WaitGroup
187-
for i := range numGoroutines {
187+
for range numGoroutines {
188188
wg.Add(1)
189-
go func(goroutineID int) {
189+
go func() {
190190
defer wg.Done()
191191

192192
request := &v1.DispatchCheckRequest{
@@ -211,7 +211,7 @@ func TestConcurrentDebugInfoAccess(t *testing.T) {
211211
// we mutate the response to prove that it's not shared across goroutines
212212
resp.GetMetadata().GetDebugInfo().GetCheck().GetRequest().Subject.Relation = "modified"
213213
resp.GetMetadata().GetDebugInfo().GetCheck().GetRequest().ResourceIds = []string{"modified"}
214-
}(i)
214+
}()
215215
}
216216

217217
wg.Wait()

internal/dispatch/graph/check_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,7 @@ func TestCheckHintsPartialApplicationOverArrow(t *testing.T) {
20722072
require.Equal(v1.ResourceCheckResult_MEMBER, resp.ResultsByResourceId["anotherdoc"].Membership)
20732073
}
20742074

2075-
func newLocalDispatcherWithConcurrencyLimit(t testing.TB, concurrencyLimit uint16) (context.Context, dispatch.Dispatcher, datastore.Revision) {
2075+
func newLocalDispatcher(t testing.TB) (context.Context, dispatch.Dispatcher, datastore.Revision) {
20762076
rawDS, err := dsfortesting.NewMemDBDatastoreForTesting(t, 0, 0, memdb.DisableGC)
20772077
require.NoError(t, err)
20782078

@@ -2097,10 +2097,6 @@ func newLocalDispatcherWithConcurrencyLimit(t testing.TB, concurrencyLimit uint1
20972097
return ctx, cachingDispatcher, revision
20982098
}
20992099

2100-
func newLocalDispatcher(t testing.TB) (context.Context, dispatch.Dispatcher, datastore.Revision) {
2101-
return newLocalDispatcherWithConcurrencyLimit(t, 10)
2102-
}
2103-
21042100
func newLocalDispatcherWithSchemaAndRels(t testing.TB, schema string, rels []tuple.Relationship) (context.Context, dispatch.Dispatcher, datastore.Revision) {
21052101
rawDS, err := dsfortesting.NewMemDBDatastoreForTesting(t, 0, 0, memdb.DisableGC)
21062102
require.NoError(t, err)

internal/dispatch/remote/primarysleeper_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,14 @@ func TestPrimarySleeper_SleepConcurrently(t *testing.T) {
260260

261261
synctest.Test(t, func(t *testing.T) {
262262
ctx := t.Context()
263-
for i := range 3 {
263+
for range 3 {
264264
wg.Add(1)
265-
go func(idx int) {
265+
go func() {
266266
defer wg.Done()
267267
start := time.Now()
268268
sleeper.sleep(ctx)
269269
results <- time.Since(start)
270-
}(i)
270+
}()
271271
}
272272

273273
wg.Wait()

internal/graph/check.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ func checkIntersectionTupleToUserset(
882882
}
883883

884884
resultsByDispatchedSubject[result.relationType].UnionWith(result.Resp.ResultsByResourceId)
885-
combinedMetadata = combineResponseMetadata(ctx, combinedMetadata, result.Resp.Metadata)
885+
combinedMetadata = combineResponseMetadata(combinedMetadata, result.Resp.Metadata)
886886
}
887887

888888
// For each resource ID, check that there exist some sort of permission for *each* subject. If not, then the
@@ -1022,11 +1022,11 @@ func checkTupleToUserset[T relation](
10221022
), hintsToReturn)
10231023
}
10241024

1025-
func withDistinctMetadata(ctx context.Context, result CheckResult) CheckResult {
1025+
func withDistinctMetadata(result CheckResult) CheckResult {
10261026
// NOTE: This is necessary to ensure unique debug information on the request and that debug
10271027
// information from the child metadata is *not* copied over.
10281028
clonedResp := result.Resp.CloneVT()
1029-
clonedResp.Metadata = combineResponseMetadata(ctx, emptyMetadata, clonedResp.Metadata)
1029+
clonedResp.Metadata = combineResponseMetadata(emptyMetadata, clonedResp.Metadata)
10301030
return CheckResult{
10311031
Resp: clonedResp,
10321032
Err: result.Err,
@@ -1082,7 +1082,7 @@ func union[T any](
10821082
}
10831083

10841084
if len(children) == 1 {
1085-
return withDistinctMetadata(ctx, handler(ctx, crc, children[0]))
1085+
return withDistinctMetadata(handler(ctx, crc, children[0]))
10861086
}
10871087

10881088
resultChan := make(chan CheckResult, len(children))
@@ -1097,7 +1097,7 @@ func union[T any](
10971097
select {
10981098
case result := <-resultChan:
10991099
log.Ctx(ctx).Trace().Object("anyResult", result.Resp).Send()
1100-
responseMetadata = combineResponseMetadata(ctx, responseMetadata, result.Resp.Metadata)
1100+
responseMetadata = combineResponseMetadata(responseMetadata, result.Resp.Metadata)
11011101
if result.Err != nil {
11021102
return checkResultError(result.Err, responseMetadata)
11031103
}
@@ -1129,7 +1129,7 @@ func all[T any](
11291129
}
11301130

11311131
if len(children) == 1 {
1132-
return withDistinctMetadata(ctx, handler(ctx, crc, children[0]))
1132+
return withDistinctMetadata(handler(ctx, crc, children[0]))
11331133
}
11341134

11351135
responseMetadata := emptyMetadata
@@ -1148,7 +1148,7 @@ func all[T any](
11481148
for range children {
11491149
select {
11501150
case result := <-resultChan:
1151-
responseMetadata = combineResponseMetadata(ctx, responseMetadata, result.Resp.Metadata)
1151+
responseMetadata = combineResponseMetadata(responseMetadata, result.Resp.Metadata)
11521152
if result.Err != nil {
11531153
return checkResultError(result.Err, responseMetadata)
11541154
}
@@ -1215,7 +1215,7 @@ func difference[T any](
12151215
// Wait for the base set to return.
12161216
select {
12171217
case base := <-baseChan:
1218-
responseMetadata = combineResponseMetadata(ctx, responseMetadata, base.Resp.Metadata)
1218+
responseMetadata = combineResponseMetadata(responseMetadata, base.Resp.Metadata)
12191219

12201220
if base.Err != nil {
12211221
return checkResultError(base.Err, responseMetadata)
@@ -1234,7 +1234,7 @@ func difference[T any](
12341234
for i := 1; i < len(children); i++ {
12351235
select {
12361236
case sub := <-othersChan:
1237-
responseMetadata = combineResponseMetadata(ctx, responseMetadata, sub.Resp.Metadata)
1237+
responseMetadata = combineResponseMetadata(responseMetadata, sub.Resp.Metadata)
12381238

12391239
if sub.Err != nil {
12401240
return checkResultError(sub.Err, responseMetadata)
@@ -1333,7 +1333,7 @@ func combineResultWithFoundResources(result CheckResult, foundResources *Members
13331333
}
13341334
}
13351335

1336-
func combineResponseMetadata(ctx context.Context, existing *v1.ResponseMeta, responseMetadata *v1.ResponseMeta) *v1.ResponseMeta {
1336+
func combineResponseMetadata(existing *v1.ResponseMeta, responseMetadata *v1.ResponseMeta) *v1.ResponseMeta {
13371337
combined := &v1.ResponseMeta{
13381338
DispatchCount: existing.DispatchCount + responseMetadata.DispatchCount,
13391339
DepthRequired: max(existing.DepthRequired, responseMetadata.DepthRequired),

internal/graph/expand.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func expandSetOperation(
353353
for _, resultChan := range resultChans {
354354
select {
355355
case result := <-resultChan:
356-
responseMetadata = combineResponseMetadata(ctx, responseMetadata, result.Resp.Metadata)
356+
responseMetadata = combineResponseMetadata(responseMetadata, result.Resp.Metadata)
357357
if result.Err != nil {
358358
return expandResultError(result.Err, responseMetadata)
359359
}

internal/graph/lookupsubjects.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ func (cl *ConcurrentLookupSubjects) lookupViaComputed(
195195
ctx context.Context,
196196
parentRequest ValidatedLookupSubjectsRequest,
197197
parentStream dispatch.LookupSubjectsStream,
198-
ts *schema.TypeSystem,
199198
cu *core.ComputedUserset,
200199
) error {
201200
dl := datalayer.MustFromContext(ctx).SnapshotReader(parentRequest.Revision)
@@ -368,7 +367,7 @@ func lookupViaIntersectionTupleToUserset(
368367
results := datasets.NewSubjectSet()
369368
collectedMetadata := emptyMetadata
370369
for _, result := range collectingStream.Results() {
371-
collectedMetadata = combineResponseMetadata(ctx, collectedMetadata, result.Metadata)
370+
collectedMetadata = combineResponseMetadata(collectedMetadata, result.Metadata)
372371
for _, foundSubjects := range result.FoundSubjectsByResourceId {
373372
if err := results.UnionWith(foundSubjects.FoundSubjects); err != nil {
374373
return fmt.Errorf("failed to UnionWith under lookupSubjectsIntersection: %w", err)
@@ -379,7 +378,7 @@ func lookupViaIntersectionTupleToUserset(
379378
dispatchInfoForResource.lock.Lock()
380379
defer dispatchInfoForResource.lock.Unlock()
381380

382-
dispatchInfoForResource.metadata = combineResponseMetadata(ctx, dispatchInfoForResource.metadata, collectedMetadata)
381+
dispatchInfoForResource.metadata = combineResponseMetadata(dispatchInfoForResource.metadata, collectedMetadata)
383382

384383
// If the first update for the resource, set the subjects set to the results.
385384
if dispatchInfoForResource.isFirstUpdate {
@@ -417,7 +416,7 @@ func lookupViaIntersectionTupleToUserset(
417416
currentSubjects = currentSubjects.WithParentCaveatExpression(ttuCaveat)
418417
currentSubjectsByResourceID[incomingResourceID] = currentSubjects.AsFoundSubjects()
419418

420-
metadata = combineResponseMetadata(ctx, metadata, tracker.metadata)
419+
metadata = combineResponseMetadata(metadata, tracker.metadata)
421420
}
422421

423422
return parentStream.Publish(&v1.DispatchLookupSubjectsResponse{
@@ -538,7 +537,7 @@ func (cl *ConcurrentLookupSubjects) lookupSetOperation(
538537

539538
case *core.SetOperation_Child_ComputedUserset:
540539
g.Go(func() error {
541-
return cl.lookupViaComputed(subCtx, req, stream, ts, child.ComputedUserset)
540+
return cl.lookupViaComputed(subCtx, req, stream, child.ComputedUserset)
542541
})
543542

544543
case *core.SetOperation_Child_UsersetRewrite:
@@ -763,7 +762,7 @@ func (lsu *lookupSubjectsUnion) CompletedChildOperations(ctx context.Context) er
763762
}
764763

765764
for _, result := range collector.Results() {
766-
metadata = combineResponseMetadata(ctx, metadata, result.Metadata)
765+
metadata = combineResponseMetadata(metadata, result.Metadata)
767766
if err := foundSubjects.UnionWith(result.FoundSubjectsByResourceId); err != nil {
768767
return fmt.Errorf("failed to UnionWith under lookupSubjectsUnion: %w", err)
769768
}
@@ -811,7 +810,7 @@ func (lsi *lookupSubjectsIntersection) CompletedChildOperations(ctx context.Cont
811810

812811
results := datasets.NewSubjectSetByResourceID()
813812
for _, result := range collector.Results() {
814-
metadata = combineResponseMetadata(ctx, metadata, result.Metadata)
813+
metadata = combineResponseMetadata(metadata, result.Metadata)
815814
if err := results.UnionWith(result.FoundSubjectsByResourceId); err != nil {
816815
return fmt.Errorf("failed to UnionWith under lookupSubjectsIntersection: %w", err)
817816
}
@@ -864,7 +863,7 @@ func (lse *lookupSubjectsExclusion) CompletedChildOperations(ctx context.Context
864863
collector := lse.collectors[index]
865864
results := datasets.NewSubjectSetByResourceID()
866865
for _, result := range collector.Results() {
867-
metadata = combineResponseMetadata(ctx, metadata, result.Metadata)
866+
metadata = combineResponseMetadata(metadata, result.Metadata)
868867
if err := results.UnionWith(result.FoundSubjectsByResourceId); err != nil {
869868
return fmt.Errorf("failed to UnionWith under lookupSubjectsExclusion: %w", err)
870869
}

internal/graph/lr2streams.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func (rdc *checkAndDispatchRunner) runDispatch(
227227
return err
228228
}
229229

230-
if err := publishResultToParentStream(ctx, result, rdc.ci, responsePartialCursor, adjustedResources, nil, isFirstPublishCall, checkMetadata, rdc.parentStream); err != nil {
230+
if err := publishResultToParentStream(result, rdc.ci, responsePartialCursor, adjustedResources, nil, isFirstPublishCall, checkMetadata, rdc.parentStream); err != nil {
231231
return err
232232
}
233233
isFirstPublishCall = false
@@ -268,7 +268,7 @@ func unfilteredLookupResourcesDispatchStreamForEntrypoint(
268268
default:
269269
}
270270

271-
if err := publishResultToParentStream(ctx, result, ci, ci.responsePartialCursor(), foundResources, nil, isFirstPublishCall, emptyMetadata, parentStream); err != nil {
271+
if err := publishResultToParentStream(result, ci, ci.responsePartialCursor(), foundResources, nil, isFirstPublishCall, emptyMetadata, parentStream); err != nil {
272272
return err
273273
}
274274
isFirstPublishCall = false
@@ -281,7 +281,6 @@ func unfilteredLookupResourcesDispatchStreamForEntrypoint(
281281
// publishResultToParentStream publishes the result of a lookup resources call to the parent stream,
282282
// mapped via foundResources.
283283
func publishResultToParentStream(
284-
ctx context.Context,
285284
result *v1.DispatchLookupResources2Response,
286285
ci cursorInformation,
287286
responseCursor *v1.Cursor,
@@ -314,7 +313,7 @@ func publishResultToParentStream(
314313
metadata := result.Metadata
315314
if isFirstPublishCall {
316315
metadata = addCallToResponseMetadata(metadata)
317-
metadata = combineResponseMetadata(ctx, metadata, additionalMetadata)
316+
metadata = combineResponseMetadata(metadata, additionalMetadata)
318317
} else {
319318
metadata = addAdditionalDepthRequired(metadata)
320319
}

pkg/datalayer/impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (t *readWriteTransaction) BulkLoad(ctx context.Context, iter datastore.Bulk
143143
}
144144

145145
func (t *readWriteTransaction) WriteSchema(ctx context.Context, definitions []datastore.SchemaDefinition, schemaString string, caveatTypeSet *caveattypes.TypeSet) error {
146-
return writeSchemaViaLegacy(ctx, t.rwt, t.rwt, definitions, schemaString, caveatTypeSet)
146+
return writeSchemaViaLegacy(ctx, t.rwt, t.rwt, definitions)
147147
}
148148

149149
func (t *readWriteTransaction) LegacySchemaWriter() LegacySchemaWriter {

0 commit comments

Comments
 (0)