25 msformat207 mscheck 210total 29errors 82warnings 99notes

iter/export_test.go2

3:5exported-declaration-commentexported declaration should have a comment beginning with its name

iter/export_test.go:3:5

2
3var DefaultMaxGoroutines = defaultMaxGoroutines
4
3:5no-package-varpackage variables introduce mutable global state

iter/export_test.go:3:5

2
3var DefaultMaxGoroutines = defaultMaxGoroutines
4

iter/iter.go9

1:1formatfile is not formatted

iter/iter.go:1:1

1package iter
2
  • Fix (safe): run `strider fmt iter/iter.go`
1:9package-commentspackage should have a documentation comment

iter/iter.go:1:9

1package iter
2
19:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

iter/iter.go:19:1

18// Iterator is also safe for reuse and concurrent use.
19type Iterator[T any] struct {
20 // MaxGoroutines controls the maximum number of goroutines
36:6exported-declaration-commentexported function or method should have a comment beginning with its name

iter/iter.go:36:6

35// a configurable goroutine limit, use a custom Iterator.
36func ForEach[T any](input []T, f func(*T)) { Iterator[T]{}.ForEach(input, f) }
37
47:25exported-declaration-commentexported function or method should have a comment beginning with its name

iter/iter.go:47:25

46// an overhead of roughly 50ns per element of input.
47func (iter Iterator[T]) ForEach(input []T, f func(*T)) {
48 iter.ForEachIdx(input, func(_ int, t *T) {
55:6exported-declaration-commentexported function or method should have a comment beginning with its name

iter/iter.go:55:6

54// index of the element to the callback.
55func ForEachIdx[T any](input []T, f func(int, *T)) { Iterator[T]{}.ForEachIdx(input, f) }
56
59:25exported-declaration-commentexported function or method should have a comment beginning with its name

iter/iter.go:59:25

58// index of the element to the callback.
59func (iter Iterator[T]) ForEachIdx(input []T, f func(int, *T)) {
60 if iter.MaxGoroutines == 0 {
62:3modifies-value-receiverassignment modifies value receiver iter

iter/iter.go:62:3

61 // iter is a value receiver and is hence safe to mutate
62 iter.MaxGoroutines = defaultMaxGoroutines()
63 }
68:3modifies-value-receiverassignment modifies value receiver iter

iter/iter.go:68:3

67 // No more concurrent tasks than the number of input items.
68 iter.MaxGoroutines = numInput
69 }

iter/iter_test.go4

1:1formatfile is not formatted

iter/iter_test.go:1:1

1package iter_test
2
  • Fix (safe): run `strider fmt iter/iter_test.go`
26:2discarded-error-resulterror result returned by fmt.Println is discarded

iter/iter_test.go:26:2

25
26 fmt.Println(input)
27 // Output:
50:34nested-structsmove nested anonymous struct types to named declarations

iter/iter_test.go:50:34

49
50 maxConcurrencyHit := make(chan struct{})
51
173:30range-value-captureclosure captures reused range variable count

iter/iter_test.go:173:30

172 for _, count := range []int{0, 1, 8, 100, 1000, 10000, 100000} {
173 b.Run(strconv.Itoa(count), func(b *testing.B) {
174 ints := make([]int, count)

iter/map.go4

1:9package-commentspackage should have a documentation comment

iter/map.go:1:9

1package iter
2
19:6exported-declaration-commentexported function or method should have a comment beginning with its name

iter/map.go:19:6

18// goroutine limit, use a custom Mapper.
19func Map[T, R any](input []T, f func(*T) R) []R {
20 return Mapper[T, R]{}.Map(input, f)
39:6exported-declaration-commentexported function or method should have a comment beginning with its name

iter/map.go:39:6

38// goroutine limit, use a custom Mapper.
39func MapErr[T, R any](input []T, f func(*T) (R, error)) ([]R, error) {
40 return Mapper[T, R]{}.MapErr(input, f)
47:23exported-declaration-commentexported function or method should have a comment beginning with its name

iter/map.go:47:23

46// Map uses up to the configured Mapper's maximum number of goroutines.
47func (m Mapper[T, R]) MapErr(input []T, f func(*T) (R, error)) ([]R, error) {
48 var (

iter/map_test.go5

1:1formatfile is not formatted

iter/map_test.go:1:1

1package iter_test
2
  • Fix (safe): run `strider fmt iter/map_test.go`
20:2discarded-error-resulterror result returned by fmt.Println is discarded

iter/map_test.go:20:2

19 results := mapper.Map(input, func(v *int) bool { return *v%2 == 0 })
20 fmt.Println(results)
21 // Output:
84:6function-lengthfunction has 69 statements and 99 lines; maximum is 50 statements or 75 lines

iter/map_test.go:84:6

83
84func TestMapErr(t *testing.T) {
85 t.Parallel()
104:11discarded-error-resulterror result returned by iter.MapErr is discarded

iter/map_test.go:104:11

103 ints := []int{1}
104 _, _ = iter.MapErr(ints, func(val *int) (int, error) {
105 panic("super bad thing happened")
165:31unchecked-type-assertionuse the checked two-result form of the type assertion

iter/map_test.go:165:31

164 require.ErrorIs(t, err, err2)
165 require.ElementsMatch(t, err.(interface{ Unwrap() []error }).Unwrap(), []error{err1, err2})
166 require.Equal(t, []int{2, 3, 0, 0, 6}, res)

panics/panics.go10

1:1formatfile is not formatted

panics/panics.go:1:1

1package panics
2
  • Fix (safe): run `strider fmt panics/panics.go`
1:9package-commentspackage should have a documentation comment

panics/panics.go:1:9

1package panics
2
15:6exported-declaration-commentexported type should have a comment beginning with its name

panics/panics.go:15:6

14// propagate the panic (re-panic) with Repanic().
15type Catcher struct {
16 recovered atomic.Pointer[Recovered]
21:19exported-declaration-commentexported function or method should have a comment beginning with its name

panics/panics.go:21:19

20// to call from multiple goroutines simultaneously.
21func (p *Catcher) Try(f func()) {
22 defer p.tryRecover()
36:19exported-declaration-commentexported function or method should have a comment beginning with its name

panics/panics.go:36:19

35// information.
36func (p *Catcher) Repanic() {
37 if val := p.Recovered(); val != nil {
44:19exported-declaration-commentexported function or method should have a comment beginning with its name

panics/panics.go:44:19

43// no calls to Try panicked.
44func (p *Catcher) Recovered() *Recovered {
45 return p.recovered.Load()
64:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

panics/panics.go:64:1

63// Recovered is a panic that was caught with recover().
64type Recovered struct {
65 // The original value of the panic.
83:21exported-declaration-commentexported function or method should have a comment beginning with its name

panics/panics.go:83:21

82// is unwrappable with the cause of the panic, if the panic was provided one.
83func (p *Recovered) AsError() error {
84 if p == nil {
91:6error-type-namingerror implementation type should have an Error suffix

panics/panics.go:91:6

90// ErrRecovered wraps a panics.Recovered in an error implementation.
91type ErrRecovered struct{ Recovered }
92
93:5error-namingpackage error variable should be named errFoo or ErrFoo

panics/panics.go:93:5

92
93var _ error = (*ErrRecovered)(nil)
94

panics/panics_test.go9

1:1formatfile is not formatted

panics/panics_test.go:1:1

1package panics_test
2
  • Fix (safe): run `strider fmt panics/panics_test.go`
25:2discarded-error-resulterror result returned by fmt.Println is discarded

panics/panics_test.go:25:2

24
25 fmt.Println(i)
26 fmt.Println(rc.Value.(string))
26:2discarded-error-resulterror result returned by fmt.Println is discarded

panics/panics_test.go:26:2

25 fmt.Println(i)
26 fmt.Println(rc.Value.(string))
27 // Output:
26:22unchecked-type-assertionuse the checked two-result form of the type assertion

panics/panics_test.go:26:22

25 fmt.Println(i)
26 fmt.Println(rc.Value.(string))
27 // Output:
46:3discarded-error-resulterror result returned by fmt.Println is discarded

panics/panics_test.go:46:3

45
46 fmt.Println(frame.Function)
47
79:4discarded-error-resulterror result returned by fmt.Printf is discarded

panics/panics_test.go:79:4

78 if cause := errors.Unwrap(err); cause != nil {
79 fmt.Printf("helper panicked with an error: %s", cause)
80 }
89:21error-stringserror string should not be capitalized or end with punctuation

panics/panics_test.go:89:21

88
89 err1 := errors.New("SOS")
90
105:21test-parallelismconsider calling t.Parallel() when this subtest begins

panics/panics_test.go:105:21

104
105 t.Run("not error", func(t *testing.T) {
106 var pc panics.Catcher
113:26test-parallelismconsider calling t.Parallel() when this subtest begins

panics/panics_test.go:113:26

112
113 t.Run("repanic panics", func(t *testing.T) {
114 var pc panics.Catcher

panics/try.go2

1:9package-commentspackage should have a documentation comment

panics/try.go:1:9

1package panics
2
7:6exported-declaration-commentexported function or method should have a comment beginning with its name

panics/try.go:7:6

6// (*panics.Recovered).AsError().
7func Try(f func()) *Recovered {
8 var c Catcher

panics/try_test.go2

1:1formatfile is not formatted

panics/try_test.go:1:1

1package panics_test
2
  • Fix (safe): run `strider fmt panics/try_test.go`
18:21error-stringserror string should not be capitalized or end with punctuation

panics/try_test.go:18:21

17
18 err := errors.New("SOS")
19 recovered := panics.Try(func() { panic(err) })

pool/context_pool.go11

1:1formatfile is not formatted

pool/context_pool.go:1:1

1package pool
2
  • Fix (safe): run `strider fmt pool/context_pool.go`
1:9package-commentspackage should have a documentation comment

pool/context_pool.go:1:9

1package pool
2
12:6exported-declaration-commentexported type should have a comment beginning with its name

pool/context_pool.go:12:6

11// Go() for the first time.
12type ContextPool struct {
13 errorPool ErrorPool
15:2context-stored-in-structdo not store context.Context in a struct; pass it explicitly to each operation

pool/context_pool.go:15:2

14
15 ctx context.Context
16 cancel context.CancelFunc
24:23exported-declaration-commentexported function or method should have a comment beginning with its name

pool/context_pool.go:24:23

23// are busy, a call to Go() will block until the task can be started.
24func (p *ContextPool) Go(f func(ctx context.Context) error) {
25 p.errorPool.Go(func() error {
39:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pool/context_pool.go:39:6

38 err := f(p.ctx)
39 if err != nil && p.cancelOnError {
40 // Leaky abstraction warning: We add the error directly because
54:23exported-declaration-commentexported function or method should have a comment beginning with its name

pool/context_pool.go:54:23

53// returns an error if any of the tasks errored.
54func (p *ContextPool) Wait() error {
55 // Make sure we call cancel after pool is done to avoid memory leakage.
64:23exported-declaration-commentexported function or method should have a comment beginning with its name

pool/context_pool.go:64:23

63// where all errors after the first are likely to be context.Canceled.
64func (p *ContextPool) WithFirstError() *ContextPool {
65 p.panicIfInitialized()
78:23exported-declaration-commentexported function or method should have a comment beginning with its name

pool/context_pool.go:78:23

77// the first error.
78func (p *ContextPool) WithCancelOnError() *ContextPool {
79 p.panicIfInitialized()
87:23exported-declaration-commentexported function or method should have a comment beginning with its name

pool/context_pool.go:87:23

86// the pool's context is not canceled until the parent context is canceled.
87func (p *ContextPool) WithFailFast() *ContextPool {
88 p.panicIfInitialized()
96:23exported-declaration-commentexported function or method should have a comment beginning with its name

pool/context_pool.go:96:23

95// Defaults to unlimited. Panics if n < 1.
96func (p *ContextPool) WithMaxGoroutines(n int) *ContextPool {
97 p.panicIfInitialized()

pool/context_pool_test.go11

1:1formatfile is not formatted

pool/context_pool_test.go:1:1

1package pool_test
2
  • Fix (safe): run `strider fmt pool/context_pool_test.go`
27:23error-stringserror string should not be capitalized or end with punctuation

pool/context_pool_test.go:27:23

26 if i == 2 {
27 return errors.New("I will cancel all other tasks!")
28 }
34:2discarded-error-resulterror result returned by fmt.Println is discarded

pool/context_pool_test.go:34:2

33 err := p.Wait()
34 fmt.Println(err)
35 // Output:
39:6cognitive-complexityfunction has cognitive complexity 8; maximum is 7

pool/context_pool_test.go:39:6

38
39func TestContextPool(t *testing.T) {
40 t.Parallel()
39:6function-lengthfunction has 157 statements and 216 lines; maximum is 50 statements or 75 lines

pool/context_pool_test.go:39:6

38
39func TestContextPool(t *testing.T) {
40 t.Parallel()
46:46test-parallelismconsider calling t.Parallel() when this subtest begins

pool/context_pool_test.go:46:46

45
46 t.Run("panics on configuration after init", func(t *testing.T) {
47 t.Run("before wait", func(t *testing.T) {
58:8discarded-error-resulterror result returned by g.Wait is discarded

pool/context_pool_test.go:58:8

57 g.Go(func(context.Context) error { return nil })
58 _ = g.Wait()
59 require.Panics(t, func() { g.WithMaxGoroutines(10) })
171:21nested-structsmove nested anonymous struct types to named declarations

pool/context_pool_test.go:171:21

170 p := pool.New().WithContext(bgctx).WithFirstError()
171 sync := make(chan struct{})
172 p.Go(func(ctx context.Context) error {
224:33discarded-error-resulterror result returned by p.Wait is discarded

pool/context_pool_test.go:224:33

223 })
224 assert.Panics(t, func() { _ = p.Wait() })
225 assert.EqualValues(t, 2, cancelledTasks.Load())
231:39range-value-captureclosure captures reused range variable maxConcurrent

pool/context_pool_test.go:231:39

230 for _, maxConcurrent := range []int{1, 10, 100} {
231 t.Run(strconv.Itoa(maxConcurrent), func(t *testing.T) {
232 maxConcurrent := maxConcurrent // copy
250:22redundant-conversionconversion from int64 to the identical type is redundant

pool/context_pool_test.go:250:22

249 require.NoError(t, p.Wait())
250 require.Equal(t, int64(0), currentConcurrent.Load())
251 })

pool/error_pool.go9

1:9package-commentspackage should have a documentation comment

pool/error_pool.go:1:9

1package pool
2
16:6exported-declaration-commentexported type should have a comment beginning with its name

pool/error_pool.go:16:6

15// A new ErrorPool should be created using `New().WithErrors()`.
16type ErrorPool struct {
17 pool Pool
27:21exported-declaration-commentexported function or method should have a comment beginning with its name

pool/error_pool.go:27:21

26// are busy, a call to Go() will block until the task can be started.
27func (p *ErrorPool) Go(f func() error) {
28 p.pool.Go(func() {
35:21exported-declaration-commentexported function or method should have a comment beginning with its name

pool/error_pool.go:35:21

34// returning any errors from tasks.
35func (p *ErrorPool) Wait() error {
36 p.pool.Wait()
43:4no-else-after-returnremove else and unindent its body after the return

pool/error_pool.go:43:4

42 return nil
43 } else if p.onlyFirstError {
44 return errs[0]
45:4no-else-after-returnremove else and unindent its body after the return

pool/error_pool.go:45:4

44 return errs[0]
45 } else {
46 return errors.Join(errs...)
54:21exported-declaration-commentexported function or method should have a comment beginning with its name

pool/error_pool.go:54:21

53// signal that all goroutines should be cancelled upon the first error.
54func (p *ErrorPool) WithContext(ctx context.Context) *ContextPool {
55 p.panicIfInitialized()
66:21exported-declaration-commentexported function or method should have a comment beginning with its name

pool/error_pool.go:66:21

65// returned by a task. By default, Wait() will return a combined error.
66func (p *ErrorPool) WithFirstError() *ErrorPool {
67 p.panicIfInitialized()
74:21exported-declaration-commentexported function or method should have a comment beginning with its name

pool/error_pool.go:74:21

73// Defaults to unlimited. Panics if n < 1.
74func (p *ErrorPool) WithMaxGoroutines(n int) *ErrorPool {
75 p.panicIfInitialized()

pool/error_pool_test.go13

1:1formatfile is not formatted

pool/error_pool_test.go:1:1

1package pool_test
2
  • Fix (safe): run `strider fmt pool/error_pool_test.go`
22:23error-stringserror string should not be capitalized or end with punctuation

pool/error_pool_test.go:22:23

21 if i == 2 {
22 return errors.New("oh no!")
23 }
28:2discarded-error-resulterror result returned by fmt.Println is discarded

pool/error_pool_test.go:28:2

27 err := p.Wait()
28 fmt.Println(err)
29 // Output:
33:6cognitive-complexityfunction has cognitive complexity 9; maximum is 7

pool/error_pool_test.go:33:6

32
33func TestErrorPool(t *testing.T) {
34 t.Parallel()
33:6function-lengthfunction has 82 statements and 103 lines; maximum is 50 statements or 75 lines

pool/error_pool_test.go:33:6

32
33func TestErrorPool(t *testing.T) {
34 t.Parallel()
39:46test-parallelismconsider calling t.Parallel() when this subtest begins

pool/error_pool_test.go:39:46

38
39 t.Run("panics on configuration after init", func(t *testing.T) {
40 t.Run("before wait", func(t *testing.T) {
51:8discarded-error-resulterror result returned by g.Wait is discarded

pool/error_pool_test.go:51:8

50 g.Go(func() error { return nil })
51 _ = g.Wait()
52 require.Panics(t, func() { g.WithMaxGoroutines(10) })
93:34discarded-error-resulterror result returned by g.Wait is discarded

pool/error_pool_test.go:93:34

92 }
93 require.Panics(t, func() { _ = g.Wait() })
94 })
99:39range-value-captureclosure captures reused range variable maxGoroutines

pool/error_pool_test.go:99:39

98 for _, maxGoroutines := range []int{1, 10, 100} {
99 t.Run(strconv.Itoa(maxGoroutines), func(t *testing.T) {
100 g := pool.New().WithErrors().WithMaxGoroutines(maxGoroutines)
99:39test-parallelismconsider calling t.Parallel() when this subtest begins

pool/error_pool_test.go:99:39

98 for _, maxGoroutines := range []int{1, 10, 100} {
99 t.Run(strconv.Itoa(maxGoroutines), func(t *testing.T) {
100 g := pool.New().WithErrors().WithMaxGoroutines(maxGoroutines)
105:11range-value-captureclosure captures reused range variable maxGoroutines

pool/error_pool_test.go:105:11

104 for i := 0; i < taskCount; i++ {
105 g.Go(func() error {
106 cur := currentConcurrent.Add(1)
116:22redundant-conversionconversion from int64 to the identical type is redundant

pool/error_pool_test.go:116:22

115 require.NoError(t, g.Wait())
116 require.Equal(t, int64(0), currentConcurrent.Load())
117 })
121:17test-parallelismconsider calling t.Parallel() when this subtest begins

pool/error_pool_test.go:121:17

120
121 t.Run("reuse", func(t *testing.T) {
122 // Test for https://github.com/sourcegraph/conc/issues/128

pool/pool.go11

1:1formatfile is not formatted

pool/pool.go:1:1

1package pool
2
  • Fix (safe): run `strider fmt pool/pool.go`
1:9package-commentspackage should have a documentation comment

pool/pool.go:1:9

1package pool
2
30:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pool/pool.go:30:1

29// task has an overhead of around 300ns.
30type Pool struct {
31 handle conc.WaitGroup
30:6exported-declaration-commentexported type should have a comment beginning with its name

pool/pool.go:30:6

29// task has an overhead of around 300ns.
30type Pool struct {
31 handle conc.WaitGroup
39:16exported-declaration-commentexported function or method should have a comment beginning with its name

pool/pool.go:39:16

38// are busy, a call to Go() will block until the task can be started.
39func (p *Pool) Go(f func()) {
40 p.init()
56:21nested-structsmove nested anonymous struct types to named declarations

pool/pool.go:56:21

55 select {
56 case p.limiter <- struct{}{}:
57 // If we are below our limit, spawn a new worker rather
72:16exported-declaration-commentexported function or method should have a comment beginning with its name

pool/pool.go:72:16

71// raised by a tasks.
72func (p *Pool) Wait() {
73 p.init()
91:16exported-declaration-commentexported function or method should have a comment beginning with its name

pool/pool.go:91:16

90// Defaults to unlimited. Panics if n < 1.
91func (p *Pool) WithMaxGoroutines(n int) *Pool {
92 p.panicIfInitialized()
119:16exported-declaration-commentexported function or method should have a comment beginning with its name

pool/pool.go:119:16

118// return errors.
119func (p *Pool) WithErrors() *ErrorPool {
120 p.panicIfInitialized()
140:16exported-declaration-commentexported function or method should have a comment beginning with its name

pool/pool.go:140:16

139// signal that all goroutines should be cancelled upon the first error.
140func (p *Pool) WithContext(ctx context.Context) *ContextPool {
141 p.panicIfInitialized()
164:19nested-structsmove nested anonymous struct types to named declarations

pool/pool.go:164:19

163
164type limiter chan struct{}
165

pool/pool_test.go13

1:1formatfile is not formatted

pool/pool_test.go:1:1

1package pool_test
2
  • Fix (safe): run `strider fmt pool/pool_test.go`
19:4discarded-error-resulterror result returned by fmt.Println is discarded

pool/pool_test.go:19:4

18 p.Go(func() {
19 fmt.Println("conc")
20 })
31:6cognitive-complexityfunction has cognitive complexity 13; maximum is 7

pool/pool_test.go:31:6

30
31func TestPool(t *testing.T) {
32 t.Parallel()
31:6function-lengthfunction has 81 statements and 117 lines; maximum is 50 statements or 75 lines

pool/pool_test.go:31:6

30
31func TestPool(t *testing.T) {
32 t.Parallel()
46:38redundant-conversionconversion from int64 to the identical type is redundant

pool/pool_test.go:46:38

45 g.Wait()
46 require.Equal(t, completed.Load(), int64(100))
47 })
49:46test-parallelismconsider calling t.Parallel() when this subtest begins

pool/pool_test.go:49:46

48
49 t.Run("panics on configuration after init", func(t *testing.T) {
50 t.Run("before wait", func(t *testing.T) {
69:39range-value-captureclosure captures reused range variable maxConcurrent

pool/pool_test.go:69:39

68 for _, maxConcurrent := range []int{1, 10, 100} {
69 t.Run(strconv.Itoa(maxConcurrent), func(t *testing.T) {
70 g := pool.New().WithMaxGoroutines(maxConcurrent)
69:39test-parallelismconsider calling t.Parallel() when this subtest begins

pool/pool_test.go:69:39

68 for _, maxConcurrent := range []int{1, 10, 100} {
69 t.Run(strconv.Itoa(maxConcurrent), func(t *testing.T) {
70 g := pool.New().WithMaxGoroutines(maxConcurrent)
76:11range-value-captureclosure captures reused range variable maxConcurrent

pool/pool_test.go:76:11

75 for i := 0; i < taskCount; i++ {
76 g.Go(func() {
77 cur := currentConcurrent.Add(1)
86:22redundant-conversionconversion from int64 to the identical type is redundant

pool/pool_test.go:86:22

85 g.Wait()
86 require.Equal(t, int64(0), errCount.Load())
87 require.Equal(t, int64(0), currentConcurrent.Load())
87:22redundant-conversionconversion from int64 to the identical type is redundant

pool/pool_test.go:87:22

86 require.Equal(t, int64(0), errCount.Load())
87 require.Equal(t, int64(0), currentConcurrent.Load())
88 })
138:20redundant-conversionconversion from int64 to the identical type is redundant

pool/pool_test.go:138:20

137 p.Wait()
138 require.Equal(t, int64(10), count.Load())
139 for i := 0; i < 10; i++ {
145:20redundant-conversionconversion from int64 to the identical type is redundant

pool/pool_test.go:145:20

144 p.Wait()
145 require.Equal(t, int64(20), count.Load())
146 })

pool/result_context_pool.go10

1:1formatfile is not formatted

pool/result_context_pool.go:1:1

1package pool
2
  • Fix (safe): run `strider fmt pool/result_context_pool.go`
1:9package-commentspackage should have a documentation comment

pool/result_context_pool.go:1:9

1package pool
2
14:6exported-declaration-commentexported type should have a comment beginning with its name

pool/result_context_pool.go:14:6

13// Go() for the first time.
14type ResultContextPool[T any] struct {
15 contextPool ContextPool
22:32exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_context_pool.go:22:32

21// are busy, a call to Go() will block until the task can be started.
22func (p *ResultContextPool[T]) Go(f func(context.Context) (T, error)) {
23 idx := p.agg.nextIndex()
33:32exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_context_pool.go:33:32

32// returns an error if any of the tasks errored.
33func (p *ResultContextPool[T]) Wait() ([]T, error) {
34 err := p.contextPool.Wait()
43:32exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_context_pool.go:43:32

42// are ignored and only the error is collected.
43func (p *ResultContextPool[T]) WithCollectErrored() *ResultContextPool[T] {
44 p.panicIfInitialized()
51:32exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_context_pool.go:51:32

50// returned by a task. By default, Wait() will return a combined error.
51func (p *ResultContextPool[T]) WithFirstError() *ResultContextPool[T] {
52 p.panicIfInitialized()
60:32exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_context_pool.go:60:32

59// canceled until the parent context is canceled.
60func (p *ResultContextPool[T]) WithCancelOnError() *ResultContextPool[T] {
61 p.panicIfInitialized()
69:32exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_context_pool.go:69:32

68// the pool's context is not canceled until the parent context is canceled.
69func (p *ResultContextPool[T]) WithFailFast() *ResultContextPool[T] {
70 p.panicIfInitialized()
77:32exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_context_pool.go:77:32

76// Defaults to unlimited. Panics if n < 1.
77func (p *ResultContextPool[T]) WithMaxGoroutines(n int) *ResultContextPool[T] {
78 p.panicIfInitialized()

pool/result_context_pool_test.go9

1:1formatfile is not formatted

pool/result_context_pool_test.go:1:1

1package pool_test
2
  • Fix (safe): run `strider fmt pool/result_context_pool_test.go`
18:6function-lengthfunction has 177 statements and 230 lines; maximum is 50 statements or 75 lines

pool/result_context_pool_test.go:18:6

17
18func TestResultContextPool(t *testing.T) {
19 t.Parallel()
24:46test-parallelismconsider calling t.Parallel() when this subtest begins

pool/result_context_pool_test.go:24:46

23
24 t.Run("panics on configuration after init", func(t *testing.T) {
25 t.Run("before wait", func(t *testing.T) {
36:11discarded-error-resulterror result returned by g.Wait is discarded

pool/result_context_pool_test.go:36:11

35 g.Go(func(context.Context) (int, error) { return 0, nil })
36 _, _ = g.Wait()
37 require.Panics(t, func() { g.WithMaxGoroutines(10) })
140:36discarded-error-resulterror result returned by p.Wait is discarded

pool/result_context_pool_test.go:140:36

139 })
140 assert.Panics(t, func() { _, _ = p.Wait() })
141 assert.EqualValues(t, 2, cancelledTasks.Load())
176:21nested-structsmove nested anonymous struct types to named declarations

pool/result_context_pool_test.go:176:21

175 g := pool.NewWithResults[int]().WithContext(context.Background()).WithFirstError()
176 sync := make(chan struct{})
177 g.Go(func(ctx context.Context) (int, error) {
201:40range-value-captureclosure captures reused range variable maxConcurrency

pool/result_context_pool_test.go:201:40

200 for _, maxConcurrency := range []int{1, 10, 100} {
201 t.Run(strconv.Itoa(maxConcurrency), func(t *testing.T) {
202 maxConcurrency := maxConcurrency // copy
227:22redundant-conversionconversion from int64 to the identical type is redundant

pool/result_context_pool_test.go:227:22

226 require.NoError(t, err)
227 require.Equal(t, int64(0), currentConcurrent.Load())
228 })
232:17test-parallelismconsider calling t.Parallel() when this subtest begins

pool/result_context_pool_test.go:232:17

231
232 t.Run("reuse", func(t *testing.T) {
233 // Test for https://github.com/sourcegraph/conc/issues/128

pool/result_error_pool.go10

1:1formatfile is not formatted

pool/result_error_pool.go:1:1

1package pool
2
  • Fix (safe): run `strider fmt pool/result_error_pool.go`
1:9package-commentspackage should have a documentation comment

pool/result_error_pool.go:1:9

1package pool
2
16:6exported-declaration-commentexported type should have a comment beginning with its name

pool/result_error_pool.go:16:6

15// Go() for the first time.
16type ResultErrorPool[T any] struct {
17 errorPool ErrorPool
24:30exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_error_pool.go:24:30

23// are busy, a call to Go() will block until the task can be started.
24func (p *ResultErrorPool[T]) Go(f func() (T, error)) {
25 idx := p.agg.nextIndex()
35:30exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_error_pool.go:35:30

34// returning the results and any errors from tasks.
35func (p *ResultErrorPool[T]) Wait() ([]T, error) {
36 err := p.errorPool.Wait()
45:30exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_error_pool.go:45:30

44// are ignored and only the error is collected.
45func (p *ResultErrorPool[T]) WithCollectErrored() *ResultErrorPool[T] {
46 p.panicIfInitialized()
55:30exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_error_pool.go:55:30

54// signal that all goroutines should be cancelled upon the first error.
55func (p *ResultErrorPool[T]) WithContext(ctx context.Context) *ResultContextPool[T] {
56 p.panicIfInitialized()
58:16copy-lock-valuecomposite literal copies pool.ContextPool by value; it contains sync.Mutex

pool/result_error_pool.go:58:16

57 return &ResultContextPool[T]{
58 contextPool: *p.errorPool.WithContext(ctx),
59 }
64:30exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_error_pool.go:64:30

63// returned by a task. By default, Wait() will return a combined error.
64func (p *ResultErrorPool[T]) WithFirstError() *ResultErrorPool[T] {
65 p.panicIfInitialized()
72:30exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_error_pool.go:72:30

71// Defaults to unlimited. Panics if n < 1.
72func (p *ResultErrorPool[T]) WithMaxGoroutines(n int) *ResultErrorPool[T] {
73 p.panicIfInitialized()

pool/result_error_pool_test.go8

1:1formatfile is not formatted

pool/result_error_pool_test.go:1:1

1package pool_test
2
  • Fix (safe): run `strider fmt pool/result_error_pool_test.go`
16:6function-lengthfunction has 105 statements and 134 lines; maximum is 50 statements or 75 lines

pool/result_error_pool_test.go:16:6

15
16func TestResultErrorPool(t *testing.T) {
17 t.Parallel()
22:46test-parallelismconsider calling t.Parallel() when this subtest begins

pool/result_error_pool_test.go:22:46

21
22 t.Run("panics on configuration after init", func(t *testing.T) {
23 t.Run("before wait", func(t *testing.T) {
34:11discarded-error-resulterror result returned by g.Wait is discarded

pool/result_error_pool_test.go:34:11

33 g.Go(func() (int, error) { return 0, nil })
34 _, _ = g.Wait()
35 require.Panics(t, func() { g.WithMaxGoroutines(10) })
69:29nested-structsmove nested anonymous struct types to named declarations

pool/result_error_pool_test.go:69:29

68 g := pool.NewWithResults[int]().WithErrors().WithFirstError()
69 synchronizer := make(chan struct{})
70 g.Go(func() (int, error) {
107:40range-value-captureclosure captures reused range variable maxConcurrency

pool/result_error_pool_test.go:107:40

106 for _, maxConcurrency := range []int{1, 10, 100} {
107 t.Run(strconv.Itoa(maxConcurrency), func(t *testing.T) {
108 maxConcurrency := maxConcurrency // copy
129:22redundant-conversionconversion from int64 to the identical type is redundant

pool/result_error_pool_test.go:129:22

128 require.NoError(t, err)
129 require.Equal(t, int64(0), currentConcurrent.Load())
130 })
134:17test-parallelismconsider calling t.Parallel() when this subtest begins

pool/result_error_pool_test.go:134:17

133
134 t.Run("reuse", func(t *testing.T) {
135 // Test for https://github.com/sourcegraph/conc/issues/128

pool/result_pool.go16

1:1formatfile is not formatted

pool/result_pool.go:1:1

1package pool
2
  • Fix (safe): run `strider fmt pool/result_pool.go`
1:9package-commentspackage should have a documentation comment

pool/result_pool.go:1:9

1package pool
2
13:6exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_pool.go:13:6

12// Go() for the first time.
13func NewWithResults[T any]() *ResultPool[T] {
14 return &ResultPool[T]{
15:9copy-lock-valuecomposite literal copies pool.Pool by value; it contains sync.Mutex

pool/result_pool.go:15:9

14 return &ResultPool[T]{
15 pool: *New(),
16 }
25:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pool/result_pool.go:25:1

24// tasks were submitted.
25type ResultPool[T any] struct {
26 pool Pool
25:6exported-declaration-commentexported type should have a comment beginning with its name

pool/result_pool.go:25:6

24// tasks were submitted.
25type ResultPool[T any] struct {
26 pool Pool
32:25exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_pool.go:32:25

31// are busy, a call to Go() will block until the task can be started.
32func (p *ResultPool[T]) Go(f func() T) {
33 idx := p.agg.nextIndex()
41:25exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_pool.go:41:25

40// a slice of results from tasks that did not panic.
41func (p *ResultPool[T]) Wait() []T {
42 p.pool.Wait()
55:25exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_pool.go:55:25

54// can return errors.
55func (p *ResultPool[T]) WithErrors() *ResultErrorPool[T] {
56 p.panicIfInitialized()
58:14copy-lock-valuecomposite literal copies pool.ErrorPool by value; it contains sync.Mutex

pool/result_pool.go:58:14

57 return &ResultErrorPool[T]{
58 errorPool: *p.pool.WithErrors(),
59 }
66:25exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_pool.go:66:25

65// signal that all goroutines should be cancelled upon the first error.
66func (p *ResultPool[T]) WithContext(ctx context.Context) *ResultContextPool[T] {
67 p.panicIfInitialized()
69:16copy-lock-valuecomposite literal copies pool.ContextPool by value; it contains sync.Mutex

pool/result_pool.go:69:16

68 return &ResultContextPool[T]{
69 contextPool: *p.pool.WithContext(ctx),
70 }
75:25exported-declaration-commentexported function or method should have a comment beginning with its name

pool/result_pool.go:75:25

74// Defaults to unlimited. Panics if n < 1.
75func (p *ResultPool[T]) WithMaxGoroutines(n int) *ResultPool[T] {
76 p.panicIfInitialized()
89:2redefines-builtin-ididentifier len shadows a predeclared identifier

pool/result_pool.go:89:2

88 mu sync.Mutex
89 len int
90 results []T
105:50flag-parameterboolean parameter errored controls function flow

pool/result_pool.go:105:50

104
105func (r *resultAggregator[T]) save(i int, res T, errored bool) {
106 r.mu.Lock()
123:39flag-parameterboolean parameter collectErrored controls function flow

pool/result_pool.go:123:39

122// collect returns the set of aggregated results.
123func (r *resultAggregator[T]) collect(collectErrored bool) []T {
124 if !r.mu.TryLock() {

pool/result_pool_test.go11

1:1formatfile is not formatted

pool/result_pool_test.go:1:1

1package pool_test
2
  • Fix (safe): run `strider fmt pool/result_pool_test.go`
25:2discarded-error-resulterror result returned by fmt.Println is discarded

pool/result_pool_test.go:25:2

24 res := p.Wait()
25 fmt.Println(res)
26
31:6cognitive-complexityfunction has cognitive complexity 9; maximum is 7

pool/result_pool_test.go:31:6

30
31func TestResultGroup(t *testing.T) {
32 t.Parallel()
31:6function-lengthfunction has 74 statements and 99 lines; maximum is 50 statements or 75 lines

pool/result_pool_test.go:31:6

30
31func TestResultGroup(t *testing.T) {
32 t.Parallel()
34:46test-parallelismconsider calling t.Parallel() when this subtest begins

pool/result_pool_test.go:34:46

33
34 t.Run("panics on configuration after init", func(t *testing.T) {
35 t.Run("before wait", func(t *testing.T) {
89:39range-value-captureclosure captures reused range variable maxGoroutines

pool/result_pool_test.go:89:39

88 for _, maxGoroutines := range []int{1, 10, 100} {
89 t.Run(strconv.Itoa(maxGoroutines), func(t *testing.T) {
90 g := pool.NewWithResults[int]().WithMaxGoroutines(maxGoroutines)
89:39test-parallelismconsider calling t.Parallel() when this subtest begins

pool/result_pool_test.go:89:39

88 for _, maxGoroutines := range []int{1, 10, 100} {
89 t.Run(strconv.Itoa(maxGoroutines), func(t *testing.T) {
90 g := pool.NewWithResults[int]().WithMaxGoroutines(maxGoroutines)
99:11range-value-captureclosure captures reused range variable maxGoroutines

pool/result_pool_test.go:99:11

98 expected[i] = i
99 g.Go(func() int {
100 cur := currentConcurrent.Add(1)
111:22redundant-conversionconversion from int64 to the identical type is redundant

pool/result_pool_test.go:111:22

110 require.Equal(t, expected, res)
111 require.Equal(t, int64(0), errCount.Load())
112 require.Equal(t, int64(0), currentConcurrent.Load())
112:22redundant-conversionconversion from int64 to the identical type is redundant

pool/result_pool_test.go:112:22

111 require.Equal(t, int64(0), errCount.Load())
112 require.Equal(t, int64(0), currentConcurrent.Load())
113 })
117:17test-parallelismconsider calling t.Parallel() when this subtest begins

pool/result_pool_test.go:117:17

116
117 t.Run("reuse", func(t *testing.T) {
118 // Test for https://github.com/sourcegraph/conc/issues/128

stream/stream.go12

1:1formatfile is not formatted

stream/stream.go:1:1

1// Package stream provides a concurrent, ordered stream implementation.
2package stream
  • Fix (safe): run `strider fmt stream/stream.go`
15:9copy-lock-valuecomposite literal copies pool.Pool by value; it contains sync.Mutex

stream/stream.go:15:9

14 return &Stream{
15 pool: *pool.New(),
16 }
38:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

stream/stream.go:38:1

37// good enough for any task that requires a network call.
38type Stream struct {
39 pool pool.Pool
38:6exported-declaration-commentexported type should have a comment beginning with its name

stream/stream.go:38:6

37// good enough for any task that requires a network call.
38type Stream struct {
39 pool pool.Pool
39:2import-shadowingidentifier pool shadows an imported package

stream/stream.go:39:2

38type Stream struct {
39 pool pool.Pool
40 callbackerHandle conc.WaitGroup
49:6exported-declaration-commentexported type should have a comment beginning with its name

stream/stream.go:49:6

48// the task has completed.
49type Task func() Callback
50
53:6exported-declaration-commentexported type should have a comment beginning with its name

stream/stream.go:53:6

52// called in the same order that tasks are submitted.
53type Callback func()
54
62:18exported-declaration-commentexported function or method should have a comment beginning with its name

stream/stream.go:62:18

61// started.
62func (s *Stream) Go(f Task) {
63 s.init()
91:18exported-declaration-commentexported function or method should have a comment beginning with its name

stream/stream.go:91:18

90// not return until all tasks and callbacks have been run.
91func (s *Stream) Wait() {
92 s.init()
105:18exported-declaration-commentexported function or method should have a comment beginning with its name

stream/stream.go:105:18

104
105func (s *Stream) WithMaxGoroutines(n int) *Stream {
106 s.pool.WithMaxGoroutines(n)
142:5no-package-varpackage variables introduce mutable global state

stream/stream.go:142:5

141
142var callbackChPool = sync.Pool{
143 New: func() any {
149:29unchecked-type-assertionuse the checked two-result form of the type assertion

stream/stream.go:149:29

148func getCh() callbackCh {
149 return callbackChPool.Get().(callbackCh)
150}

stream/stream_test.go5

1:1formatfile is not formatted

stream/stream_test.go:1:1

1package stream_test
2
  • Fix (safe): run `strider fmt stream/stream_test.go`
23:20discarded-error-resulterror result returned by fmt.Println is discarded

stream/stream_test.go:23:20

22 // This will print in the order the tasks were submitted
23 return func() { fmt.Println(dur) }
24 })
37:6cognitive-complexityfunction has cognitive complexity 8; maximum is 7

stream/stream_test.go:37:6

36
37func TestStream(t *testing.T) {
38 t.Parallel()
37:6function-lengthfunction has 65 statements and 100 lines; maximum is 50 statements or 75 lines

stream/stream_test.go:37:6

36
37func TestStream(t *testing.T) {
38 t.Parallel()
68:20redundant-conversionconversion from int64 to the identical type is redundant

stream/stream_test.go:68:20

67 s.Wait()
68 require.Equal(t, int64(5), totalCount.Load())
69 })

waitgroup.go6

1:1formatfile is not formatted

waitgroup.go:1:1

1package conc
2
  • Fix (safe): run `strider fmt waitgroup.go`
1:9package-commentspackage should have a documentation comment

waitgroup.go:1:9

1package conc
2
22:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

waitgroup.go:22:1

21// Also like sync.WaitGroup, it must not be copied after first use.
22type WaitGroup struct {
23 wg sync.WaitGroup
22:6exported-declaration-commentexported type should have a comment beginning with its name

waitgroup.go:22:6

21// Also like sync.WaitGroup, it must not be copied after first use.
22type WaitGroup struct {
23 wg sync.WaitGroup
38:21exported-declaration-commentexported function or method should have a comment beginning with its name

waitgroup.go:38:21

37// propagate any panics spawned in a child goroutine.
38func (h *WaitGroup) Wait() {
39 h.wg.Wait()
47:21exported-declaration-commentexported function or method should have a comment beginning with its name

waitgroup.go:47:21

46// will return a *panics.Recovered if one of the child goroutines panics.
47func (h *WaitGroup) WaitAndRecover() *panics.Recovered {
48 h.wg.Wait()

waitgroup_test.go8

1:1formatfile is not formatted

waitgroup_test.go:1:1

1package conc_test
2
  • Fix (safe): run `strider fmt waitgroup_test.go`
24:2discarded-error-resulterror result returned by fmt.Println is discarded

waitgroup_test.go:24:2

23
24 fmt.Println(count.Load())
25 // Output:
37:2discarded-error-resulterror result returned by fmt.Println is discarded

waitgroup_test.go:37:2

36 recoveredPanic := wg.WaitAndRecover()
37 fmt.Println(recoveredPanic.Value)
38 // Output:
42:6function-lengthfunction has 79 statements and 117 lines; maximum is 50 statements or 75 lines

waitgroup_test.go:42:6

41
42func TestWaitGroup(t *testing.T) {
43 t.Parallel()
61:34redundant-conversionconversion from int64 to the identical type is redundant

waitgroup_test.go:61:34

60 wg.Wait()
61 require.Equal(t, count.Load(), int64(100))
62 })
80:11add-constantstring literal "super bad thing" appears more than twice; define a constant

waitgroup_test.go:80:11

79 wg.Go(func() {
80 panic("super bad thing")
81 })
114:21redundant-conversionconversion from int64 to the identical type is redundant

waitgroup_test.go:114:21

113 require.Panics(t, wg.Wait)
114 require.Equal(t, int64(2), i.Load())
115 })
155:21redundant-conversionconversion from int64 to the identical type is redundant

waitgroup_test.go:155:21

154 require.Equal(t, p.Value, "super bad thing")
155 require.Equal(t, int64(2), i.Load())
156 })