29 msformat213 mscheck 466total 43errors 173warnings 250notes

bench_helper_test.go7

1:1formatfile is not formatted

bench_helper_test.go:1:1

1package mapset
2
  • Fix (safe): run `strider fmt bench_helper_test.go`
1:9package-directory-mismatchpackage mapset does not match directory golang-set

bench_helper_test.go:1:9

1package mapset
2
16:28flag-parameterboolean parameter safe controls function flow

bench_helper_test.go:16:28

15
16func buildRandomSet(n int, safe bool) Set[int] {
17 if safe {
19:4no-else-after-returnremove else and unindent its body after the return

bench_helper_test.go:19:4

18 return NewSet(nrand(n)...)
19 } else {
20 return NewThreadUnsafeSet(nrand(n)...)
24:27flag-parameterboolean parameter safe controls function flow

bench_helper_test.go:24:27

23
24func buildCaseName(n int, safe bool) string {
25 var settype string
35:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

bench_helper_test.go:35:1

34
35type benchCase struct {
36 n int
41:2slice-preallocationpreallocate cases with capacity len(range source) before appending once per iteration

bench_helper_test.go:41:2

40func buildBenchCases(ns ...int) []benchCase {
41 cases := []benchCase{}
42 for _, n := range ns {

bench_test.go7

1:1file-length-limitfile has 841 lines; maximum is 500

bench_test.go:1:1

1/*
2Open Source Initiative OSI - The MIT License (MIT):Licensing
1:1formatfile is not formatted

bench_test.go:1:1

1/*
2Open Source Initiative OSI - The MIT License (MIT):Licensing
  • Fix (safe): run `strider fmt bench_test.go`
26:9package-directory-mismatchpackage mapset does not match directory golang-set

bench_test.go:26:9

25
26package mapset
27
262:6cognitive-complexityfunction has cognitive complexity 10; maximum is 7

bench_test.go:262:6

261// In this scenario, Contains argument escapes to the heap, while ContainsOne does not.
262func benchContainsComparison(b *testing.B, n int, s Set[int]) {
263 nums := nrand(n)
543:33redundant-conversionconversion from float64 to the identical type is redundant

bench_test.go:543:33

542func benchIntersect(b *testing.B, n int, s, t Set[int]) {
543 nums := nrand(int(float64(n) * float64(1.5)))
544 for _, v := range nums[:n] {
582:33redundant-conversionconversion from float64 to the identical type is redundant

bench_test.go:582:33

581func benchSymmetricDifference(b *testing.B, n int, s, t Set[int]) {
582 nums := nrand(int(float64(n) * float64(1.5)))
583 for _, v := range nums[:n] {
836:12discarded-error-resulterror result returned by s.MarshalJSON is discarded

bench_test.go:836:12

835 for i := 0; i < b.N; i++ {
836 _, _ = s.MarshalJSON()
837 }

helper.go6

3:9package-commentspackage should have a documentation comment

helper.go:3:9

2
3package mapset
4
3:9package-directory-mismatchpackage mapset does not match directory golang-set

helper.go:3:9

2
3package mapset
4
5:37nested-structsmove nested anonymous struct types to named declarations

helper.go:5:37

4
5func mapclone[T comparable](m map[T]struct{}) map[T]struct{} {
6 c := make(map[T]struct{}, len(m))
5:53nested-structsmove nested anonymous struct types to named declarations

helper.go:5:53

4
5func mapclone[T comparable](m map[T]struct{}) map[T]struct{} {
6 c := make(map[T]struct{}, len(m))
6:18nested-structsmove nested anonymous struct types to named declarations

helper.go:6:18

5func mapclone[T comparable](m map[T]struct{}) map[T]struct{} {
6 c := make(map[T]struct{}, len(m))
7 for k := range m {
8:10nested-structsmove nested anonymous struct types to named declarations

helper.go:8:10

7 for k := range m {
8 c[k] = struct{}{}
9 }

helper_1_21.go4

3:9package-commentspackage should have a documentation comment

helper_1_21.go:3:9

2
3package mapset
4
3:9package-directory-mismatchpackage mapset does not match directory golang-set

helper_1_21.go:3:9

2
3package mapset
4
7:37nested-structsmove nested anonymous struct types to named declarations

helper_1_21.go:7:37

6
7func mapclone[T comparable](m map[T]struct{}) map[T]struct{} {
8 return maps.Clone(m)
7:53nested-structsmove nested anonymous struct types to named declarations

helper_1_21.go:7:53

6
7func mapclone[T comparable](m map[T]struct{}) map[T]struct{} {
8 return maps.Clone(m)

iterator.go6

26:9package-commentspackage should have a documentation comment

iterator.go:26:9

25
26package mapset
27
26:9package-directory-mismatchpackage mapset does not match directory golang-set

iterator.go:26:9

25
26package mapset
27
30:6exported-declaration-commentexported type should have a comment beginning with its name

iterator.go:30:6

29// elements.
30type Iterator[T comparable] struct {
31 C <-chan T
32:12nested-structsmove nested anonymous struct types to named declarations

iterator.go:32:12

31 C <-chan T
32 stop chan struct{}
33}
51:66nested-structsmove nested anonymous struct types to named declarations

iterator.go:51:66

50// newIterator returns a new Iterator instance together with its item and stop channels.
51func newIterator[T comparable]() (*Iterator[T], chan<- T, <-chan struct{}) {
52 itemChan := make(chan T)
53:24nested-structsmove nested anonymous struct types to named declarations

iterator.go:53:24

52 itemChan := make(chan T)
53 stopChan := make(chan struct{})
54 return &Iterator[T]{

iterator_example_test.go4

1:1formatfile is not formatted

iterator_example_test.go:1:1

1/*
2Open Source Initiative OSI - The MIT License (MIT):Licensing
  • Fix (safe): run `strider fmt iterator_example_test.go`
26:9package-directory-mismatchpackage mapset does not match directory golang-set

iterator_example_test.go:26:9

25
26package mapset
27
36:6test-parallelismconsider calling t.Parallel() when this test begins

iterator_example_test.go:36:6

35
36func Test_ExampleIterator(t *testing.T) {
37
57:35add-constantstring literal "John" appears more than twice; define a constant

iterator_example_test.go:57:35

56
57 if found == nil || found.name != "John" {
58 t.Fatalf("expected iterator to have found `John` record but got nil or something else")

set.go16

36:9package-directory-mismatchpackage mapset does not match directory golang-set

set.go:36:9

35// that can enforce mutual exclusion through other means.
36package mapset
37
43:6exported-declaration-commentexported type should have a comment beginning with its name

set.go:43:6

42// operations that can be applied to that set.
43type Set[T comparable] interface {
44 // Add adds an element to the set. Returns whether
43:24interface-method-limitinterface has 34 methods, exceeding the configured design limit of 10

set.go:43:24

42// operations that can be applied to that set.
43type Set[T comparable] interface {
44 // Add adds an element to the set. Returns whether
228:6constructor-interface-returnNewSet returns interface Set[T] although its concrete result is consistently *threadSafeSet[T]; return the concrete type

set.go:228:6

227// Operations on the resulting set are thread-safe.
228func NewSet[T comparable](vs ...T) Set[T] {
229 s := newThreadSafeSetWithSize[T](len(vs))
228:6exported-declaration-commentexported function or method should have a comment beginning with its name

set.go:228:6

227// Operations on the resulting set are thread-safe.
228func NewSet[T comparable](vs ...T) Set[T] {
229 s := newThreadSafeSetWithSize[T](len(vs))
236:6constructor-interface-returnNewSetWithSize returns interface Set[T] although its concrete result is consistently *threadSafeSet[T]; return the concrete type

set.go:236:6

235// capacity. Operations on the resulting set are thread-safe.
236func NewSetWithSize[T comparable](cardinality int) Set[T] {
237 return newThreadSafeSetWithSize[T](cardinality)
236:6exported-declaration-commentexported function or method should have a comment beginning with its name

set.go:236:6

235// capacity. Operations on the resulting set are thread-safe.
236func NewSetWithSize[T comparable](cardinality int) Set[T] {
237 return newThreadSafeSetWithSize[T](cardinality)
242:6constructor-interface-returnNewThreadUnsafeSet returns interface Set[T] although its concrete result is consistently *threadUnsafeSet[T]; return the concrete type

set.go:242:6

241// Operations on the resulting set are not thread-safe.
242func NewThreadUnsafeSet[T comparable](vs ...T) Set[T] {
243 s := newThreadUnsafeSetWithSize[T](len(vs))
242:6exported-declaration-commentexported function or method should have a comment beginning with its name

set.go:242:6

241// Operations on the resulting set are not thread-safe.
242func NewThreadUnsafeSet[T comparable](vs ...T) Set[T] {
243 s := newThreadUnsafeSetWithSize[T](len(vs))
250:6constructor-interface-returnNewThreadUnsafeSetWithSize returns interface Set[T] although its concrete result is consistently *threadUnsafeSet[T]; return the concrete type

set.go:250:6

249// a specified capacity. Operations on the resulting set are not thread-safe.
250func NewThreadUnsafeSetWithSize[T comparable](cardinality int) Set[T] {
251 return newThreadUnsafeSetWithSize[T](cardinality)
250:6exported-declaration-commentexported function or method should have a comment beginning with its name

set.go:250:6

249// a specified capacity. Operations on the resulting set are not thread-safe.
250func NewThreadUnsafeSetWithSize[T comparable](cardinality int) Set[T] {
251 return newThreadUnsafeSetWithSize[T](cardinality)
256:6constructor-interface-returnNewSetFromMapKeys returns interface Set[T] although its concrete result is consistently *threadSafeSet[T]; return the concrete type

set.go:256:6

255// Operations on the resulting set are thread-safe.
256func NewSetFromMapKeys[T comparable, V any](val map[T]V) Set[T] {
257 s := newThreadSafeSetWithSize[T](len(val))
256:6exported-declaration-commentexported function or method should have a comment beginning with its name

set.go:256:6

255// Operations on the resulting set are thread-safe.
256func NewSetFromMapKeys[T comparable, V any](val map[T]V) Set[T] {
257 s := newThreadSafeSetWithSize[T](len(val))
268:6constructor-interface-returnNewThreadUnsafeSetFromMapKeys returns interface Set[T] although its concrete result is consistently *threadUnsafeSet[T]; return the concrete type

set.go:268:6

267// Operations on the resulting set are not thread-safe.
268func NewThreadUnsafeSetFromMapKeys[T comparable, V any](val map[T]V) Set[T] {
269 s := newThreadUnsafeSetWithSize[T](len(val))
268:6exported-declaration-commentexported function or method should have a comment beginning with its name

set.go:268:6

267// Operations on the resulting set are not thread-safe.
268func NewThreadUnsafeSetFromMapKeys[T comparable, V any](val map[T]V) Set[T] {
269 s := newThreadUnsafeSetWithSize[T](len(val))
280:6exported-declaration-commentexported function or method should have a comment beginning with its name

set.go:280:6

279// with Go 1.23, users can use a for loop to iterate over it.
280func Elements[T comparable](s Set[T]) func(func(element T) bool) {
281 return func(yield func(element T) bool) {

set123_test.go4

1:1formatfile is not formatted

set123_test.go:1:1

1//go:build go1.23
2// +build go1.23
  • Fix (safe): run `strider fmt set123_test.go`
2:1redundant-build-taglegacy +build line is redundant with go:build

set123_test.go:2:1

1//go:build go1.23
2// +build go1.23
3
4:9package-directory-mismatchpackage mapset does not match directory golang-set

set123_test.go:4:9

3
4package mapset
5
10:6test-parallelismconsider calling t.Parallel() when this test begins

set123_test.go:10:6

9
10func Test_Elements123(t *testing.T) {
11 a := NewSet[string]()

set_test.go153

1:1file-length-limitfile has 1678 lines; maximum is 500

set_test.go:1:1

1/*
2Open Source Initiative OSI - The MIT License (MIT):Licensing
1:1formatfile is not formatted

set_test.go:1:1

1/*
2Open Source Initiative OSI - The MIT License (MIT):Licensing
  • Fix (safe): run `strider fmt set_test.go`
26:9package-directory-mismatchpackage mapset does not match directory golang-set

set_test.go:26:9

25
26package mapset
27
62:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:62:12

61 if !a.Equal(b) {
62 t.Errorf("%v != %v\n", a, b)
63 }
66:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:66:6

65
66func Test_NewSet(t *testing.T) {
67 a := NewSet[int]()
76:30add-constantstring literal "a" appears more than twice; define a constant

set_test.go:76:30

75 assertEqual(NewSet([]string{"a"}...), NewSet("a"), t)
76 assertEqual(NewSet([]string{"a", "b"}...), NewSet("a", "b"), t)
77}
79:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:79:6

78
79func Test_NewUnsafeSet(t *testing.T) {
80 a := NewThreadUnsafeSet[int]()
87:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:87:6

86
87func Test_AddSet(t *testing.T) {
88 a := makeSetInt([]int{1, 2, 3})
95:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:95:6

94
95func Test_AddUnsafeSet(t *testing.T) {
96 a := makeUnsafeSetInt([]int{1, 2, 3})
103:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:103:6

102
103func Test_AppendSet(t *testing.T) {
104 a := makeSetIntWithAppend(1, 2, 3)
111:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:111:6

110
111func Test_AppendUnsafeSet(t *testing.T) {
112 a := makeUnsafeSetIntWithAppend(1, 2, 3)
119:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:119:6

118
119func Test_AddSetNoDuplicate(t *testing.T) {
120 a := makeSetInt([]int{7, 5, 3, 7})
126:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:126:7

125
126 if !(a.Contains(7) && a.Contains(5) && a.Contains(3)) {
127 t.Error("AddSetNoDuplicate set should have a 7, 5, and 3 in it.")
131:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:131:6

130
131func Test_AddUnsafeSetNoDuplicate(t *testing.T) {
132 a := makeUnsafeSetInt([]int{7, 5, 3, 7})
138:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:138:7

137
138 if !(a.Contains(7) && a.Contains(5) && a.Contains(3)) {
139 t.Error("AddSetNoDuplicate set should have a 7, 5, and 3 in it.")
143:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:143:6

142
143func Test_AppendSetNoDuplicate(t *testing.T) {
144 a := makeSetIntWithAppend(7, 5, 3, 7)
150:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:150:7

149
150 if !(a.Contains(7) && a.Contains(5) && a.Contains(3)) {
151 t.Error("AppendSetNoDuplicate set should have a 7, 5, and 3 in it.")
155:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:155:6

154
155func Test_AppendUnsafeSetNoDuplicate(t *testing.T) {
156 a := makeUnsafeSetIntWithAppend(7, 5, 3, 7)
162:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:162:7

161
162 if !(a.Contains(7) && a.Contains(5) && a.Contains(3)) {
163 t.Error("AppendSetNoDuplicate set should have a 7, 5, and 3 in it.")
167:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:167:6

166
167func Test_AppendFrom(t *testing.T) {
168 a := NewSet("Z", "Y", "X", "W")
171:31add-constantstring literal "X" appears more than twice; define a constant

set_test.go:171:31

170
171 if !a.Equal(NewSet("Z", "Y", "X", "W", "A", "B")) {
172 t.Error("Added set is not correct")
171:36add-constantstring literal "W" appears more than twice; define a constant

set_test.go:171:36

170
171 if !a.Equal(NewSet("Z", "Y", "X", "W", "A", "B")) {
172 t.Error("Added set is not correct")
175:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:175:12

174 if num != 2 {
175 t.Errorf("Number of added elements is not correct. num: %d", num)
176 }
179:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:179:6

178
179func Test_UnsafeAppendFrom(t *testing.T) {
180 a := NewThreadUnsafeSet("Z", "Y", "X", "W")
180:26add-constantstring literal "Z" appears more than twice; define a constant

set_test.go:180:26

179func Test_UnsafeAppendFrom(t *testing.T) {
180 a := NewThreadUnsafeSet("Z", "Y", "X", "W")
181 num := a.AppendFrom(NewThreadUnsafeSet("A", "B", "X", "W"))
180:31add-constantstring literal "Y" appears more than twice; define a constant

set_test.go:180:31

179func Test_UnsafeAppendFrom(t *testing.T) {
180 a := NewThreadUnsafeSet("Z", "Y", "X", "W")
181 num := a.AppendFrom(NewThreadUnsafeSet("A", "B", "X", "W"))
181:41add-constantstring literal "A" appears more than twice; define a constant

set_test.go:181:41

180 a := NewThreadUnsafeSet("Z", "Y", "X", "W")
181 num := a.AppendFrom(NewThreadUnsafeSet("A", "B", "X", "W"))
182
181:46add-constantstring literal "B" appears more than twice; define a constant

set_test.go:181:46

180 a := NewThreadUnsafeSet("Z", "Y", "X", "W")
181 num := a.AppendFrom(NewThreadUnsafeSet("A", "B", "X", "W"))
182
187:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:187:12

186 if num != 2 {
187 t.Errorf("Number of added elements is not correct. num: %d", num)
188 }
191:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:191:6

190
191func Test_RemoveSet(t *testing.T) {
192 a := makeSetInt([]int{6, 3, 1})
212:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:212:6

211
212func Test_RemoveAllSet(t *testing.T) {
213 a := makeSetInt([]int{6, 3, 1, 8, 9})
232:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:232:6

231
232func Test_RemoveUnsafeSet(t *testing.T) {
233 a := makeUnsafeSetInt([]int{6, 3, 1})
249:11add-constantstring literal "RemoveSet should be an empty set after removing 6 and 1" appears more than twice; define a constant

set_test.go:249:11

248 if a.Cardinality() != 0 {
249 t.Error("RemoveSet should be an empty set after removing 6 and 1")
250 }
253:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:253:6

252
253func Test_RemoveAllUnsafeSet(t *testing.T) {
254 a := makeUnsafeSetInt([]int{6, 3, 1, 8, 9})
273:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:273:6

272
273func Test_ContainsSet(t *testing.T) {
274 a := NewSet[int]()
292:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:292:7

291
292 if !(a.Contains(13) && a.Contains(7) && a.Contains(1)) {
293 t.Error("ContainsSet should contain 13, 7, 1")
297:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:297:6

296
297func Test_ContainsUnsafeSet(t *testing.T) {
298 a := NewThreadUnsafeSet[int]()
316:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:316:7

315
316 if !(a.Contains(13) && a.Contains(7) && a.Contains(1)) {
317 t.Error("ContainsSet should contain 13, 7, 1")
321:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:321:6

320
321func Test_ContainsMultipleSet(t *testing.T) {
322 a := makeSetInt([]int{8, 6, 7, 5, 3, 0, 9})
333:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:333:6

332
333func Test_ContainsMultipleUnsafeSet(t *testing.T) {
334 a := makeUnsafeSetInt([]int{8, 6, 7, 5, 3, 0, 9})
345:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:345:6

344
345func Test_ContainsOneSet(t *testing.T) {
346 a := NewSet[int]()
351:11add-constantstring literal "ContainsSet should contain 71" appears more than twice; define a constant

set_test.go:351:11

350 if !a.ContainsOne(71) {
351 t.Error("ContainsSet should contain 71")
352 }
357:11add-constantstring literal "ContainsSet should not contain 71" appears more than twice; define a constant

set_test.go:357:11

356 if a.ContainsOne(71) {
357 t.Error("ContainsSet should not contain 71")
358 }
364:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:364:7

363
364 if !(a.ContainsOne(13) && a.ContainsOne(7) && a.ContainsOne(1)) {
365 t.Error("ContainsSet should contain 13, 7, 1")
365:11add-constantstring literal "ContainsSet should contain 13, 7, 1" appears more than twice; define a constant

set_test.go:365:11

364 if !(a.ContainsOne(13) && a.ContainsOne(7) && a.ContainsOne(1)) {
365 t.Error("ContainsSet should contain 13, 7, 1")
366 }
369:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:369:6

368
369func Test_ContainsOneUnsafeSet(t *testing.T) {
370 a := NewThreadUnsafeSet[int]()
388:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:388:7

387
388 if !(a.ContainsOne(13) && a.ContainsOne(7) && a.ContainsOne(1)) {
389 t.Error("ContainsSet should contain 13, 7, 1")
393:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:393:6

392
393func Test_ContainsAnySet(t *testing.T) {
394 a := NewSet[int]()
425:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:425:6

424
425func Test_ContainsAnyElement(t *testing.T) {
426 a := NewSet[int]()
452:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:452:6

451}
452func Test_ClearSet(t *testing.T) {
453 a := makeSetInt([]int{2, 5, 9, 10})
462:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:462:6

461
462func Test_ClearUnsafeSet(t *testing.T) {
463 a := makeUnsafeSetInt([]int{2, 5, 9, 10})
472:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:472:6

471
472func Test_CardinalitySet(t *testing.T) {
473 a := NewSet[int]()
500:11add-constantstring literal "set should have a size of 1" appears more than twice; define a constant

set_test.go:500:11

499 if a.Cardinality() != 0 {
500 t.Error("set should have a size of 1")
501 }
504:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:504:6

503
504func Test_CardinalityUnsafeSet(t *testing.T) {
505 a := NewThreadUnsafeSet[int]()
508:11add-constantstring literal "set should be an empty set" appears more than twice; define a constant

set_test.go:508:11

507 if a.Cardinality() != 0 {
508 t.Error("set should be an empty set")
509 }
536:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:536:6

535
536func Test_SetIsSubset(t *testing.T) {
537 a := makeSetInt([]int{1, 2, 3, 5, 7})
555:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:555:6

554
555func Test_SetIsProperSubset(t *testing.T) {
556 a := makeSetInt([]int{1, 2, 3, 5, 7})
576:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:576:6

575
576func Test_UnsafeSetIsSubset(t *testing.T) {
577 a := makeUnsafeSetInt([]int{1, 2, 3, 5, 7})
595:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:595:6

594
595func Test_UnsafeSetIsProperSubset(t *testing.T) {
596 a := makeUnsafeSetInt([]int{1, 2, 3, 5, 7})
605:11add-constantstring literal "set a should be a subset of set b" appears more than twice; define a constant

set_test.go:605:11

604 if !a.IsSubset(b) {
605 t.Error("set a should be a subset of set b")
606 }
621:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:621:6

620
621func Test_SetIsSuperset(t *testing.T) {
622 a := NewSet[int]()
645:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:645:6

644
645func Test_SetIsProperSuperset(t *testing.T) {
646 a := NewSet[int]()
666:11add-constantstring literal "set a should be a superset of set b" appears more than twice; define a constant

set_test.go:666:11

665 if !a.IsSuperset(b) {
666 t.Error("set a should be a superset of set b")
667 }
682:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:682:6

681
682func Test_UnsafeSetIsSuperset(t *testing.T) {
683 a := NewThreadUnsafeSet[int]()
706:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:706:6

705
706func Test_UnsafeSetIsProperSuperset(t *testing.T) {
707 a := NewThreadUnsafeSet[int]()
736:11add-constantstring literal "set a should not be a superset of set b because set b has a 42" appears more than twice; define a constant

set_test.go:736:11

735 if a.IsSuperset(b) {
736 t.Error("set a should not be a superset of set b because set b has a 42")
737 }
743:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:743:6

742
743func Test_SetUnion(t *testing.T) {
744 a := NewSet[int]()
779:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:779:6

778
779func Test_UnsafeSetUnion(t *testing.T) {
780 a := NewThreadUnsafeSet[int]()
815:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:815:6

814
815func Test_SetIntersect(t *testing.T) {
816 a := NewSet[int]()
837:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:837:7

836
837 if !(d.Cardinality() == 1 && d.Contains(10)) {
838 t.Error("set d should have a size of 1 and contain the item 10")
842:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:842:6

841
842func Test_UnsafeSetIntersect(t *testing.T) {
843 a := NewThreadUnsafeSet[int]()
864:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:864:7

863
864 if !(d.Cardinality() == 1 && d.Contains(10)) {
865 t.Error("set d should have a size of 1 and contain the item 10")
869:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:869:6

868
869func Test_SetDifference(t *testing.T) {
870 a := NewSet[int]()
885:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:885:7

884
885 if !(c.Cardinality() == 1 && c.Contains(2)) {
886 t.Error("the difference of set a to b is the set of 1 item: 2")
890:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:890:6

889
890func Test_UnsafeSetDifference(t *testing.T) {
891 a := NewThreadUnsafeSet[int]()
906:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:906:7

905
906 if !(c.Cardinality() == 1 && c.Contains(2)) {
907 t.Error("the difference of set a to b is the set of 1 item: 2")
911:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:911:6

910
911func Test_SetSymmetricDifference(t *testing.T) {
912 a := NewSet[int]()
928:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:928:7

927
928 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
929 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
928:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:928:7

927
928 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
929 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
928:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:928:7

927
928 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
929 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
928:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:928:7

927
928 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
929 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
928:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:928:7

927
928 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
929 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
928:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:928:7

927
928 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
929 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
933:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:933:6

932
933func Test_UnsafeSetSymmetricDifference(t *testing.T) {
934 a := NewThreadUnsafeSet[int]()
950:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:950:7

949
950 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
951 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
950:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:950:7

949
950 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
951 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
950:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:950:7

949
950 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
951 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
950:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:950:7

949
950 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
951 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
950:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:950:7

949
950 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
951 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
950:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

set_test.go:950:7

949
950 if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
951 t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
955:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:955:6

954
955func Test_SetEqual(t *testing.T) {
956 a := NewSet[int]()
992:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:992:6

991
992func Test_UnsafeSetEqual(t *testing.T) {
993 a := NewThreadUnsafeSet[int]()
1029:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1029:6

1028
1029func Test_SetClone(t *testing.T) {
1030 a := NewSet[int]()
1053:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1053:6

1052
1053func Test_UnsafeSetClone(t *testing.T) {
1054 a := NewThreadUnsafeSet[int]()
1077:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1077:6

1076
1077func Test_Each(t *testing.T) {
1078 a := NewSet[string]()
1108:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1108:6

1107
1108func Test_Filter(t *testing.T) {
1109 a := NewSet[string]()
1122:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1122:12

1121 if !keepFromX.Equal(expected) {
1122 t.Errorf("Expected %v, got %v", expected, keepFromX)
1123 }
1127:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1127:12

1126 if a.Cardinality() != 4 {
1127 t.Errorf("Expected source cardinality 4, got %d", a.Cardinality())
1128 }
1133:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1133:12

1132 if !all.Equal(a) {
1133 t.Errorf("Expected clone of source, got %v", all)
1134 }
1142:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1142:12

1141 if none.Cardinality() != 0 {
1142 t.Errorf("Expected empty set, got %v", none)
1143 }
1149:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1149:12

1148 if emptyOut.Cardinality() != 0 {
1149 t.Errorf("Expected empty set from empty source, got %v", emptyOut)
1150 }
1153:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1153:6

1152
1153func Test_UnsafeFilter(t *testing.T) {
1154 a := NewThreadUnsafeSet[int]()
1166:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1166:12

1165 if !evens.Equal(expected) {
1166 t.Errorf("Expected %v, got %v", expected, evens)
1167 }
1171:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1171:12

1170 if a.Cardinality() != 4 {
1171 t.Errorf("Expected source cardinality 4, got %d", a.Cardinality())
1172 }
1177:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1177:12

1176 if none.Cardinality() != 0 {
1177 t.Errorf("Expected empty set, got %v", none)
1178 }
1184:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1184:12

1183 if emptyOut.Cardinality() != 0 {
1184 t.Errorf("Expected empty set from empty source, got %v", emptyOut)
1185 }
1188:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1188:6

1187
1188func Test_FilterVisitsAllElements(t *testing.T) {
1189 a := NewSet(1, 2, 3, 4, 5)
1198:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1198:12

1197 if !visited.Equal(a) {
1198 t.Errorf("Filter did not visit every element: visited %v, expected %v", visited, a)
1199 }
1202:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1202:6

1201
1202func Test_Iter(t *testing.T) {
1203 a := NewSet[string]()
1220:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1220:6

1219
1220func Test_UnsafeIter(t *testing.T) {
1221 a := NewThreadUnsafeSet[string]()
1238:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1238:6

1237
1238func Test_Iterator(t *testing.T) {
1239 a := NewSet[string]()
1256:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1256:6

1255
1256func Test_UnsafeIterator(t *testing.T) {
1257 a := NewThreadUnsafeSet[string]()
1274:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1274:6

1273
1274func Test_IteratorStop(t *testing.T) {
1275 a := NewSet[string]()
1289:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1289:6

1288
1289func Test_PopSafe(t *testing.T) {
1290 a := NewSet[string]()
1293:8add-constantstring literal "b" appears more than twice; define a constant

set_test.go:1293:8

1292 a.Add("a")
1293 a.Add("b")
1294 a.Add("c")
1299:3no-naked-returnreturn values must be explicit

set_test.go:1299:3

1298 v, _ = a.Pop()
1299 return
1300 }
1326:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1326:6

1325
1326func Test_PopUnsafe(t *testing.T) {
1327 a := NewThreadUnsafeSet[string]()
1331:8add-constantstring literal "c" appears more than twice; define a constant

set_test.go:1331:8

1330 a.Add("b")
1331 a.Add("c")
1332 a.Add("d")
1332:8add-constantstring literal "d" appears more than twice; define a constant

set_test.go:1332:8

1331 a.Add("c")
1332 a.Add("d")
1333
1336:3no-naked-returnreturn values must be explicit

set_test.go:1336:3

1335 v, _ = a.Pop()
1336 return
1337 }
1363:6cognitive-complexityfunction has cognitive complexity 10; maximum is 7

set_test.go:1363:6

1362
1363func Test_PopNSafe(t *testing.T) {
1364 a := NewSet[string]()
1363:6cyclomatic-complexityfunction complexity is 11; maximum is 10

set_test.go:1363:6

1362
1363func Test_PopNSafe(t *testing.T) {
1364 a := NewSet[string]()
1363:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1363:6

1362
1363func Test_PopNSafe(t *testing.T) {
1364 a := NewSet[string]()
1371:2overwritten-before-usethis value of items is overwritten before use

set_test.go:1371:2

1370 // Test pop with n <= 0
1371 items, count := a.PopN(0)
1372 if count != 0 {
1375:2overwritten-before-usethis value of items is overwritten before use

set_test.go:1375:2

1374 }
1375 items, count = a.PopN(-1)
1376 if count != 0 {
1408:12add-constantstring literal "expected 0 items popped, got %d" appears more than twice; define a constant

set_test.go:1408:12

1407 if count != 0 {
1408 t.Errorf("expected 0 items popped, got %d", count)
1409 }
1415:11add-constantstring literal "unexpected result set; should be a,b,c,d (any order is fine" appears more than twice; define a constant

set_test.go:1415:11

1414 if !captureSet.Contains("c", "a", "d", "b") {
1415 t.Error("unexpected result set; should be a,b,c,d (any order is fine")
1416 }
1419:6cognitive-complexityfunction has cognitive complexity 10; maximum is 7

set_test.go:1419:6

1418
1419func Test_PopNUnsafe(t *testing.T) {
1420 a := NewThreadUnsafeSet[string]()
1419:6cyclomatic-complexityfunction complexity is 11; maximum is 10

set_test.go:1419:6

1418
1419func Test_PopNUnsafe(t *testing.T) {
1420 a := NewThreadUnsafeSet[string]()
1419:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1419:6

1418
1419func Test_PopNUnsafe(t *testing.T) {
1420 a := NewThreadUnsafeSet[string]()
1427:2overwritten-before-usethis value of items is overwritten before use

set_test.go:1427:2

1426 // Test pop with n <= 0
1427 items, count := a.PopN(0)
1428 if count != 0 {
1431:2overwritten-before-usethis value of items is overwritten before use

set_test.go:1431:2

1430 }
1431 items, count = a.PopN(-1)
1432 if count != 0 {
1441:12add-constantstring literal "expected 2 items popped, got %d" appears more than twice; define a constant

set_test.go:1441:12

1440 if count != 2 {
1441 t.Errorf("expected 2 items popped, got %d", count)
1442 }
1475:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1475:6

1474
1475func Test_EmptySetProperties(t *testing.T) {
1476 empty := NewSet[string]()
1516:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1516:6

1515
1516func Test_ToSliceUnthreadsafe(t *testing.T) {
1517 s := makeUnsafeSetInt([]int{1, 2, 3})
1520:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1520:12

1519 if len(setAsSlice) != s.Cardinality() {
1520 t.Errorf("Set length is incorrect: %v", len(setAsSlice))
1521 }
1525:13error-stringserror string should not be capitalized or end with punctuation

set_test.go:1525:13

1524 if !s.Contains(i) {
1525 t.Errorf("Set is missing element: %v", i)
1526 }
1530:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1530:6

1529
1530func Test_NewSetFromMapKey_Ints(t *testing.T) {
1531 m := map[int]int{
1539:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1539:12

1538 if len(m) != s.Cardinality() {
1539 t.Errorf("Length of Set is not the same as the map. Expected: %d. Actual: %d", len(m), s.Cardinality())
1540 }
1544:13error-stringserror string should not be capitalized or end with punctuation

set_test.go:1544:13

1543 if !s.Contains(k) {
1544 t.Errorf("Element %d not found in map: %v", k, m)
1545 }
1549:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1549:6

1548
1549func Test_NewSetFromMapKey_Strings(t *testing.T) {
1550 m := map[int]int{
1558:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1558:12

1557 if len(m) != s.Cardinality() {
1558 t.Errorf("Length of Set is not the same as the map. Expected: %d. Actual: %d", len(m), s.Cardinality())
1559 }
1563:13error-stringserror string should not be capitalized or end with punctuation

set_test.go:1563:13

1562 if !s.Contains(k) {
1563 t.Errorf("Element %q not found in map: %v", k, m)
1564 }
1568:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1568:6

1567
1568func Test_NewThreadUnsafeSetFromMapKey_Ints(t *testing.T) {
1569 m := map[int]int{
1577:12add-constantstring literal "Length of Set is not the same as the map. Expected: %d. Actual: %d" appears more than twice; define a constant

set_test.go:1577:12

1576 if len(m) != s.Cardinality() {
1577 t.Errorf("Length of Set is not the same as the map. Expected: %d. Actual: %d", len(m), s.Cardinality())
1578 }
1577:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1577:12

1576 if len(m) != s.Cardinality() {
1577 t.Errorf("Length of Set is not the same as the map. Expected: %d. Actual: %d", len(m), s.Cardinality())
1578 }
1582:13error-stringserror string should not be capitalized or end with punctuation

set_test.go:1582:13

1581 if !s.Contains(k) {
1582 t.Errorf("Element %d not found in map: %v", k, m)
1583 }
1587:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1587:6

1586
1587func Test_NewThreadUnsafeSetFromMapKey_Strings(t *testing.T) {
1588 m := map[int]int{
1596:12error-stringserror string should not be capitalized or end with punctuation

set_test.go:1596:12

1595 if len(m) != s.Cardinality() {
1596 t.Errorf("Length of Set is not the same as the map. Expected: %d. Actual: %d", len(m), s.Cardinality())
1597 }
1601:13error-stringserror string should not be capitalized or end with punctuation

set_test.go:1601:13

1600 if !s.Contains(k) {
1601 t.Errorf("Element %q not found in map: %v", k, m)
1602 }
1606:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1606:6

1605
1606func Test_Elements(t *testing.T) {
1607 a := NewSet[string]()
1638:6test-parallelismconsider calling t.Parallel() when this test begins

set_test.go:1638:6

1637
1638func Test_Example(t *testing.T) {
1639 /*
1638:19unused-parameterparameter t is unused

set_test.go:1638:19

1637
1638func Test_Example(t *testing.T) {
1639 /*

sorted.go4

2:1redundant-build-taglegacy +build line is redundant with go:build

sorted.go:2:1

1//go:build go1.21
2// +build go1.21
3
29:9package-commentspackage should have a documentation comment

sorted.go:29:9

28
29package mapset
30
29:9package-directory-mismatchpackage mapset does not match directory golang-set

sorted.go:29:9

28
29package mapset
30
38:6exported-declaration-commentexported function or method should have a comment beginning with its name

sorted.go:38:6

37// When sorting floating-point numbers, NaNs are ordered before other values.
38func Sorted[E cmp.Ordered](set Set[E]) []E {
39 s := set.ToSlice()

sorted_test.go10

1:1formatfile is not formatted

sorted_test.go:1:1

1//go:build go1.21
2// +build go1.21
  • Fix (safe): run `strider fmt sorted_test.go`
2:1redundant-build-taglegacy +build line is redundant with go:build

sorted_test.go:2:1

1//go:build go1.21
2// +build go1.21
3
29:9package-directory-mismatchpackage mapset does not match directory golang-set

sorted_test.go:29:9

28
29package mapset
30
35:6test-parallelismconsider calling t.Parallel() when this test begins

sorted_test.go:35:6

34
35func Test_Sorted(t *testing.T) {
36 test := func(t *testing.T, ctor func(vals ...string) Set[string]) {
41:13error-stringserror string should not be capitalized or end with punctuation

sorted_test.go:41:13

40 if len(sorted) != set.Cardinality() {
41 t.Errorf("Length of slice is not the same as the set. Expected: %d. Actual: %d", set.Cardinality(), len(sorted))
42 }
45:13error-stringserror string should not be capitalized or end with punctuation

sorted_test.go:45:13

44 if sorted[0] != "apple" {
45 t.Errorf("Element 0 was not equal to apple: %s", sorted[0])
46 }
48:13error-stringserror string should not be capitalized or end with punctuation

sorted_test.go:48:13

47 if sorted[1] != "banana" {
48 t.Errorf("Element 1 was not equal to banana: %s", sorted[1])
49 }
51:13error-stringserror string should not be capitalized or end with punctuation

sorted_test.go:51:13

50 if sorted[2] != "pear" {
51 t.Errorf("Element 2 was not equal to pear: %s", sorted[2])
52 }
55:16test-parallelismconsider calling t.Parallel() when this subtest begins

sorted_test.go:55:16

54
55 t.Run("Safe", func(t *testing.T) {
56 test(t, NewSet[string])
58:18test-parallelismconsider calling t.Parallel() when this subtest begins

sorted_test.go:58:18

57 })
58 t.Run("Unsafe", func(t *testing.T) {
59 test(t, NewThreadUnsafeSet[string])

threadsafe.go50

1:1formatfile is not formatted

threadsafe.go:1:1

1/*
2Open Source Initiative OSI - The MIT License (MIT):Licensing
  • Fix (safe): run `strider fmt threadsafe.go`
26:9package-commentspackage should have a documentation comment

threadsafe.go:26:9

25
26package mapset
27
26:9package-directory-mismatchpackage mapset does not match directory golang-set

threadsafe.go:26:9

25
26package mapset
27
51:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:51:28

50
51func (t *threadSafeSet[T]) Add(v T) bool {
52 t.Lock()
58:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:58:28

57
58func (t *threadSafeSet[T]) Append(v ...T) int {
59 t.Lock()
65:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:65:28

64
65func (t *threadSafeSet[T]) AppendFrom(other Set[T]) int {
66 o := other.(*threadSafeSet[T])
66:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:66:12

65func (t *threadSafeSet[T]) AppendFrom(other Set[T]) int {
66 o := other.(*threadSafeSet[T])
67
76:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:76:28

75
76func (t *threadSafeSet[T]) Contains(v ...T) bool {
77 t.RLock()
84:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:84:28

83
84func (t *threadSafeSet[T]) ContainsOne(v T) bool {
85 t.RLock()
92:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:92:28

91
92func (t *threadSafeSet[T]) ContainsAny(v ...T) bool {
93 t.RLock()
100:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:100:28

99
100func (t *threadSafeSet[T]) ContainsAnyElement(other Set[T]) bool {
101 o := other.(*threadSafeSet[T])
101:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:101:12

100func (t *threadSafeSet[T]) ContainsAnyElement(other Set[T]) bool {
101 o := other.(*threadSafeSet[T])
102
113:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:113:28

112
113func (t *threadSafeSet[T]) IsEmpty() bool {
114 return t.Cardinality() == 0
117:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:117:28

116
117func (t *threadSafeSet[T]) IsSubset(other Set[T]) bool {
118 o := other.(*threadSafeSet[T])
118:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:118:12

117func (t *threadSafeSet[T]) IsSubset(other Set[T]) bool {
118 o := other.(*threadSafeSet[T])
119
129:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:129:28

128
129func (t *threadSafeSet[T]) IsProperSubset(other Set[T]) bool {
130 o := other.(*threadSafeSet[T])
130:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:130:12

129func (t *threadSafeSet[T]) IsProperSubset(other Set[T]) bool {
130 o := other.(*threadSafeSet[T])
131
140:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:140:28

139
140func (t *threadSafeSet[T]) IsSuperset(other Set[T]) bool {
141 return other.IsSubset(t)
144:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:144:28

143
144func (t *threadSafeSet[T]) IsProperSuperset(other Set[T]) bool {
145 return other.IsProperSubset(t)
148:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:148:28

147
148func (t *threadSafeSet[T]) Union(other Set[T]) Set[T] {
149 o := other.(*threadSafeSet[T])
149:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:149:12

148func (t *threadSafeSet[T]) Union(other Set[T]) Set[T] {
149 o := other.(*threadSafeSet[T])
150
154:35unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:154:35

153
154 unsafeUnion := t.uss.Union(o.uss).(*threadUnsafeSet[T])
155 ret := &threadSafeSet[T]{uss: unsafeUnion}
161:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:161:28

160
161func (t *threadSafeSet[T]) Intersect(other Set[T]) Set[T] {
162 o := other.(*threadSafeSet[T])
162:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:162:12

161func (t *threadSafeSet[T]) Intersect(other Set[T]) Set[T] {
162 o := other.(*threadSafeSet[T])
163
167:46unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:167:46

166
167 unsafeIntersection := t.uss.Intersect(o.uss).(*threadUnsafeSet[T])
168 ret := &threadSafeSet[T]{uss: unsafeIntersection}
174:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:174:28

173
174func (t *threadSafeSet[T]) Difference(other Set[T]) Set[T] {
175 o := other.(*threadSafeSet[T])
175:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:175:12

174func (t *threadSafeSet[T]) Difference(other Set[T]) Set[T] {
175 o := other.(*threadSafeSet[T])
176
180:45unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:180:45

179
180 unsafeDifference := t.uss.Difference(o.uss).(*threadUnsafeSet[T])
181 ret := &threadSafeSet[T]{uss: unsafeDifference}
187:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:187:28

186
187func (t *threadSafeSet[T]) SymmetricDifference(other Set[T]) Set[T] {
188 o := other.(*threadSafeSet[T])
188:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:188:12

187func (t *threadSafeSet[T]) SymmetricDifference(other Set[T]) Set[T] {
188 o := other.(*threadSafeSet[T])
189
193:54unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:193:54

192
193 unsafeDifference := t.uss.SymmetricDifference(o.uss).(*threadUnsafeSet[T])
194 ret := &threadSafeSet[T]{uss: unsafeDifference}
200:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:200:28

199
200func (t *threadSafeSet[T]) Clear() {
201 t.Lock()
206:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:206:28

205
206func (t *threadSafeSet[T]) Remove(v T) {
207 t.Lock()
212:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:212:28

211
212func (t *threadSafeSet[T]) RemoveAll(i ...T) {
213 t.Lock()
218:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:218:28

217
218func (t *threadSafeSet[T]) Cardinality() int {
219 t.RLock()
224:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:224:28

223
224func (t *threadSafeSet[T]) Each(cb func(T) bool) {
225 t.RLock()
234:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:234:28

233
234func (t *threadSafeSet[T]) Filter(cb func(T) bool) Set[T] {
235 t.RLock()
246:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:246:28

245
246func (t *threadSafeSet[T]) Iter() <-chan T {
247 ch := make(chan T)
261:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:261:28

260
261func (t *threadSafeSet[T]) Iterator() *Iterator[T] {
262 iterator, ch, stopCh := newIterator[T]()
281:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:281:28

280
281func (t *threadSafeSet[T]) Equal(other Set[T]) bool {
282 o := other.(*threadSafeSet[T])
282:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:282:12

281func (t *threadSafeSet[T]) Equal(other Set[T]) bool {
282 o := other.(*threadSafeSet[T])
283
293:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:293:28

292
293func (t *threadSafeSet[T]) Clone() Set[T] {
294 t.RLock()
296:30unchecked-type-assertionuse the checked two-result form of the type assertion

threadsafe.go:296:30

295
296 unsafeClone := t.uss.Clone().(*threadUnsafeSet[T])
297 ret := &threadSafeSet[T]{uss: unsafeClone}
309:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:309:28

308
309func (t *threadSafeSet[T]) Pop() (T, bool) {
310 t.Lock()
315:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:315:28

314
315func (t *threadSafeSet[T]) PopN(n int) ([]T, int) {
316 t.Lock()
321:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:321:28

320
321func (t *threadSafeSet[T]) ToSlice() []T {
322 t.RLock()
332:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:332:28

331
332func (t *threadSafeSet[T]) MarshalJSON() ([]byte, error) {
333 t.RLock()
340:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:340:28

339
340func (t *threadSafeSet[T]) UnmarshalJSON(p []byte) error {
341 t.Lock()
348:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:348:28

347
348func (t *threadSafeSet[T]) MarshalBSONValue() (bsontype.Type, []byte, error) {
349 t.RLock()
356:28exported-declaration-commentexported function or method should have a comment beginning with its name

threadsafe.go:356:28

355
356func (t *threadSafeSet[T]) UnmarshalBSONValue(bt bsontype.Type, p []byte) error {
357 t.Lock()

threadsafe_test.go101

1:1file-length-limitfile has 805 lines; maximum is 500

threadsafe_test.go:1:1

1/*
2Open Source Initiative OSI - The MIT License (MIT):Licensing
1:1formatfile is not formatted

threadsafe_test.go:1:1

1/*
2Open Source Initiative OSI - The MIT License (MIT):Licensing
  • Fix (safe): run `strider fmt threadsafe_test.go`
26:9package-directory-mismatchpackage mapset does not match directory golang-set

threadsafe_test.go:26:9

25
26package mapset
27
40:7exported-declaration-commentexported declaration should have a comment beginning with its name

threadsafe_test.go:40:7

39
40const N = 1000
41
42:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:42:6

41
42func Test_AddConcurrent(t *testing.T) {
43 runtime.GOMAXPROCS(2)
60:13error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:60:13

59 if !s.Contains(i) {
60 t.Errorf("Set is missing element: %v", i)
61 }
65:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:65:6

64
65func Test_AppendConcurrent(t *testing.T) {
66 runtime.GOMAXPROCS(2)
84:13error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:84:13

83 if !s.Contains(i) {
84 t.Errorf("Set is missing element: %v", i)
85 }
89:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:89:6

88
89func Test_CardinalityConcurrent(t *testing.T) {
90 runtime.GOMAXPROCS(2)
101:14error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:101:14

100 if newElems < elems {
101 t.Errorf("Cardinality shrunk from %v to %v", elems, newElems)
102 }
113:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:113:6

112
113func Test_ClearConcurrent(t *testing.T) {
114 runtime.GOMAXPROCS(2)
113:27unused-parameterparameter t is unused

threadsafe_test.go:113:27

112
113func Test_ClearConcurrent(t *testing.T) {
114 runtime.GOMAXPROCS(2)
134:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:134:6

133
134func Test_CloneConcurrent(t *testing.T) {
135 runtime.GOMAXPROCS(2)
134:27unused-parameterparameter t is unused

threadsafe_test.go:134:27

133
134func Test_CloneConcurrent(t *testing.T) {
135 runtime.GOMAXPROCS(2)
156:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:156:6

155
156func Test_ContainsConcurrent(t *testing.T) {
157 runtime.GOMAXPROCS(2)
156:30unused-parameterparameter t is unused

threadsafe_test.go:156:30

155
156func Test_ContainsConcurrent(t *testing.T) {
157 runtime.GOMAXPROCS(2)
161:2slice-preallocationpreallocate integers with capacity len(range source) before appending once per iteration

threadsafe_test.go:161:2

160 ints := rand.Perm(N)
161 integers := make([]int, 0)
162 for _, v := range ints {
178:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:178:6

177
178func Test_ContainsOneConcurrent(t *testing.T) {
179 runtime.GOMAXPROCS(2)
178:33unused-parameterparameter t is unused

threadsafe_test.go:178:33

177
178func Test_ContainsOneConcurrent(t *testing.T) {
179 runtime.GOMAXPROCS(2)
199:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:199:6

198
199func Test_ContainsAnyConcurrent(t *testing.T) {
200 runtime.GOMAXPROCS(2)
199:33unused-parameterparameter t is unused

threadsafe_test.go:199:33

198
199func Test_ContainsAnyConcurrent(t *testing.T) {
200 runtime.GOMAXPROCS(2)
204:2slice-preallocationpreallocate integers with capacity len(range source) before appending once per iteration

threadsafe_test.go:204:2

203 ints := rand.Perm(N)
204 integers := make([]int, 0)
205 for _, v := range ints {
223:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:223:6

222
223func Test_ContainsAnyElementConcurrent(t *testing.T) {
224 runtime.GOMAXPROCS(2)
223:40unused-parameterparameter t is unused

threadsafe_test.go:223:40

222
223func Test_ContainsAnyElementConcurrent(t *testing.T) {
224 runtime.GOMAXPROCS(2)
244:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:244:6

243
244func Test_DifferenceConcurrent(t *testing.T) {
245 runtime.GOMAXPROCS(2)
244:32unused-parameterparameter t is unused

threadsafe_test.go:244:32

243
244func Test_DifferenceConcurrent(t *testing.T) {
245 runtime.GOMAXPROCS(2)
265:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:265:6

264
265func Test_EqualConcurrent(t *testing.T) {
266 runtime.GOMAXPROCS(2)
265:27unused-parameterparameter t is unused

threadsafe_test.go:265:27

264
265func Test_EqualConcurrent(t *testing.T) {
266 runtime.GOMAXPROCS(2)
286:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:286:6

285
286func Test_IntersectConcurrent(t *testing.T) {
287 runtime.GOMAXPROCS(2)
286:31unused-parameterparameter t is unused

threadsafe_test.go:286:31

285
286func Test_IntersectConcurrent(t *testing.T) {
287 runtime.GOMAXPROCS(2)
307:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:307:6

306
307func Test_IsEmptyConcurrent(t *testing.T) {
308 runtime.GOMAXPROCS(2)
317:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

threadsafe_test.go:317:7

316 size := s.Cardinality()
317 if s.IsEmpty() && size > 0 {
318 t.Errorf("Is Empty should be return false")
318:14error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:318:14

317 if s.IsEmpty() && size > 0 {
318 t.Errorf("Is Empty should be return false")
319 }
330:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:330:6

329
330func Test_IsSubsetConcurrent(t *testing.T) {
331 runtime.GOMAXPROCS(2)
330:30unused-parameterparameter t is unused

threadsafe_test.go:330:30

329
330func Test_IsSubsetConcurrent(t *testing.T) {
331 runtime.GOMAXPROCS(2)
351:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:351:6

350
351func Test_IsProperSubsetConcurrent(t *testing.T) {
352 runtime.GOMAXPROCS(2)
351:36unused-parameterparameter t is unused

threadsafe_test.go:351:36

350
351func Test_IsProperSubsetConcurrent(t *testing.T) {
352 runtime.GOMAXPROCS(2)
372:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:372:6

371
372func Test_IsSupersetConcurrent(t *testing.T) {
373 runtime.GOMAXPROCS(2)
372:32unused-parameterparameter t is unused

threadsafe_test.go:372:32

371
372func Test_IsSupersetConcurrent(t *testing.T) {
373 runtime.GOMAXPROCS(2)
393:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:393:6

392
393func Test_IsProperSupersetConcurrent(t *testing.T) {
394 runtime.GOMAXPROCS(2)
393:38unused-parameterparameter t is unused

threadsafe_test.go:393:38

392
393func Test_IsProperSupersetConcurrent(t *testing.T) {
394 runtime.GOMAXPROCS(2)
414:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:414:6

413
414func Test_EachConcurrent(t *testing.T) {
415 runtime.GOMAXPROCS(2)
443:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:443:6

442
443func Test_FilterConcurrent(t *testing.T) {
444 runtime.GOMAXPROCS(2)
466:15error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:466:15

465 if elem%2 != 0 {
466 t.Errorf("Filter produced odd element %d", elem)
467 }
469:15error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:469:15

468 if !s.Contains(elem) {
469 t.Errorf("Filter produced element %d not in source", elem)
470 }
482:6cognitive-complexityfunction has cognitive complexity 9; maximum is 7

threadsafe_test.go:482:6

481
482func Test_IterConcurrent(t *testing.T) {
483 runtime.GOMAXPROCS(2)
482:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:482:6

481
482func Test_IterConcurrent(t *testing.T) {
483 runtime.GOMAXPROCS(2)
482:26unused-parameterparameter t is unused

threadsafe_test.go:482:26

481
482func Test_IterConcurrent(t *testing.T) {
483 runtime.GOMAXPROCS(2)
491:2slice-preallocationpreallocate cs with capacity len(range source) before appending once per iteration

threadsafe_test.go:491:2

490
491 cs := make([]<-chan int, 0)
492 for range ints {
496:17use-anyuse any instead of interface{}

threadsafe_test.go:496:17

495
496 c := make(chan interface{})
497 go func() {
515:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:515:6

514
515func Test_RemoveConcurrent(t *testing.T) {
516 runtime.GOMAXPROCS(2)
535:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:535:12

534 if s.Cardinality() != 0 {
535 t.Errorf("Expected cardinality 0; got %v", s.Cardinality())
536 }
539:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:539:6

538
539func Test_StringConcurrent(t *testing.T) {
540 runtime.GOMAXPROCS(2)
539:28unused-parameterparameter t is unused

threadsafe_test.go:539:28

538
539func Test_StringConcurrent(t *testing.T) {
540 runtime.GOMAXPROCS(2)
559:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:559:6

558
559func Test_SymmetricDifferenceConcurrent(t *testing.T) {
560 runtime.GOMAXPROCS(2)
559:41unused-parameterparameter t is unused

threadsafe_test.go:559:41

558
559func Test_SymmetricDifferenceConcurrent(t *testing.T) {
560 runtime.GOMAXPROCS(2)
580:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:580:6

579
580func Test_ToSlice(t *testing.T) {
581 runtime.GOMAXPROCS(2)
598:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:598:12

597 if len(setAsSlice) != s.Cardinality() {
598 t.Errorf("Set length is incorrect: %v", len(setAsSlice))
599 }
603:13add-constantstring literal "Set is missing element: %v" appears more than twice; define a constant

threadsafe_test.go:603:13

602 if !s.Contains(i) {
603 t.Errorf("Set is missing element: %v", i)
604 }
603:13error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:603:13

602 if !s.Contains(i) {
603 t.Errorf("Set is missing element: %v", i)
604 }
610:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:610:6

609// This code reveals the deadlock however it doesn't happen consistently.
610func Test_ToSliceDeadlock(t *testing.T) {
611 runtime.GOMAXPROCS(2)
610:27unused-parameterparameter t is unused

threadsafe_test.go:610:27

609// This code reveals the deadlock however it doesn't happen consistently.
610func Test_ToSliceDeadlock(t *testing.T) {
611 runtime.GOMAXPROCS(2)
629:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:629:6

628
629func Test_UnmarshalJSON(t *testing.T) {
630 s := []byte(`["test", "1", "2", "3"]`) //,["4,5,6"]]`)
633:11redundant-conversionconversion from json.Number to the identical type is redundant

threadsafe_test.go:633:11

632 []string{
633 string(json.Number("1")),
634 string(json.Number("2")),
634:11redundant-conversionconversion from json.Number to the identical type is redundant

threadsafe_test.go:634:11

633 string(json.Number("1")),
634 string(json.Number("2")),
635 string(json.Number("3")),
635:11redundant-conversionconversion from json.Number to the identical type is redundant

threadsafe_test.go:635:11

634 string(json.Number("2")),
635 string(json.Number("3")),
636 "test",
643:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:643:12

642 if err != nil {
643 t.Errorf("Error should be nil: %v", err)
644 }
647:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:647:12

646 if !expected.Equal(actual) {
647 t.Errorf("Expected no difference, got: %v", expected.Difference(actual))
648 }
651:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:651:6

650
651func Test_MarshalJSON(t *testing.T) {
652 expected := NewSet(
654:11redundant-conversionconversion from json.Number to the identical type is redundant

threadsafe_test.go:654:11

653 []string{
654 string(json.Number("1")),
655 "test",
662:5add-constantstring literal "1" appears more than twice; define a constant

threadsafe_test.go:662:5

661 []string{
662 "1",
663 "test",
663:5add-constantstring literal "test" appears more than twice; define a constant

threadsafe_test.go:663:5

662 "1",
663 "test",
664 }...,
668:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:668:12

667 if err != nil {
668 t.Errorf("Error should be nil: %v", err)
669 }
674:12add-constantstring literal "Error should be nil: %v" appears more than twice; define a constant

threadsafe_test.go:674:12

673 if err != nil {
674 t.Errorf("Error should be nil: %v", err)
675 }
674:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:674:12

673 if err != nil {
674 t.Errorf("Error should be nil: %v", err)
675 }
678:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:678:12

677 if !expected.Equal(actual) {
678 t.Errorf("Expected no difference, got: %v", expected.Difference(actual))
679 }
685:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:685:6

684// that was called out on issue: https://github.com/deckarep/golang-set/issues/163.
685func Test_DeadlockOnEachCallbackWhenPanic(t *testing.T) {
686 numbers := []int{1, 2, 3, 4}
711:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:711:12

710 if widgets.Cardinality() != 4 {
711 t.Errorf("Expected widgets to have 4 elements, but has %d", card)
712 }
714:2discarded-error-resulterror result returned by doWork is discarded

threadsafe_test.go:714:2

713
714 doWork(widgets)
715
724:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:724:12

723 if widgets.Cardinality() != 5 {
724 t.Errorf("Expected widgets to have 5 elements, but has %d", card)
725 }
728:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:728:6

727
728func Test_UnmarshalBSONValue(t *testing.T) {
729 tp, s, initErr := bson.MarshalValue(
734:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:734:12

733 if initErr != nil {
734 t.Errorf("Init Error should be nil: %v", initErr)
735
740:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:740:12

739 if tp != bson.TypeArray {
740 t.Errorf("Encoded Type should be bson.Array, got: %v", tp)
741
745:26add-constantstring literal "2" appears more than twice; define a constant

threadsafe_test.go:745:26

744
745 expected := NewSet("1", "2", "3", "test")
746 actual := NewSet[string]()
745:31add-constantstring literal "3" appears more than twice; define a constant

threadsafe_test.go:745:31

744
745 expected := NewSet("1", "2", "3", "test")
746 actual := NewSet[string]()
749:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:749:12

748 if err != nil {
749 t.Errorf("Error should be nil: %v", err)
750 }
753:12add-constantstring literal "Expected no difference, got: %v" appears more than twice; define a constant

threadsafe_test.go:753:12

752 if !expected.Equal(actual) {
753 t.Errorf("Expected no difference, got: %v", expected.Difference(actual))
754 }
753:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:753:12

752 if !expected.Equal(actual) {
753 t.Errorf("Expected no difference, got: %v", expected.Difference(actual))
754 }
757:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:757:6

756
757func TestThreadUnsafeSet_UnmarshalBSONValue(t *testing.T) {
758 tp, s, initErr := bson.MarshalValue(
759:10redundant-conversionconversion from int64 to the identical type is redundant

threadsafe_test.go:759:10

758 tp, s, initErr := bson.MarshalValue(
759 bson.A{int64(1), int64(2), int64(3)},
760 )
759:20redundant-conversionconversion from int64 to the identical type is redundant

threadsafe_test.go:759:20

758 tp, s, initErr := bson.MarshalValue(
759 bson.A{int64(1), int64(2), int64(3)},
760 )
759:30redundant-conversionconversion from int64 to the identical type is redundant

threadsafe_test.go:759:30

758 tp, s, initErr := bson.MarshalValue(
759 bson.A{int64(1), int64(2), int64(3)},
760 )
763:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:763:12

762 if initErr != nil {
763 t.Errorf("Init Error should be nil: %v", initErr)
764
769:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:769:12

768 if tp != bson.TypeArray {
769 t.Errorf("Encoded Type should be bson.Array, got: %v", tp)
770
776:51redundant-conversionconversion from []byte to the identical type is redundant

threadsafe_test.go:776:51

775 actual := NewThreadUnsafeSet[int64]()
776 err := actual.UnmarshalBSONValue(bson.TypeArray, []byte(s))
777 if err != nil {
778:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:778:12

777 if err != nil {
778 t.Errorf("Error should be nil: %v", err)
779 }
781:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:781:12

780 if !expected.Equal(actual) {
781 t.Errorf("Expected no difference, got: %v", expected.Difference(actual))
782 }
785:6test-parallelismconsider calling t.Parallel() when this test begins

threadsafe_test.go:785:6

784
785func Test_MarshalBSONValue(t *testing.T) {
786 expected := NewSet("1", "test")
792:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:792:12

791 if err != nil {
792 t.Errorf("Error should be nil: %v", err)
793 }
798:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:798:12

797 if err != nil {
798 t.Errorf("Error should be nil: %v", err)
799 }
802:12error-stringserror string should not be capitalized or end with punctuation

threadsafe_test.go:802:12

801 if !expected.Equal(actual) {
802 t.Errorf("Expected no difference, got: %v", expected.Difference(actual))
803 }

threadunsafe.go58

1:1formatfile is not formatted

threadunsafe.go:1:1

1/*
2Open Source Initiative OSI - The MIT License (MIT):Licensing
  • Fix (safe): run `strider fmt threadunsafe.go`
26:9package-commentspackage should have a documentation comment

threadunsafe.go:26:9

25
26package mapset
27
26:9package-directory-mismatchpackage mapset does not match directory golang-set

threadunsafe.go:26:9

25
26package mapset
27
37:42nested-structsmove nested anonymous struct types to named declarations

threadunsafe.go:37:42

36
37type threadUnsafeSet[T comparable] map[T]struct{}
38
40:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

threadunsafe.go:40:1

39// Assert concrete type:threadUnsafeSet adheres to Set interface.
40var _ Set[string] = (*threadUnsafeSet[string])(nil)
41
52:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:52:30

51
52func (s *threadUnsafeSet[T]) Add(v T) bool {
53 prevLen := s.Cardinality()
59:30confusing-namingname add differs from Add only by capitalization

threadunsafe.go:59:30

58// private version of Add which doesn't return a value
59func (s *threadUnsafeSet[T]) add(v T) {
60 (*s)[v] = struct{}{}
60:12nested-structsmove nested anonymous struct types to named declarations

threadunsafe.go:60:12

59func (s *threadUnsafeSet[T]) add(v T) {
60 (*s)[v] = struct{}{}
61}
63:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:63:30

62
63func (s *threadUnsafeSet[T]) Append(vs ...T) int {
64 prevLen := s.Cardinality()
70:30confusing-namingname append differs from Append only by capitalization

threadunsafe.go:70:30

69// private version of Append which doesn't return a value
70func (s *threadUnsafeSet[T]) append(vs ...T) {
71 for i := range vs {
76:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:76:30

75
76func (s *threadUnsafeSet[T]) AppendFrom(other Set[T]) int {
77 o := other.(*threadUnsafeSet[T])
77:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadunsafe.go:77:12

76func (s *threadUnsafeSet[T]) AppendFrom(other Set[T]) int {
77 o := other.(*threadUnsafeSet[T])
78
86:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:86:30

85
86func (s *threadUnsafeSet[T]) Cardinality() int {
87 return len(*s)
90:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:90:30

89
90func (s *threadUnsafeSet[T]) Clear() {
91 // Constructions like this are optimised by compiler, and replaced by
99:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:99:30

98
99func (s *threadUnsafeSet[T]) Clone() Set[T] {
100 t := threadUnsafeSet[T](mapclone(*s))
104:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:104:30

103
104func (s *threadUnsafeSet[T]) Contains(v ...T) bool {
105 for _, val := range v {
113:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:113:30

112
113func (s *threadUnsafeSet[T]) ContainsOne(v T) bool {
114 return s.contains(v)
117:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:117:30

116
117func (s *threadUnsafeSet[T]) ContainsAny(v ...T) bool {
118 for _, val := range v {
126:30cognitive-complexityfunction has cognitive complexity 11; maximum is 7

threadunsafe.go:126:30

125
126func (s *threadUnsafeSet[T]) ContainsAnyElement(other Set[T]) bool {
127 o := other.(*threadUnsafeSet[T])
126:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:126:30

125
126func (s *threadUnsafeSet[T]) ContainsAnyElement(other Set[T]) bool {
127 o := other.(*threadUnsafeSet[T])
127:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadunsafe.go:127:12

126func (s *threadUnsafeSet[T]) ContainsAnyElement(other Set[T]) bool {
127 o := other.(*threadUnsafeSet[T])
128
147:30confusing-namingname contains differs from Contains only by capitalization

threadunsafe.go:147:30

146// private version of Contains for a single element v
147func (s *threadUnsafeSet[T]) contains(v T) (ok bool) {
148 _, found := (*s)[v]
152:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:152:30

151
152func (s *threadUnsafeSet[T]) Difference(other Set[T]) Set[T] {
153 o := other.(*threadUnsafeSet[T])
153:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadunsafe.go:153:12

152func (s *threadUnsafeSet[T]) Difference(other Set[T]) Set[T] {
153 o := other.(*threadUnsafeSet[T])
154
164:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:164:30

163
164func (s *threadUnsafeSet[T]) Each(cb func(T) bool) {
165 for elem := range *s {
172:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:172:30

171
172func (s *threadUnsafeSet[T]) Filter(cb func(T) bool) Set[T] {
173 mappedSet := newThreadUnsafeSetWithSize[T](s.Cardinality())
182:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:182:30

181
182func (s *threadUnsafeSet[T]) Equal(other Set[T]) bool {
183 o := other.(*threadUnsafeSet[T])
183:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadunsafe.go:183:12

182func (s *threadUnsafeSet[T]) Equal(other Set[T]) bool {
183 o := other.(*threadUnsafeSet[T])
184
196:30cognitive-complexityfunction has cognitive complexity 11; maximum is 7

threadunsafe.go:196:30

195
196func (s *threadUnsafeSet[T]) Intersect(other Set[T]) Set[T] {
197 o := other.(*threadUnsafeSet[T])
196:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:196:30

195
196func (s *threadUnsafeSet[T]) Intersect(other Set[T]) Set[T] {
197 o := other.(*threadUnsafeSet[T])
197:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadunsafe.go:197:12

196func (s *threadUnsafeSet[T]) Intersect(other Set[T]) Set[T] {
197 o := other.(*threadUnsafeSet[T])
198
219:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:219:30

218
219func (s *threadUnsafeSet[T]) IsEmpty() bool {
220 return s.Cardinality() == 0
223:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:223:30

222
223func (s *threadUnsafeSet[T]) IsProperSubset(other Set[T]) bool {
224 return s.Cardinality() < other.Cardinality() && s.IsSubset(other)
224:9optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

threadunsafe.go:224:9

223func (s *threadUnsafeSet[T]) IsProperSubset(other Set[T]) bool {
224 return s.Cardinality() < other.Cardinality() && s.IsSubset(other)
225}
227:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:227:30

226
227func (s *threadUnsafeSet[T]) IsProperSuperset(other Set[T]) bool {
228 return s.Cardinality() > other.Cardinality() && s.IsSuperset(other)
228:9optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

threadunsafe.go:228:9

227func (s *threadUnsafeSet[T]) IsProperSuperset(other Set[T]) bool {
228 return s.Cardinality() > other.Cardinality() && s.IsSuperset(other)
229}
231:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:231:30

230
231func (s *threadUnsafeSet[T]) IsSubset(other Set[T]) bool {
232 o := other.(*threadUnsafeSet[T])
232:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadunsafe.go:232:12

231func (s *threadUnsafeSet[T]) IsSubset(other Set[T]) bool {
232 o := other.(*threadUnsafeSet[T])
233 if s.Cardinality() > other.Cardinality() {
244:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:244:30

243
244func (s *threadUnsafeSet[T]) IsSuperset(other Set[T]) bool {
245 return other.IsSubset(s)
248:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:248:30

247
248func (s *threadUnsafeSet[T]) Iter() <-chan T {
249 ch := make(chan T)
260:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:260:30

259
260func (s *threadUnsafeSet[T]) Iterator() *Iterator[T] {
261 iterator, ch, stopCh := newIterator[T]()
278:1doc-comment-perioddocumentation comment should end with punctuation

threadunsafe.go:278:1

277
278// Pop returns a popped item in case set is not empty, or nil-value of T
279// if set is already empty
280:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:280:30

279// if set is already empty
280func (s *threadUnsafeSet[T]) Pop() (v T, ok bool) {
281 for item := range *s {
288:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:288:30

287
288func (s *threadUnsafeSet[T]) PopN(n int) (items []T, count int) {
289 if n <= 0 || len(*s) == 0 {
294:3modifies-parameterassignment modifies parameter n

threadunsafe.go:294:3

293 if n > sn {
294 n = sn
295 }
309:29exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:309:29

308
309func (s threadUnsafeSet[T]) Remove(v T) {
310 delete(s, v)
313:29exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:313:29

312
313func (s threadUnsafeSet[T]) RemoveAll(i ...T) {
314 for _, elem := range i {
328:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:328:30

327
328func (s *threadUnsafeSet[T]) SymmetricDifference(other Set[T]) Set[T] {
329 o := other.(*threadUnsafeSet[T])
329:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadunsafe.go:329:12

328func (s *threadUnsafeSet[T]) SymmetricDifference(other Set[T]) Set[T] {
329 o := other.(*threadUnsafeSet[T])
330
347:29exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:347:29

346
347func (s threadUnsafeSet[T]) ToSlice() []T {
348 keys := make([]T, 0, s.Cardinality())
356:29exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:356:29

355
356func (s threadUnsafeSet[T]) Union(other Set[T]) Set[T] {
357 o := other.(*threadUnsafeSet[T])
357:12unchecked-type-assertionuse the checked two-result form of the type assertion

threadunsafe.go:357:12

356func (s threadUnsafeSet[T]) Union(other Set[T]) Set[T] {
357 o := other.(*threadUnsafeSet[T])
358
372:1doc-comment-perioddocumentation comment should end with punctuation

threadunsafe.go:372:1

371
372// MarshalJSON creates a JSON array from the set, it marshals all elements
373func (s threadUnsafeSet[T]) MarshalJSON() ([]byte, error) {
379:7marshal-receivermarshal and unmarshal methods should use a consistent receiver type

threadunsafe.go:379:7

378// primitive types. Numbers are decoded as json.Number.
379func (s *threadUnsafeSet[T]) UnmarshalJSON(b []byte) error {
380 var i []T
379:30exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:379:30

378// primitive types. Numbers are decoded as json.Number.
379func (s *threadUnsafeSet[T]) UnmarshalJSON(b []byte) error {
380 var i []T
391:29exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:391:29

390// MarshalBSON creates a BSON array from the set.
391func (s threadUnsafeSet[T]) MarshalBSONValue() (bsontype.Type, []byte, error) {
392 return bson.MarshalValue(s.ToSlice())
396:29exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe.go:396:29

395// UnmarshalBSON recreates a set from a BSON array.
396func (s threadUnsafeSet[T]) UnmarshalBSONValue(bt bsontype.Type, b []byte) error {
397 if bt != bson.TypeArray {
398:10use-errors-newreplace fmt.Errorf with errors.New for a static message

threadunsafe.go:398:10

397 if bt != bson.TypeArray {
398 return fmt.Errorf("must use BSON Array to unmarshal Set")
399 }

threadunsafe_test.go36

1:1formatfile is not formatted

threadunsafe_test.go:1:1

1/*
2Open Source Initiative OSI - The MIT License (MIT):Licensing
  • Fix (safe): run `strider fmt threadunsafe_test.go`
26:9package-directory-mismatchpackage mapset does not match directory golang-set

threadunsafe_test.go:26:9

25
26package mapset
27
33:6test-parallelismconsider calling t.Parallel() when this test begins

threadunsafe_test.go:33:6

32
33func TestThreadUnsafeSet_MarshalJSON(t *testing.T) {
34 expected := NewThreadUnsafeSet[int64](1, 2, 3)
40:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:40:12

39 if err != nil {
40 t.Errorf("Error should be nil: %v", err)
41 }
45:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:45:12

44 if err != nil {
45 t.Errorf("Error should be nil: %v", err)
46 }
49:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:49:12

48 if !expected.Equal(actual) {
49 t.Errorf("Expected no difference, got: %v", expected.Difference(actual))
50 }
55:12add-constantstring literal "Error should be nil: %v" appears more than twice; define a constant

threadunsafe_test.go:55:12

54 if err != nil {
55 t.Errorf("Error should be nil: %v", err)
56 }
55:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:55:12

54 if err != nil {
55 t.Errorf("Error should be nil: %v", err)
56 }
60:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:60:12

59 if err != nil {
60 t.Errorf("Error should be nil: %v", err)
61 }
64:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:64:12

63 if !expected.Equal(actual) {
64 t.Errorf("Expected no difference, got: %v", expected.Difference(actual))
65 }
68:6test-parallelismconsider calling t.Parallel() when this test begins

threadunsafe_test.go:68:6

67
68func TestThreadUnsafeSet_UnmarshalJSON(t *testing.T) {
69 expected := NewThreadUnsafeSet[int64](1, 2, 3)
75:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:75:12

74 if err != nil {
75 t.Errorf("Error should be nil: %v", err)
76 }
78:12add-constantstring literal "Expected no difference, got: %v" appears more than twice; define a constant

threadunsafe_test.go:78:12

77 if !expected.Equal(actual) {
78 t.Errorf("Expected no difference, got: %v", expected.Difference(actual))
79 }
78:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:78:12

77 if !expected.Equal(actual) {
78 t.Errorf("Expected no difference, got: %v", expected.Difference(actual))
79 }
85:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:85:12

84 if err != nil {
85 t.Errorf("Error should be nil: %v", err)
86 }
88:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:88:12

87 if !expected.Equal(actual) {
88 t.Errorf("Expected no difference, got: %v", expected.Difference(actual))
89 }
92:6test-parallelismconsider calling t.Parallel() when this test begins

threadunsafe_test.go:92:6

91
92func TestThreadUnsafeSet_MarshalJSON_Struct(t *testing.T) {
93 expected := &testStruct{"test", NewThreadUnsafeSet("a")}
97:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:97:12

96 if err != nil {
97 t.Errorf("Error should be nil: %v", err)
98 }
103:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:103:12

102 if err != nil {
103 t.Errorf("Error should be nil: %v", err)
104 }
107:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:107:12

106 if !expected.Set.Equal(actual.Set) {
107 t.Errorf("Expected no difference, got: %v", expected.Set.Difference(actual.Set))
108 }
110:6test-parallelismconsider calling t.Parallel() when this test begins

threadunsafe_test.go:110:6

109}
110func TestThreadUnsafeSet_UnmarshalJSON_Struct(t *testing.T) {
111 expected := &testStruct{"test", NewThreadUnsafeSet("a", "b", "c")}
111:26add-constantstring literal "test" appears more than twice; define a constant

threadunsafe_test.go:111:26

110func TestThreadUnsafeSet_UnmarshalJSON_Struct(t *testing.T) {
111 expected := &testStruct{"test", NewThreadUnsafeSet("a", "b", "c")}
112 actual := &testStruct{}
111:53add-constantstring literal "a" appears more than twice; define a constant

threadunsafe_test.go:111:53

110func TestThreadUnsafeSet_UnmarshalJSON_Struct(t *testing.T) {
111 expected := &testStruct{"test", NewThreadUnsafeSet("a", "b", "c")}
112 actual := &testStruct{}
116:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:116:12

115 if err != nil {
116 t.Errorf("Error should be nil: %v", err)
117 }
119:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:119:12

118 if !expected.Set.Equal(actual.Set) {
119 t.Errorf("Expected no difference, got: %v", expected.Set.Difference(actual.Set))
120 }
122:40nested-structsmove nested anonymous struct types to named declarations

threadunsafe_test.go:122:40

121
122 expectedComplex := NewThreadUnsafeSet(struct{ Val string }{Val: "a"}, struct{ Val string }{Val: "b"})
123 actualComplex := NewThreadUnsafeSet[struct{ Val string }]()
122:72nested-structsmove nested anonymous struct types to named declarations

threadunsafe_test.go:122:72

121
122 expectedComplex := NewThreadUnsafeSet(struct{ Val string }{Val: "a"}, struct{ Val string }{Val: "b"})
123 actualComplex := NewThreadUnsafeSet[struct{ Val string }]()
123:38nested-structsmove nested anonymous struct types to named declarations

threadunsafe_test.go:123:38

122 expectedComplex := NewThreadUnsafeSet(struct{ Val string }{Val: "a"}, struct{ Val string }{Val: "b"})
123 actualComplex := NewThreadUnsafeSet[struct{ Val string }]()
124
127:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:127:12

126 if err != nil {
127 t.Errorf("Error should be nil: %v", err)
128 }
130:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:130:12

129 if !expectedComplex.Equal(actualComplex) {
130 t.Errorf("Expected no difference, got: %v", expectedComplex.Difference(actualComplex))
131 }
133:37nested-structsmove nested anonymous struct types to named declarations

threadunsafe_test.go:133:37

132
133 actualComplex = NewThreadUnsafeSet[struct{ Val string }]()
134 err = json.Unmarshal([]byte(`[{"Val": "a"}, {"Val": "b"}]`), actualComplex)
136:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:136:12

135 if err != nil {
136 t.Errorf("Error should be nil: %v", err)
137 }
139:12error-stringserror string should not be capitalized or end with punctuation

threadunsafe_test.go:139:12

138 if !expectedComplex.Equal(actualComplex) {
139 t.Errorf("Expected no difference, got: %v", expectedComplex.Difference(actualComplex))
140 }
144:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

threadunsafe_test.go:144:1

143// this serves as an example of how to correctly unmarshal a struct with a Set property
144type testStruct struct {
145 Other string
149:22exported-declaration-commentexported function or method should have a comment beginning with its name

threadunsafe_test.go:149:22

148
149func (t *testStruct) UnmarshalJSON(b []byte) error {
150 raw := struct {
150:9nested-structsmove nested anonymous struct types to named declarations

threadunsafe_test.go:150:9

149func (t *testStruct) UnmarshalJSON(b []byte) error {
150 raw := struct {
151 Other string