34 msformat174 mscheck 656total 89errors 256warnings 311notes

copier.go103

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

copier.go:1:1

1package copier
2
1:1formatfile is not formatted

copier.go:1:1

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

copier.go:1:9

1package copier
2
13:1doc-comment-perioddocumentation comment should end with punctuation

copier.go:13:1

12
13// These flags define options for tag handling
14const (
31:2doc-comment-perioddocumentation comment should end with punctuation

copier.go:31:2

30
31 // Some default converter types for a nicer syntax
32 String string = ""
32:2exported-declaration-commentexported declaration should have a comment beginning with its name

copier.go:32:2

31 // Some default converter types for a nicer syntax
32 String string = ""
33 Bool bool = false
33:2exported-declaration-commentexported declaration should have a comment beginning with its name

copier.go:33:2

32 String string = ""
33 Bool bool = false
34 Int int = 0
34:2exported-declaration-commentexported declaration should have a comment beginning with its name

copier.go:34:2

33 Bool bool = false
34 Int int = 0
35 Float32 float32 = 0
35:2exported-declaration-commentexported declaration should have a comment beginning with its name

copier.go:35:2

34 Int int = 0
35 Float32 float32 = 0
36 Float64 float64 = 0
36:2exported-declaration-commentexported declaration should have a comment beginning with its name

copier.go:36:2

35 Float32 float32 = 0
36 Float64 float64 = 0
37)
39:1doc-comment-perioddocumentation comment should end with punctuation

copier.go:39:1

38
39// Option sets copy options
40type Option struct {
57:19confusing-namingname converters differs from Converters only by capitalization

copier.go:57:19

56
57func (opt Option) converters() map[converterPair]TypeConverter {
58 var converters = map[converterPair]TypeConverter{}
73:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

copier.go:73:1

72
73type TypeConverter struct {
74 SrcType interface{}
73:6exported-declaration-commentexported type should have a comment beginning with its name

copier.go:73:6

72
73type TypeConverter struct {
74 SrcType interface{}
74:10use-anyuse any instead of interface{}

copier.go:74:10

73type TypeConverter struct {
74 SrcType interface{}
75 DstType interface{}
75:10use-anyuse any instead of interface{}

copier.go:75:10

74 SrcType interface{}
75 DstType interface{}
76 Fn func(src interface{}) (dst interface{}, err error)
76:19use-anyuse any instead of interface{}

copier.go:76:19

75 DstType interface{}
76 Fn func(src interface{}) (dst interface{}, err error)
77}
76:37use-anyuse any instead of interface{}

copier.go:76:37

75 DstType interface{}
76 Fn func(src interface{}) (dst interface{}, err error)
77}
84:19confusing-namingname fieldNameMapping differs from FieldNameMapping only by capitalization

copier.go:84:19

83
84func (opt Option) fieldNameMapping() map[converterPair]FieldNameMapping {
85 var mapping = map[converterPair]FieldNameMapping{}
99:6exported-declaration-commentexported type should have a comment beginning with its name

copier.go:99:6

98
99type FieldNameMapping struct {
100 SrcType interface{}
100:10use-anyuse any instead of interface{}

copier.go:100:10

99type FieldNameMapping struct {
100 SrcType interface{}
101 DstType interface{}
101:10use-anyuse any instead of interface{}

copier.go:101:10

100 SrcType interface{}
101 DstType interface{}
102 Mapping map[string]string
118:1doc-comment-perioddocumentation comment should end with punctuation

copier.go:118:1

117
118// Copy copy things
119func Copy(toValue interface{}, fromValue interface{}) (err error) {
119:19use-anyuse any instead of interface{}

copier.go:119:19

118// Copy copy things
119func Copy(toValue interface{}, fromValue interface{}) (err error) {
120 return copier(toValue, fromValue, Option{})
119:42use-anyuse any instead of interface{}

copier.go:119:42

118// Copy copy things
119func Copy(toValue interface{}, fromValue interface{}) (err error) {
120 return copier(toValue, fromValue, Option{})
123:1doc-comment-perioddocumentation comment should end with punctuation

copier.go:123:1

122
123// CopyWithOption copy with option
124func CopyWithOption(toValue interface{}, fromValue interface{}, opt Option) (err error) {
124:29use-anyuse any instead of interface{}

copier.go:124:29

123// CopyWithOption copy with option
124func CopyWithOption(toValue interface{}, fromValue interface{}, opt Option) (err error) {
125 return copier(toValue, fromValue, opt)
124:52use-anyuse any instead of interface{}

copier.go:124:52

123// CopyWithOption copy with option
124func CopyWithOption(toValue interface{}, fromValue interface{}, opt Option) (err error) {
125 return copier(toValue, fromValue, opt)
128:6cognitive-complexityfunction has cognitive complexity 297; maximum is 7

copier.go:128:6

127
128func copier(toValue interface{}, fromValue interface{}, opt Option) (err error) {
129 var (
128:6cyclomatic-complexityfunction complexity is 100; maximum is 10

copier.go:128:6

127
128func copier(toValue interface{}, fromValue interface{}, opt Option) (err error) {
129 var (
128:6function-lengthfunction has 186 statements and 348 lines; maximum is 50 statements or 75 lines

copier.go:128:6

127
128func copier(toValue interface{}, fromValue interface{}, opt Option) (err error) {
129 var (
128:21use-anyuse any instead of interface{}

copier.go:128:21

127
128func copier(toValue interface{}, fromValue interface{}, opt Option) (err error) {
129 var (
128:44use-anyuse any instead of interface{}

copier.go:128:44

127
128func copier(toValue interface{}, fromValue interface{}, opt Option) (err error) {
129 var (
164:5optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier.go:164:5

163 // Just set it if possible to assign for normal types
164 if from.Kind() != reflect.Slice && from.Kind() != reflect.Struct && from.Kind() != reflect.Map && (from.Type().AssignableTo(to.Type()) || from.Type().ConvertibleTo(to.Type())) {
165 if !isPtrFrom || !opt.DeepCopy {
172:3no-naked-returnreturn values must be explicit

copier.go:172:3

171 }
172 return
173 }
175:5optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier.go:175:5

174
175 if from.Kind() != reflect.Slice && fromType.Kind() == reflect.Map && toType.Kind() == reflect.Map {
176 if !fromType.Key().ConvertibleTo(toType.Key()) {
215:5modifies-parameterassignment modifies parameter toValue

copier.go:215:5

214 elemType = reflect.PtrTo(elemType)
215 toValue = toValue.Addr()
216 }
218:3no-naked-returnreturn values must be explicit

copier.go:218:3

217 }
218 return
219 }
224:4no-naked-returnreturn values must be explicit

copier.go:224:4

223 if from.IsNil() && to.IsNil() {
224 return
225 }
252:4no-naked-returnreturn values must be explicit

copier.go:252:4

251
252 return
253 }
258:3no-naked-returnreturn values must be explicit

copier.go:258:3

257 // skip not supported type
258 return
259 }
262:56optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier.go:262:56

261 if len(converters) > 0 {
262 if ok, e := set(to, from, opt.DeepCopy, converters); e == nil && ok {
263 // converter supported
264:4no-naked-returnreturn values must be explicit

copier.go:264:4

263 // converter supported
264 return
265 }
293:61optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier.go:293:61

292 if len(converters) > 0 {
293 if ok, e := set(dest, source, opt.DeepCopy, converters); e == nil && ok {
294 if isSlice {
295:6task-commentFIXME comment should be resolved or linked to an owned work item

copier.go:295:6

294 if isSlice {
295 // FIXME: maybe should check the other types?
296 if to.Type().Elem().Kind() == reflect.Ptr {
299:7max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:299:7

298 } else {
299 if to.Len() < i+1 {
300 reflect.Append(to, dest)
352:7max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:352:7

351 // only initialize parent embedded struct pointer in the path
352 for idx := range f.Index[:len(f.Index)-1] {
353 destField := dest.FieldByIndex(f.Index[:idx+1])
355:8max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:355:8

354
355 if destField.Kind() != reflect.Ptr {
356 continue
359:8max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:359:8

358
359 if !destField.IsNil() {
360 continue
362:8max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:362:8

361 }
362 if !destField.CanSet() {
363 destFieldNotSet = true
379:7max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:379:7

378 if toField.IsValid() {
379 if toField.CanSet() {
380 isSet, err := set(toField, fromField, opt.DeepCopy, converters)
381:8max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:381:8

380 isSet, err := set(toField, fromField, opt.DeepCopy, converters)
381 if err != nil {
382 return err
384:8max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:384:8

383 }
384 if !isSet {
385 if err := copier(toField.Addr().Interface(), fromField.Interface(), opt); err != nil {
385:9max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:385:9

384 if !isSet {
385 if err := copier(toField.Addr().Interface(), fromField.Interface(), opt); err != nil {
386 return err
389:8max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:389:8

388 }
389 if fieldFlags != 0 {
390 // Note that a copy was made
397:7max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:397:7

396 var toMethod reflect.Value
397 if dest.CanAddr() {
398 toMethod = dest.Addr().MethodByName(destFieldName)
403:7max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:403:7

402
403 if toMethod.IsValid() && toMethod.Type().NumIn() == 1 && fromField.Type().AssignableTo(toMethod.Type().In(0)) {
404 toMethod.Call([]reflect.Value{fromField})
422:8optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier.go:422:8

421
422 if fromMethod.IsValid() && fromMethod.Type().NumIn() == 0 && fromMethod.Type().NumOut() == 1 && !shouldIgnore(fromMethod, flgs.BitFlags[name], opt.IgnoreEmpty) {
423 if toField := fieldByName(dest, destFieldName, opt.CaseSensitive); toField.IsValid() && toField.CanSet() {
422:8optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier.go:422:8

421
422 if fromMethod.IsValid() && fromMethod.Type().NumIn() == 0 && fromMethod.Type().NumOut() == 1 && !shouldIgnore(fromMethod, flgs.BitFlags[name], opt.IgnoreEmpty) {
423 if toField := fieldByName(dest, destFieldName, opt.CaseSensitive); toField.IsValid() && toField.CanSet() {
425:7max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:425:7

424 values := fromMethod.Call([]reflect.Value{})
425 if len(values) >= 1 {
426 set(toField, values[0], opt.DeepCopy, converters)
426:8discarded-error-resulterror result returned by set is discarded

copier.go:426:8

425 if len(values) >= 1 {
426 set(toField, values[0], opt.DeepCopy, converters)
427 }
445:7max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:445:7

444 err = copier(to.Index(i).Addr().Interface(), dest.Addr().Interface(), opt)
445 if err != nil {
446 continue
455:6max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:455:6

454 isSet, err := set(to.Index(i), dest, opt.DeepCopy, converters)
455 if err != nil {
456 return err
458:6max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:458:6

457 }
458 if !isSet {
459 // ignore error while copy slice element
461:7max-control-nestingcontrol-flow nesting exceeds 5 levels

copier.go:461:7

460 err = copier(to.Index(i).Addr().Interface(), dest.Interface(), opt)
461 if err != nil {
462 continue
474:2no-naked-returnreturn values must be explicit

copier.go:474:2

473
474 return
475}
524:5no-package-varpackage variables introduce mutable global state

copier.go:524:5

523
524var deepFieldsLock sync.RWMutex
525var deepFieldsMap = make(map[reflect.Type][]reflect.StructField)
525:5no-package-varpackage variables introduce mutable global state

copier.go:525:5

524var deepFieldsLock sync.RWMutex
525var deepFieldsMap = make(map[reflect.Type][]reflect.StructField)
526
527:6cognitive-complexityfunction has cognitive complexity 11; maximum is 7

copier.go:527:6

526
527func deepFields(reflectType reflect.Type) []reflect.StructField {
528 deepFieldsLock.RLock()
535:5modifies-parameterassignment modifies parameter reflectType

copier.go:535:5

534 var res []reflect.StructField
535 if reflectType, _ = indirectType(reflectType); reflectType.Kind() == reflect.Struct {
536 fields := make([]reflect.StructField, 0, reflectType.NumField())
562:3modifies-parameterassignment modifies parameter reflectValue

copier.go:562:3

561 for reflectValue.Kind() == reflect.Ptr {
562 reflectValue = reflectValue.Elem()
563 }
569:3modifies-parameterassignment modifies parameter reflectType

copier.go:569:3

568 for reflectType.Kind() == reflect.Ptr || reflectType.Kind() == reflect.Slice {
569 reflectType = reflectType.Elem()
570 isPtr = true
575:6cognitive-complexityfunction has cognitive complexity 57; maximum is 7

copier.go:575:6

574
575func set(to, from reflect.Value, deepCopy bool, converters map[converterPair]TypeConverter) (bool, error) {
576 if !from.IsValid() {
575:6cyclomatic-complexityfunction complexity is 35; maximum is 10

copier.go:575:6

574
575func set(to, from reflect.Value, deepCopy bool, converters map[converterPair]TypeConverter) (bool, error) {
576 if !from.IsValid() {
575:6function-lengthfunction has 58 statements and 113 lines; maximum is 50 statements or 75 lines

copier.go:575:6

574
575func set(to, from reflect.Value, deepCopy bool, converters map[converterPair]TypeConverter) (bool, error) {
576 if !from.IsValid() {
575:34flag-parameterboolean parameter deepCopy controls function flow

copier.go:575:34

574
575func set(to, from reflect.Value, deepCopy bool, converters map[converterPair]TypeConverter) (bool, error) {
576 if !from.IsValid() {
581:4no-else-after-returnremove else and unindent its body after the return

copier.go:581:4

580 return false, err
581 } else if ok {
582 return true, nil
587:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier.go:587:6

586 // set `to` to nil if from is nil
587 if from.Kind() == reflect.Ptr && from.IsNil() {
588 to.Set(reflect.Zero(to.Type()))
590:5no-else-after-returnremove else and unindent its body after the return

copier.go:590:5

589 return true, nil
590 } else if to.IsNil() {
591 // `from` -> `to`
596:6nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

copier.go:596:6

595 if err != nil {
596 return true, nil
597 }
605:13optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier.go:605:13

604 to.Set(reflect.New(to.Type().Elem()))
605 } else if from.Kind() != reflect.Ptr && from.IsZero() {
606 to.Set(reflect.Zero(to.Type()))
610:3modifies-parameterassignment modifies parameter to

copier.go:610:3

609 // depointer `to`
610 to = to.Elem()
611 }
621:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier.go:621:6

620 }
621 if from.Kind() == reflect.Ptr && from.IsNil() {
622 to.Set(reflect.Zero(to.Type()))
625:60optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier.go:625:60

624 }
625 if _, ok := to.Addr().Interface().(sql.Scanner); !ok && (toKind == reflect.Struct || toKind == reflect.Map || toKind == reflect.Slice) {
626 return false, nil
646:4modifies-parameterassignment modifies parameter from

copier.go:646:4

645 // depointer `from`
646 from = indirect(from)
647 }
663:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

copier.go:663:4

662 if err != nil {
663 return false, nil
664 }
718:3single-case-switchswitch with one case can be replaced by an if statement

copier.go:718:3

717 for _, t := range strings.Split(tag, ",") {
718 switch t {
719 case "-":
721:4no-naked-returnreturn values must be explicit

copier.go:721:4

720 flg = tagIgnore
721 return
722 case "must":
736:2no-naked-returnreturn values must be explicit

copier.go:736:2

735 }
736 return
737}
740:6cognitive-complexityfunction has cognitive complexity 26; maximum is 7

copier.go:740:6

739// getTagFlags Parses struct tags for bit flags, field name.
740func getFlags(dest, src reflect.Value, toType, fromType reflect.Type, opt Option) (flags, error) {
741 flgs := flags{
740:6cyclomatic-complexityfunction complexity is 13; maximum is 10

copier.go:740:6

739// getTagFlags Parses struct tags for bit flags, field name.
740func getFlags(dest, src reflect.Value, toType, fromType reflect.Type, opt Option) (flags, error) {
741 flgs := flags{
772:6no-else-after-returnremove else and unindent its body after the return

copier.go:772:6

771 return flags{}, err
772 } else if name != "" {
773 flgs.DestNames.FieldNameToTag[field.Name] = name
796:6no-else-after-returnremove else and unindent its body after the return

copier.go:796:6

795 return flags{}, err
796 } else if name != "" {
797 flgs.SrcNames.FieldNameToTag[field.Name] = name
811:4single-case-switchswitch with one case can be replaced by an if statement

copier.go:811:4

810 if flgs&hasCopied == 0 {
811 switch {
812 case flgs&tagMust != 0 && flgs&tagNoPanic != 0:
814:5no-naked-returnreturn values must be explicit

copier.go:814:5

813 err = fmt.Errorf("field %s has must tag but was not copied", name)
814 return
815 case flgs&(tagMust) != 0:
820:2no-naked-returnreturn values must be explicit

copier.go:820:2

819 }
820 return
821}
823:6cognitive-complexityfunction has cognitive complexity 13; maximum is 7

copier.go:823:6

822
823func getFieldName(fieldName string, flgs flags, fieldNameMapping map[string]string) (srcFieldName string, destFieldName string) {
824 // get dest field name
828:3no-naked-returnreturn values must be explicit

copier.go:828:3

827 destFieldName = name
828 return
829 }
860:2no-naked-returnreturn values must be explicit

copier.go:860:2

859 }
860 return
861}
866:3no-naked-returnreturn values must be explicit

copier.go:866:3

865 i, ok = v.Interface().(driver.Valuer)
866 return
867 }
870:2no-naked-returnreturn values must be explicit

copier.go:870:2

869 i, ok = v.Addr().Interface().(driver.Valuer)
870 return
871}
873:6cognitive-complexityfunction has cognitive complexity 9; maximum is 7

copier.go:873:6

872
873func fieldByName(v reflect.Value, name string, caseSensitive bool) reflect.Value {
874 if caseSensitive {
873:48flag-parameterboolean parameter caseSensitive controls function flow

copier.go:873:48

872
873func fieldByName(v reflect.Value, name string, caseSensitive bool) reflect.Value {
874 if caseSensitive {

copier_benchmark_test.go10

1:1formatfile is not formatted

copier_benchmark_test.go:1:1

1package copier_test
2
  • Fix (safe): run `strider fmt copier_benchmark_test.go`
14:3discarded-error-resulterror result returned by copier.Copy is discarded

copier_benchmark_test.go:14:3

13 for x := 0; x < b.N; x++ {
14 copier.Copy(&Employee{}, &user)
15 }
31:44range-value-addresstaking the address of range value note can be misleading

copier_benchmark_test.go:31:44

30 for _, note := range user.Notes {
31 employee.Notes = append(employee.Notes, &note)
32 }
39:21add-constantstring literal "Jinzhu" appears more than twice; define a constant

copier_benchmark_test.go:39:21

38 var fakeAge int32 = 12
39 user := User{Name: "Jinzhu", Nickname: "jinzhu", Age: 18, FakeAge: &fakeAge, Role: "Admin", Notes: []string{"hello world", "welcome"}, flags: []byte{'x'}}
40 for x := 0; x < b.N; x++ {
39:41add-constantstring literal "jinzhu" appears more than twice; define a constant

copier_benchmark_test.go:39:41

38 var fakeAge int32 = 12
39 user := User{Name: "Jinzhu", Nickname: "jinzhu", Age: 18, FakeAge: &fakeAge, Role: "Admin", Notes: []string{"hello world", "welcome"}, flags: []byte{'x'}}
40 for x := 0; x < b.N; x++ {
39:85add-constantstring literal "Admin" appears more than twice; define a constant

copier_benchmark_test.go:39:85

38 var fakeAge int32 = 12
39 user := User{Name: "Jinzhu", Nickname: "jinzhu", Age: 18, FakeAge: &fakeAge, Role: "Admin", Notes: []string{"hello world", "welcome"}, flags: []byte{'x'}}
40 for x := 0; x < b.N; x++ {
39:110add-constantstring literal "hello world" appears more than twice; define a constant

copier_benchmark_test.go:39:110

38 var fakeAge int32 = 12
39 user := User{Name: "Jinzhu", Nickname: "jinzhu", Age: 18, FakeAge: &fakeAge, Role: "Admin", Notes: []string{"hello world", "welcome"}, flags: []byte{'x'}}
40 for x := 0; x < b.N; x++ {
39:125add-constantstring literal "welcome" appears more than twice; define a constant

copier_benchmark_test.go:39:125

38 var fakeAge int32 = 12
39 user := User{Name: "Jinzhu", Nickname: "jinzhu", Age: 18, FakeAge: &fakeAge, Role: "Admin", Notes: []string{"hello world", "welcome"}, flags: []byte{'x'}}
40 for x := 0; x < b.N; x++ {
41:14discarded-error-resulterror result returned by json.Marshal is discarded

copier_benchmark_test.go:41:14

40 for x := 0; x < b.N; x++ {
41 data, _ := json.Marshal(user)
42 var employee Employee
43:3discarded-error-resulterror result returned by json.Unmarshal is discarded

copier_benchmark_test.go:43:3

42 var employee Employee
43 json.Unmarshal(data, &employee)
44

copier_case_insensitive_test.go22

1:1formatfile is not formatted

copier_case_insensitive_test.go:1:1

1package copier
2
  • Fix (safe): run `strider fmt copier_case_insensitive_test.go`
7:1doc-comment-perioddocumentation comment should end with punctuation

copier_case_insensitive_test.go:7:1

6
7// Test case for issue where case-insensitive field matching
8// fails when there are both exported and unexported fields with similar names
9:6test-parallelismconsider calling t.Parallel() when this test begins

copier_case_insensitive_test.go:9:6

8// fails when there are both exported and unexported fields with similar names
9func TestCaseInsensitiveFieldMatching(t *testing.T) {
10 // Simulate protobuf generated struct with both unexported 'state' and exported 'State' fields
11:7exported-declaration-commentexported type should have a comment beginning with its name

copier_case_insensitive_test.go:11:7

10 // Simulate protobuf generated struct with both unexported 'state' and exported 'State' fields
11 type ProtoStruct struct {
12 state uint32
14:3confusing-namingname State differs from state only by capitalization

copier_case_insensitive_test.go:14:3

13 PageNumber int32 `json:"pageNumber"`
14 State int32 `json:"state"`
15 }
17:7exported-declaration-commentexported type should have a comment beginning with its name

copier_case_insensitive_test.go:17:7

16
17 type SourceStruct struct {
18 PageNumber int32 `json:"pageNumber"`
36:12error-stringserror string should not be capitalized or end with punctuation

copier_case_insensitive_test.go:36:12

35 if dest.State != source.State {
36 t.Errorf("State field not copied correctly. Expected: %d, Got: %d", source.State, dest.State)
37 }
44:12error-stringserror string should not be capitalized or end with punctuation

copier_case_insensitive_test.go:44:12

43 if dest.PageNumber != source.PageNumber {
44 t.Errorf("PageNumber field not copied correctly. Expected: %d, Got: %d", source.PageNumber, dest.PageNumber)
45 }
48:1doc-comment-perioddocumentation comment should end with punctuation

copier_case_insensitive_test.go:48:1

47
48// Test that exact case matching still works
49func TestExactCaseMatching(t *testing.T) {
49:6test-parallelismconsider calling t.Parallel() when this test begins

copier_case_insensitive_test.go:49:6

48// Test that exact case matching still works
49func TestExactCaseMatching(t *testing.T) {
50 type Source struct {
50:7exported-declaration-commentexported type should have a comment beginning with its name

copier_case_insensitive_test.go:50:7

49func TestExactCaseMatching(t *testing.T) {
50 type Source struct {
51 Name string
55:7exported-declaration-commentexported type should have a comment beginning with its name

copier_case_insensitive_test.go:55:7

54
55 type Dest struct {
56 Name string
69:12error-stringserror string should not be capitalized or end with punctuation

copier_case_insensitive_test.go:69:12

68 if dest.Name != source.Name || dest.Age != source.Age {
69 t.Errorf("Fields not copied correctly. Expected: %+v, Got: %+v", source, *dest)
70 }
73:6test-parallelismconsider calling t.Parallel() when this test begins

copier_case_insensitive_test.go:73:6

72
73func TestCaseInsensitiveMatchingWithEmbeddedField(t *testing.T) {
74 type Embedded struct {
74:7exported-declaration-commentexported type should have a comment beginning with its name

copier_case_insensitive_test.go:74:7

73func TestCaseInsensitiveMatchingWithEmbeddedField(t *testing.T) {
74 type Embedded struct {
75 Name string
78:7exported-declaration-commentexported type should have a comment beginning with its name

copier_case_insensitive_test.go:78:7

77
78 type Dest struct {
79 name string
78:7max-public-structsfile declares more than 5 exported structs

copier_case_insensitive_test.go:78:7

77
78 type Dest struct {
79 name string
79:3confusing-namingname name differs from Name only by capitalization

copier_case_insensitive_test.go:79:3

78 type Dest struct {
79 name string
80 Embedded
83:7exported-declaration-commentexported type should have a comment beginning with its name

copier_case_insensitive_test.go:83:7

82
83 type Source struct {
84 NAME string
83:7max-public-structsfile declares more than 5 exported structs

copier_case_insensitive_test.go:83:7

82
83 type Source struct {
84 NAME string
84:3confusing-namingname NAME differs from Name only by capitalization

copier_case_insensitive_test.go:84:3

83 type Source struct {
84 NAME string
85 }
97:12add-constantstring literal "Copy failed: %v" appears more than twice; define a constant

copier_case_insensitive_test.go:97:12

96 if err != nil {
97 t.Fatalf("Copy failed: %v", err)
98 }

copier_converter_test.go47

1:1formatfile is not formatted

copier_converter_test.go:1:1

1package copier_test
2
  • Fix (safe): run `strider fmt copier_converter_test.go`
16:6function-lengthfunction has 26 statements and 81 lines; maximum is 50 statements or 75 lines

copier_converter_test.go:16:6

15
16func TestCopyWithTypeConverters(t *testing.T) {
17 type SrcStruct struct {
16:6test-parallelismconsider calling t.Parallel() when this test begins

copier_converter_test.go:16:6

15
16func TestCopyWithTypeConverters(t *testing.T) {
17 type SrcStruct struct {
17:7exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:17:7

16func TestCopyWithTypeConverters(t *testing.T) {
17 type SrcStruct struct {
18 Field1 time.Time
24:7exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:24:7

23
24 type DestStruct struct {
25 Field1 string
49:18use-anyuse any instead of interface{}

copier_converter_test.go:49:18

48 DstType: copier.String,
49 Fn: func(src interface{}) (interface{}, error) {
50 s, ok := src.(time.Time)
49:32use-anyuse any instead of interface{}

copier_converter_test.go:49:32

48 DstType: copier.String,
49 Fn: func(src interface{}) (interface{}, error) {
50 s, ok := src.(time.Time)
62:18use-anyuse any instead of interface{}

copier_converter_test.go:62:18

61 DstType: copier.Int,
62 Fn: func(src interface{}) (interface{}, error) {
63 s, ok := src.(string)
62:32use-anyuse any instead of interface{}

copier_converter_test.go:62:32

61 DstType: copier.Int,
62 Fn: func(src interface{}) (interface{}, error) {
63 s, ok := src.(string)
90:12add-constantstring literal "got %q, wanted %q" appears more than twice; define a constant

copier_converter_test.go:90:12

89 if dst.Field3 != "" {
90 t.Fatalf("got %q, wanted %q", dst.Field3, "")
91 }
98:6test-parallelismconsider calling t.Parallel() when this test begins

copier_converter_test.go:98:6

97
98func TestCopyWithConverterAndAnnotation(t *testing.T) {
99 type SrcStruct struct {
99:7exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:99:7

98func TestCopyWithConverterAndAnnotation(t *testing.T) {
99 type SrcStruct struct {
100 Field1 string
103:7exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:103:7

102
103 type DestStruct struct {
104 Field1 string
121:18use-anyuse any instead of interface{}

copier_converter_test.go:121:18

120 DstType: copier.String,
121 Fn: func(src interface{}) (interface{}, error) {
122 s, ok := src.(string)
121:32use-anyuse any instead of interface{}

copier_converter_test.go:121:32

120 DstType: copier.String,
121 Fn: func(src interface{}) (interface{}, error) {
122 s, ok := src.(string)
125:30add-constantstring literal "src type not matching" appears more than twice; define a constant

copier_converter_test.go:125:30

124 if !ok {
125 return nil, errors.New("src type not matching")
126 }
143:6test-parallelismconsider calling t.Parallel() when this test begins

copier_converter_test.go:143:6

142
143func TestCopyWithConverterStrToStrPointer(t *testing.T) {
144 type SrcStruct struct {
144:7exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:144:7

143func TestCopyWithConverterStrToStrPointer(t *testing.T) {
144 type SrcStruct struct {
145 Field1 string
148:7exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:148:7

147
148 type DestStruct struct {
149 Field1 *string
148:7max-public-structsfile declares more than 5 exported structs

copier_converter_test.go:148:7

147
148 type DestStruct struct {
149 Field1 *string
167:18use-anyuse any instead of interface{}

copier_converter_test.go:167:18

166 DstType: &ptrStrType,
167 Fn: func(src interface{}) (interface{}, error) {
168 s, _ := src.(string)
167:32use-anyuse any instead of interface{}

copier_converter_test.go:167:32

166 DstType: &ptrStrType,
167 Fn: func(src interface{}) (interface{}, error) {
168 s, _ := src.(string)
172:7nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

copier_converter_test.go:172:7

171 if s == "" {
172 return nil, nil
173 }
181:12add-constantstring literal `Should be able to copy from src to dst object. %v` appears more than twice; define a constant

copier_converter_test.go:181:12

180 if err != nil {
181 t.Fatalf(`Should be able to copy from src to dst object. %v`, err)
182 return
190:6test-parallelismconsider calling t.Parallel() when this test begins

copier_converter_test.go:190:6

189
190func TestCopyWithConverterRaisingError(t *testing.T) {
191 type SrcStruct struct {
191:7exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:191:7

190func TestCopyWithConverterRaisingError(t *testing.T) {
191 type SrcStruct struct {
192 Field1 string
191:7max-public-structsfile declares more than 5 exported structs

copier_converter_test.go:191:7

190func TestCopyWithConverterRaisingError(t *testing.T) {
191 type SrcStruct struct {
192 Field1 string
195:7exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:195:7

194
195 type DestStruct struct {
196 Field1 *string
195:7max-public-structsfile declares more than 5 exported structs

copier_converter_test.go:195:7

194
195 type DestStruct struct {
196 Field1 *string
214:18use-anyuse any instead of interface{}

copier_converter_test.go:214:18

213 DstType: &ptrStrType,
214 Fn: func(src interface{}) (interface{}, error) {
215 return nil, errors.New("src type not matching")
214:32use-anyuse any instead of interface{}

copier_converter_test.go:214:32

213 DstType: &ptrStrType,
214 Fn: func(src interface{}) (interface{}, error) {
215 return nil, errors.New("src type not matching")
226:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

copier_converter_test.go:226:1

225
226type IntArray []int
227
226:6exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:226:6

225
226type IntArray []int
227
228:19exported-declaration-commentexported function or method should have a comment beginning with its name

copier_converter_test.go:228:19

227
228func (a IntArray) Value() (driver.Value, error) {
229 return json.Marshal(a)
232:6exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:232:6

231
232type Int int
233
234:6exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:234:6

233
234type From struct {
235 Data IntArray
234:6max-public-structsfile declares more than 5 exported structs

copier_converter_test.go:234:6

233
234type From struct {
235 Data IntArray
238:6exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:238:6

237
238type To struct {
239 Data []byte
238:6max-public-structsfile declares more than 5 exported structs

copier_converter_test.go:238:6

237
238type To struct {
239 Data []byte
242:6exported-declaration-commentexported type should have a comment beginning with its name

copier_converter_test.go:242:6

241
242type FailedTo struct {
243 Data []Int
242:6max-public-structsfile declares more than 5 exported structs

copier_converter_test.go:242:6

241
242type FailedTo struct {
243 Data []Int
246:6cyclomatic-complexityfunction complexity is 11; maximum is 10

copier_converter_test.go:246:6

245
246func TestValuerConv(t *testing.T) {
247 // when the field of struct implement driver.Valuer and cannot convert to dest type directly,
246:6test-parallelismconsider calling t.Parallel() when this test begins

copier_converter_test.go:246:6

245
246func TestValuerConv(t *testing.T) {
247 // when the field of struct implement driver.Valuer and cannot convert to dest type directly,
253:5optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_converter_test.go:253:5

252
253 if typ1 == typ2 || typ1.ConvertibleTo(typ2) || typ1.AssignableTo(typ2) {
254 // in 1.22 and older, u can not convert typ1 to typ2
278:5optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_converter_test.go:278:5

277 // Testcase2: fallback case when valuer conv failed
278 if len(failedTo.Data) != 3 || failedTo.Data[0] != 1 || failedTo.Data[1] != 2 || failedTo.Data[2] != 3 {
279 t.Errorf("copier failed from %#v to %#v", from, failedTo)
278:5optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_converter_test.go:278:5

277 // Testcase2: fallback case when valuer conv failed
278 if len(failedTo.Data) != 3 || failedTo.Data[0] != 1 || failedTo.Data[1] != 2 || failedTo.Data[2] != 3 {
279 t.Errorf("copier failed from %#v to %#v", from, failedTo)
278:5optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_converter_test.go:278:5

277 // Testcase2: fallback case when valuer conv failed
278 if len(failedTo.Data) != 3 || failedTo.Data[0] != 1 || failedTo.Data[1] != 2 || failedTo.Data[2] != 3 {
279 t.Errorf("copier failed from %#v to %#v", from, failedTo)

copier_different_type_test.go33

1:1formatfile is not formatted

copier_different_type_test.go:1:1

1package copier_test
2
  • Fix (safe): run `strider fmt copier_different_type_test.go`
11:6exported-declaration-commentexported type should have a comment beginning with its name

copier_different_type_test.go:11:6

10
11type TypeStruct1 struct {
12 Field1 string
23:6exported-declaration-commentexported type should have a comment beginning with its name

copier_different_type_test.go:23:6

22
23type TypeStruct2 struct {
24 Field1 int
32:6exported-declaration-commentexported type should have a comment beginning with its name

copier_different_type_test.go:32:6

31
32type TypeStruct3 struct {
33 Field1 interface{}
33:9use-anyuse any instead of interface{}

copier_different_type_test.go:33:9

32type TypeStruct3 struct {
33 Field1 interface{}
34 Field2 string
43:6exported-declaration-commentexported type should have a comment beginning with its name

copier_different_type_test.go:43:6

42
43type TypeStruct4 struct {
44 field1 int
48:23exported-declaration-commentexported function or method should have a comment beginning with its name

copier_different_type_test.go:48:23

47
48func (t *TypeStruct4) Field1(i int) {
49 t.field1 = i
52:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

copier_different_type_test.go:52:1

51
52type TypeBaseStruct5 struct {
53 A bool
52:6exported-declaration-commentexported type should have a comment beginning with its name

copier_different_type_test.go:52:6

51
52type TypeBaseStruct5 struct {
53 A bool
63:6exported-declaration-commentexported type should have a comment beginning with its name

copier_different_type_test.go:63:6

62
63type TypeSqlNullStruct6 struct {
64 A sql.NullBool `json:"a"`
63:6max-public-structsfile declares more than 5 exported structs

copier_different_type_test.go:63:6

62
63type TypeSqlNullStruct6 struct {
64 A sql.NullBool `json:"a"`
74:6test-parallelismconsider calling t.Parallel() when this test begins

copier_different_type_test.go:74:6

73
74func TestCopyDifferentFieldType(t *testing.T) {
75 ts := &TypeStruct1{
81:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_different_type_test.go:81:2

80
81 copier.Copy(ts2, ts)
82
84:12error-stringserror string should not be capitalized or end with punctuation

copier_different_type_test.go:84:12

83 if ts2.Field2 != ts.Field2 || ts2.Field1 != 0 {
84 t.Errorf("Should be able to copy from ts to ts2")
85 }
88:6test-parallelismconsider calling t.Parallel() when this test begins

copier_different_type_test.go:88:6

87
88func TestCopyDifferentTypeMethod(t *testing.T) {
89 ts := &TypeStruct1{
95:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_different_type_test.go:95:2

94
95 copier.Copy(ts4, ts)
96
98:12error-stringserror string should not be capitalized or end with punctuation

copier_different_type_test.go:98:12

97 if ts4.Field2 != ts.Field2 || ts4.field1 != 0 {
98 t.Errorf("Should be able to copy from ts to ts4")
99 }
102:6cognitive-complexityfunction has cognitive complexity 9; maximum is 7

copier_different_type_test.go:102:6

101
102func TestAssignableType(t *testing.T) {
103 ts := &TypeStruct1{
102:6test-parallelismconsider calling t.Parallel() when this test begins

copier_different_type_test.go:102:6

101
102func TestAssignableType(t *testing.T) {
103 ts := &TypeStruct1{
104:11add-constantstring literal "str1" appears more than twice; define a constant

copier_different_type_test.go:104:11

103 ts := &TypeStruct1{
104 Field1: "str1",
105 Field2: "str2",
105:11add-constantstring literal "str2" appears more than twice; define a constant

copier_different_type_test.go:105:11

104 Field1: "str1",
105 Field2: "str2",
106 Field3: TypeStruct2{
136:2discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_different_type_test.go:136:2

135
136 copier.CopyWithOption(&ts3, &ts, copier.Option{CaseSensitive: true})
137
145:12error-stringserror string should not be capitalized or end with punctuation

copier_different_type_test.go:145:12

144 if ts3.Field2 != ts.Field2 {
145 t.Errorf("Field2 should be copied")
146 }
178:6cognitive-complexityfunction has cognitive complexity 9; maximum is 7

copier_different_type_test.go:178:6

177
178func TestCopyFromBaseToSqlNullWithOptionDeepCopy(t *testing.T) {
179 a := TypeBaseStruct5{
178:6cyclomatic-complexityfunction complexity is 18; maximum is 10

copier_different_type_test.go:178:6

177
178func TestCopyFromBaseToSqlNullWithOptionDeepCopy(t *testing.T) {
179 a := TypeBaseStruct5{
178:6test-parallelismconsider calling t.Parallel() when this test begins

copier_different_type_test.go:178:6

177
178func TestCopyFromBaseToSqlNullWithOptionDeepCopy(t *testing.T) {
179 a := TypeBaseStruct5{
181:6redundant-conversionconversion from byte to the identical type is redundant

copier_different_type_test.go:181:6

180 A: true,
181 B: byte(2),
182 C: 5.5,
194:12error-stringserror string should not be capitalized or end with punctuation

copier_different_type_test.go:194:12

193 if err != nil {
194 t.Errorf("CopyStructWithOption() error = %v", err)
195 return
198:19boolean-literal-comparisonomit the boolean literal from the logical expression

copier_different_type_test.go:198:19

197 // ę£€ęŸ„ b ē»“ęž„ä½“ēš„å­—ę®µę˜Æå¦ē¬¦åˆé¢„ęœŸ
198 if !b.A.Valid || b.A.Bool != true {
199 t.Errorf("b.A = %v, want %v", b.A, true)
201:31redundant-conversionconversion from byte to the identical type is redundant

copier_different_type_test.go:201:31

200 }
201 if !b.B.Valid || b.B.Byte != byte(2) {
202 t.Errorf("b.B = %v, want %v", b.B, byte(2))
202:38redundant-conversionconversion from byte to the identical type is redundant

copier_different_type_test.go:202:38

201 if !b.B.Valid || b.B.Byte != byte(2) {
202 t.Errorf("b.B = %v, want %v", b.B, byte(2))
203 }
216:19time-value-equalitycompare time.Time values with Time.Equal instead of == or !=

copier_different_type_test.go:216:19

215 }
216 if !b.G.Valid || b.G.Time != a.G {
217 t.Errorf("b.G = %v, want %v", b.G, a.G)
220:38add-constantstring literal "deep" appears more than twice; define a constant

copier_different_type_test.go:220:38

219 if !b.H.Valid || b.H.String != "deep" {
220 t.Errorf("b.H = %v, want %v", b.H, "deep")
221 }

copier_field_name_mapping_test.go4

1:1formatfile is not formatted

copier_field_name_mapping_test.go:1:1

1package copier_test
2
  • Fix (safe): run `strider fmt copier_field_name_mapping_test.go`
9:6test-parallelismconsider calling t.Parallel() when this test begins

copier_field_name_mapping_test.go:9:6

8
9func TestCustomFieldName(t *testing.T) {
10 type User1 struct {
10:7exported-declaration-commentexported type should have a comment beginning with its name

copier_field_name_mapping_test.go:10:7

9func TestCustomFieldName(t *testing.T) {
10 type User1 struct {
11 Id int64
16:7exported-declaration-commentexported type should have a comment beginning with its name

copier_field_name_mapping_test.go:16:7

15
16 type User2 struct {
17 Id2 int64

copier_issue170_test.go15

1:1formatfile is not formatted

copier_issue170_test.go:1:1

1package copier_test
2
  • Fix (safe): run `strider fmt copier_issue170_test.go`
9:6exported-declaration-commentexported type should have a comment beginning with its name

copier_issue170_test.go:9:6

8
9type A struct {
10 A int
12:6exported-declaration-commentexported type should have a comment beginning with its name

copier_issue170_test.go:12:6

11}
12type B struct {
13 A int
17:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

copier_issue170_test.go:17:1

16
17var copied = B{A: 2387483274, b: 128387134}
18
17:5no-package-varpackage variables introduce mutable global state

copier_issue170_test.go:17:5

16
17var copied = B{A: 2387483274, b: 128387134}
18
25:19use-anyuse any instead of interface{}

copier_issue170_test.go:25:19

24 DstType: B{},
25 Fn: func(from interface{}) (interface{}, error) {
26 return copied, nil
25:33use-anyuse any instead of interface{}

copier_issue170_test.go:25:33

24 DstType: B{},
25 Fn: func(from interface{}) (interface{}, error) {
26 return copied, nil
33:6test-parallelismconsider calling t.Parallel() when this test begins

copier_issue170_test.go:33:6

32
33func Test_Struct_With_Converter(t *testing.T) {
34 aa := A{A: 11}
42:6test-parallelismconsider calling t.Parallel() when this test begins

copier_issue170_test.go:42:6

41
42func Test_Map_With_Converter(t *testing.T) {
43 aa := map[string]*A{
64:6test-parallelismconsider calling t.Parallel() when this test begins

copier_issue170_test.go:64:6

63
64func Test_Slice_With_Converter(t *testing.T) {
65 aa := []*A{
83:13add-constantstring literal "Got %v, wanted %v" appears more than twice; define a constant

copier_issue170_test.go:83:13

82 if !reflect.DeepEqual(*temp, wanted) {
83 t.Fatalf("Got %v, wanted %v", *temp, wanted)
84 }
88:6test-parallelismconsider calling t.Parallel() when this test begins

copier_issue170_test.go:88:6

87
88func Test_Slice_Embedded_With_Converter(t *testing.T) {
89 aa := struct {
89:8nested-structsmove nested anonymous struct types to named declarations

copier_issue170_test.go:89:8

88func Test_Slice_Embedded_With_Converter(t *testing.T) {
89 aa := struct {
90 A []*A
95:8nested-structsmove nested anonymous struct types to named declarations

copier_issue170_test.go:95:8

94
95 bb := struct {
96 A []*B
103:12nested-structsmove nested anonymous struct types to named declarations

copier_issue170_test.go:103:12

102
103 wanted := struct {
104 A []*B

copier_issue84_test.go11

1:1formatfile is not formatted

copier_issue84_test.go:1:1

1package copier_test
2
  • Fix (safe): run `strider fmt copier_issue84_test.go`
10:6exported-declaration-commentexported type should have a comment beginning with its name

copier_issue84_test.go:10:6

9
10type Embedded struct {
11 Field1 string
15:6exported-declaration-commentexported type should have a comment beginning with its name

copier_issue84_test.go:15:6

14
15type Embedder struct {
16 Embedded
20:6exported-declaration-commentexported type should have a comment beginning with its name

copier_issue84_test.go:20:6

19
20type Timestamps struct {
21 CreatedAt time.Time `json:"created_at"`
25:6exported-declaration-commentexported type should have a comment beginning with its name

copier_issue84_test.go:25:6

24
25type NotWork struct {
26 ID string `json:"id"`
33:6exported-declaration-commentexported type should have a comment beginning with its name

copier_issue84_test.go:33:6

32
33type Work struct {
34 ID string `json:"id"`
41:6test-parallelismconsider calling t.Parallel() when this test begins

copier_issue84_test.go:41:6

40
41func TestIssue84(t *testing.T) {
42 t.Run("test1", func(t *testing.T) {
42:17test-parallelismconsider calling t.Parallel() when this subtest begins

copier_issue84_test.go:42:17

41func TestIssue84(t *testing.T) {
42 t.Run("test1", func(t *testing.T) {
43 var embedder Embedder
59:22test-parallelismconsider calling t.Parallel() when this subtest begins

copier_issue84_test.go:59:22

58 })
59 t.Run("from issue", func(t *testing.T) {
60 notWorkObj := NotWork{
82:3discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_issue84_test.go:82:3

81
82 copier.CopyWithOption(&destObj1, &workObj, copier.Option{IgnoreEmpty: true, DeepCopy: false})
83
84:3discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_issue84_test.go:84:3

83
84 copier.CopyWithOption(&destObj2, &notWorkObj, copier.Option{IgnoreEmpty: true, DeepCopy: false})
85 })

copier_tags_test.go40

1:1formatfile is not formatted

copier_tags_test.go:1:1

1package copier_test
2
  • Fix (safe): run `strider fmt copier_tags_test.go`
9:6exported-declaration-commentexported type should have a comment beginning with its name

copier_tags_test.go:9:6

8
9type EmployeeTags struct {
10 Name string `copier:"must"`
16:6exported-declaration-commentexported type should have a comment beginning with its name

copier_tags_test.go:16:6

15
16type EmployeeTags2 struct {
17 Name string `copier:"must,nopanic"`
23:6exported-declaration-commentexported type should have a comment beginning with its name

copier_tags_test.go:23:6

22
23type EmployeeTags3 struct {
24 Name string
30:6exported-declaration-commentexported type should have a comment beginning with its name

copier_tags_test.go:30:6

29
30type User1 struct {
31 Name string
37:6exported-declaration-commentexported type should have a comment beginning with its name

copier_tags_test.go:37:6

36
37type User2 struct {
38 DOB string
43:6test-parallelismconsider calling t.Parallel() when this test begins

copier_tags_test.go:43:6

42
43func TestCopyTagIgnore(t *testing.T) {
44 employee := EmployeeTags{ID: 100}
46:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_tags_test.go:46:2

45 user := User1{Name: "Dexter Ledesma", DOB: "1 November, 1970", Address: "21 Jump Street", ID: 12345}
46 copier.Copy(&employee, user)
47 if employee.ID == user.ID {
55:6test-parallelismconsider calling t.Parallel() when this test begins

copier_tags_test.go:55:6

54
55func TestCopyTagMust(t *testing.T) {
56 employee := &EmployeeTags{}
63:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_tags_test.go:63:2

62 }()
63 copier.Copy(employee, user)
64}
66:6test-parallelismconsider calling t.Parallel() when this test begins

copier_tags_test.go:66:6

65
66func TestCopyTagMustByOption(t *testing.T) {
67 employee := &EmployeeTags3{}
69:24test-parallelismconsider calling t.Parallel() when this subtest begins

copier_tags_test.go:69:24

68 user := &User2{DOB: "1 January 1970"}
69 t.Run("must is true", func(t *testing.T) {
70 defer func() {
75:3discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_tags_test.go:75:3

74 }()
75 copier.CopyWithOption(employee, user, copier.Option{Must: true})
76 })
78:25test-parallelismconsider calling t.Parallel() when this subtest begins

copier_tags_test.go:78:25

77
78 t.Run("must is false", func(t *testing.T) {
79 defer func() {
84:3discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_tags_test.go:84:3

83 }()
84 copier.CopyWithOption(employee, user, copier.Option{Must: false})
85 })
88:6test-parallelismconsider calling t.Parallel() when this test begins

copier_tags_test.go:88:6

87
88func TestCopyTagMustAndNoPanic(t *testing.T) {
89 employee := &EmployeeTags2{}
90:22add-constantstring literal "1 January 1970" appears more than twice; define a constant

copier_tags_test.go:90:22

89 employee := &EmployeeTags2{}
90 user := &User2{DOB: "1 January 1970"}
91 err := copier.Copy(employee, user)
97:6test-parallelismconsider calling t.Parallel() when this test begins

copier_tags_test.go:97:6

96
97func TestCopyTagMustAndNoPanicByOption(t *testing.T) {
98 employee := &EmployeeTags3{}
106:6test-parallelismconsider calling t.Parallel() when this test begins

copier_tags_test.go:106:6

105
106func TestCopyTagOverrideZeroValue(t *testing.T) {
107 options := copier.Option{IgnoreEmpty: true}
111:2discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_tags_test.go:111:2

110
111 copier.CopyWithOption(&user, employee, options)
112 if user.Address != "" {
117:6test-parallelismconsider calling t.Parallel() when this test begins

copier_tags_test.go:117:6

116
117func TestCopyTagOverridePtrToZeroValue(t *testing.T) {
118 options := copier.Option{IgnoreEmpty: true}
119:13add-constantstring literal "21 Jump Street" appears more than twice; define a constant

copier_tags_test.go:119:13

118 options := copier.Option{IgnoreEmpty: true}
119 address := "21 Jump Street"
120 user1 := User1{ID: 100, Address: ""}
121:22add-constantstring literal "1 November, 1970" appears more than twice; define a constant

copier_tags_test.go:121:22

120 user1 := User1{ID: 100, Address: ""}
121 user2 := User2{DOB: "1 November, 1970", Address: &address, ID: 12345}
122
123:2discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_tags_test.go:123:2

122
123 copier.CopyWithOption(&user2, user1, options)
124 if user2.Address != nil {
129:6test-parallelismconsider calling t.Parallel() when this test begins

copier_tags_test.go:129:6

128
129func TestCopyTagOverrideZeroValueToPtr(t *testing.T) {
130 options := copier.Option{IgnoreEmpty: true}
134:2discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_tags_test.go:134:2

133
134 copier.CopyWithOption(&user2, user1, options)
135 if user1.Address != nil {
136:11add-constantstring literal "Original Address was not overwritten" appears more than twice; define a constant

copier_tags_test.go:136:11

135 if user1.Address != nil {
136 t.Error("Original Address was not overwritten")
137 }
140:6test-parallelismconsider calling t.Parallel() when this test begins

copier_tags_test.go:140:6

139
140func TestCopyTagOverridePtr(t *testing.T) {
141 options := copier.Option{IgnoreEmpty: true}
146:2discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_tags_test.go:146:2

145
146 copier.CopyWithOption(&user, user2, options)
147 if user.Address != nil {
152:6test-parallelismconsider calling t.Parallel() when this test begins

copier_tags_test.go:152:6

151
152func TestCopyTagFieldName(t *testing.T) {
153 t.Run("another name field copy", func(t *testing.T) {
153:35test-parallelismconsider calling t.Parallel() when this subtest begins

copier_tags_test.go:153:35

152func TestCopyTagFieldName(t *testing.T) {
153 t.Run("another name field copy", func(t *testing.T) {
154 type SrcTags struct {
154:8exported-declaration-commentexported type should have a comment beginning with its name

copier_tags_test.go:154:8

153 t.Run("another name field copy", func(t *testing.T) {
154 type SrcTags struct {
155 FieldA string
154:8max-public-structsfile declares more than 5 exported structs

copier_tags_test.go:154:8

153 t.Run("another name field copy", func(t *testing.T) {
154 type SrcTags struct {
155 FieldA string
160:8exported-declaration-commentexported type should have a comment beginning with its name

copier_tags_test.go:160:8

159
160 type DestTags struct {
161 Field1 string `copier:"FieldA"`
160:8max-public-structsfile declares more than 5 exported structs

copier_tags_test.go:160:8

159
160 type DestTags struct {
161 Field1 string `copier:"FieldA"`
188:36test-parallelismconsider calling t.Parallel() when this subtest begins

copier_tags_test.go:188:36

187
188 t.Run("validate error flag name", func(t *testing.T) {
189 type SrcTags struct {
189:8exported-declaration-commentexported type should have a comment beginning with its name

copier_tags_test.go:189:8

188 t.Run("validate error flag name", func(t *testing.T) {
189 type SrcTags struct {
190 field string
189:8max-public-structsfile declares more than 5 exported structs

copier_tags_test.go:189:8

188 t.Run("validate error flag name", func(t *testing.T) {
189 type SrcTags struct {
190 field string
193:8exported-declaration-commentexported type should have a comment beginning with its name

copier_tags_test.go:193:8

192
193 type DestTags struct {
194 Field1 string `copier:"field"`
193:8max-public-structsfile declares more than 5 exported structs

copier_tags_test.go:193:8

192
193 type DestTags struct {
194 Field1 string `copier:"field"`

copier_test.go360

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

copier_test.go:1:1

1package copier_test
2
1:1formatfile is not formatted

copier_test.go:1:1

1package copier_test
2
  • Fix (safe): run `strider fmt copier_test.go`
14:6exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:14:6

13
14type User struct {
15 Name string
25:18exported-declaration-commentexported function or method should have a comment beginning with its name

copier_test.go:25:18

24
25func (user User) DoubleAge() int32 {
26 return 2 * user.Age
29:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

copier_test.go:29:1

28
29type Employee struct {
30 _User *User
29:6exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:29:6

28
29type Employee struct {
30 _User *User
30:2unexported-namingunexported identifier should not begin with an underscore

copier_test.go:30:2

29type Employee struct {
30 _User *User
31 Name string
30:2var-namingidentifier should use MixedCaps rather than underscores

copier_test.go:30:2

29type Employee struct {
30 _User *User
31 Name string
43:27exported-declaration-commentexported function or method should have a comment beginning with its name

copier_test.go:43:27

42
43func (employee *Employee) Role(role string) {
44 employee.SuperRule = "Super " + role
47:6cognitive-complexityfunction has cognitive complexity 13; maximum is 7

copier_test.go:47:6

46
47func checkEmployee(employee Employee, user User, t *testing.T, testCase string) {
48 if employee.Name != user.Name {
47:6cyclomatic-complexityfunction complexity is 19; maximum is 10

copier_test.go:47:6

46
47func checkEmployee(employee Employee, user User, t *testing.T, testCase string) {
48 if employee.Name != user.Name {
49:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:49:12

48 if employee.Name != user.Name {
49 t.Errorf("%v: Name haven't been copied correctly.", testCase)
50 }
52:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:52:12

51 if employee.NickName == nil || *employee.NickName != user.Nickname {
52 t.Errorf("%v: NickName haven't been copied correctly.", testCase)
53 }
55:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:55:12

54 if employee.Birthday == nil && user.Birthday != nil {
55 t.Errorf("%v: Birthday haven't been copied correctly.", testCase)
56 }
58:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:58:12

57 if employee.Birthday != nil && user.Birthday == nil {
58 t.Errorf("%v: Birthday haven't been copied correctly.", testCase)
59 }
62:12add-constantstring literal "%v: Birthday haven't been copied correctly." appears more than twice; define a constant

copier_test.go:62:12

61 !employee.Birthday.Equal(*(user.Birthday)) {
62 t.Errorf("%v: Birthday haven't been copied correctly.", testCase)
63 }
62:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:62:12

61 !employee.Birthday.Equal(*(user.Birthday)) {
62 t.Errorf("%v: Birthday haven't been copied correctly.", testCase)
63 }
65:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:65:12

64 if employee.Age != int64(user.Age) {
65 t.Errorf("%v: Age haven't been copied correctly.", testCase)
66 }
68:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:68:12

67 if user.FakeAge != nil && employee.FakeAge != int(*user.FakeAge) {
68 t.Errorf("%v: FakeAge haven't been copied correctly.", testCase)
69 }
88:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:88:6

87
88func TestCopySameStructWithPointerField(t *testing.T) {
89 var fakeAge int32 = 12
93:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:93:2

92 newUser := &User{}
93 copier.Copy(newUser, user)
94 if user.Birthday == newUser.Birthday {
95:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:95:12

94 if user.Birthday == newUser.Birthday {
95 t.Errorf("TestCopySameStructWithPointerField: copy Birthday failed since they need to have different address")
96 }
99:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:99:12

98 if user.FakeAge == newUser.FakeAge {
99 t.Errorf("TestCopySameStructWithPointerField: copy FakeAge failed since they need to have different address")
100 }
105:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:105:6

104 if user == nil {
105 if employee.Name != "" || employee.NickName != nil || employee.Birthday != nil || employee.Age != 0 ||
106 employee.DoubleAge != 0 || employee.FakeAge != 0 || employee.SuperRule != "" || employee.Notes != nil {
105:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:105:6

104 if user == nil {
105 if employee.Name != "" || employee.NickName != nil || employee.Birthday != nil || employee.Age != 0 ||
106 employee.DoubleAge != 0 || employee.FakeAge != 0 || employee.SuperRule != "" || employee.Notes != nil {
105:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:105:6

104 if user == nil {
105 if employee.Name != "" || employee.NickName != nil || employee.Birthday != nil || employee.Age != 0 ||
106 employee.DoubleAge != 0 || employee.FakeAge != 0 || employee.SuperRule != "" || employee.Notes != nil {
105:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:105:6

104 if user == nil {
105 if employee.Name != "" || employee.NickName != nil || employee.Birthday != nil || employee.Age != 0 ||
106 employee.DoubleAge != 0 || employee.FakeAge != 0 || employee.SuperRule != "" || employee.Notes != nil {
105:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:105:6

104 if user == nil {
105 if employee.Name != "" || employee.NickName != nil || employee.Birthday != nil || employee.Age != 0 ||
106 employee.DoubleAge != 0 || employee.FakeAge != 0 || employee.SuperRule != "" || employee.Notes != nil {
105:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:105:6

104 if user == nil {
105 if employee.Name != "" || employee.NickName != nil || employee.Birthday != nil || employee.Age != 0 ||
106 employee.DoubleAge != 0 || employee.FakeAge != 0 || employee.SuperRule != "" || employee.Notes != nil {
115:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:115:6

114
115func TestCopySliceOfDifferentTypes(t *testing.T) {
116 var ss []string
123:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:123:12

122 if !reflect.DeepEqual(ss, anotherSs) {
123 t.Errorf("Copy nil slice to nil slice should get nil slice")
124 }
127:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:127:6

126
127func TestCopyStruct(t *testing.T) {
128 var fakeAge int32 = 12
133:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:133:12

132 if err := copier.Copy(employee, &user); err == nil {
133 t.Errorf("Copy to unaddressable value should get error")
134 }
136:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:136:2

135
136 copier.Copy(&employee, &user)
137 checkEmployee(employee, user, t, "Copy From Ptr To Ptr")
140:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:140:2

139 employee2 := Employee{}
140 copier.Copy(&employee2, user)
141 checkEmployee(employee2, user, t, "Copy From Struct To Ptr")
145:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:145:2

144 ptrToUser := &user
145 copier.Copy(&employee3, &ptrToUser)
146 checkEmployee(employee3, user, t, "Copy From Double Ptr To Ptr")
149:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:149:2

148 employee4 := &Employee{}
149 copier.Copy(&employee4, user)
150 checkEmployee(*employee4, user, t, "Copy From Ptr To Double Ptr")
153:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:153:2

152 employee5 := &Employee{}
153 copier.Copy(&employee5, &employee)
154 checkEmployee(*employee5, user, t, "Copy From Employee To Employee")
157:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:157:6

156
157func TestCopyFromStructToSlice(t *testing.T) {
158 user := User{Name: "Jinzhu", Age: 18, Role: "Admin", Notes: []string{"hello world"}}
158:21add-constantstring literal "Jinzhu" appears more than twice; define a constant

copier_test.go:158:21

157func TestCopyFromStructToSlice(t *testing.T) {
158 user := User{Name: "Jinzhu", Age: 18, Role: "Admin", Notes: []string{"hello world"}}
159 employees := []Employee{}
158:46add-constantstring literal "Admin" appears more than twice; define a constant

copier_test.go:158:46

157func TestCopyFromStructToSlice(t *testing.T) {
158 user := User{Name: "Jinzhu", Age: 18, Role: "Admin", Notes: []string{"hello world"}}
159 employees := []Employee{}
158:71add-constantstring literal "hello world" appears more than twice; define a constant

copier_test.go:158:71

157func TestCopyFromStructToSlice(t *testing.T) {
158 user := User{Name: "Jinzhu", Age: 18, Role: "Admin", Notes: []string{"hello world"}}
159 employees := []Employee{}
162:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:162:12

161 if err := copier.Copy(employees, &user); err != nil && len(employees) != 0 {
162 t.Errorf("Copy to unaddressable value should get error")
163 }
165:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:165:5

164
165 if copier.Copy(&employees, &user); len(employees) != 1 {
166 t.Errorf("Should only have one elem when copy struct to slice")
166:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:166:12

165 if copier.Copy(&employees, &user); len(employees) != 1 {
166 t.Errorf("Should only have one elem when copy struct to slice")
167 } else {
172:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:172:5

171 employees2 := &[]Employee{}
172 if copier.Copy(&employees2, user); len(*employees2) != 1 {
173 t.Errorf("Should only have one elem when copy struct to slice")
173:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:173:12

172 if copier.Copy(&employees2, user); len(*employees2) != 1 {
173 t.Errorf("Should only have one elem when copy struct to slice")
174 } else {
179:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:179:5

178 employees3 := []*Employee{}
179 if copier.Copy(&employees3, user); len(employees3) != 1 {
180 t.Errorf("Should only have one elem when copy struct to slice")
180:12add-constantstring literal "Should only have one elem when copy struct to slice" appears more than twice; define a constant

copier_test.go:180:12

179 if copier.Copy(&employees3, user); len(employees3) != 1 {
180 t.Errorf("Should only have one elem when copy struct to slice")
181 } else {
180:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:180:12

179 if copier.Copy(&employees3, user); len(employees3) != 1 {
180 t.Errorf("Should only have one elem when copy struct to slice")
181 } else {
186:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:186:5

185 employees4 := &[]*Employee{}
186 if copier.Copy(&employees4, user); len(*employees4) != 1 {
187 t.Errorf("Should only have one elem when copy struct to slice")
187:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:187:12

186 if copier.Copy(&employees4, user); len(*employees4) != 1 {
187 t.Errorf("Should only have one elem when copy struct to slice")
188 } else {
193:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:193:6

192
193func TestCopyFromSliceToSlice(t *testing.T) {
194 users := []User{
199:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:199:5

198
199 if copier.Copy(&employees, users); len(employees) != 2 {
200 t.Errorf("Should have two elems when copy slice to slice")
200:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:200:12

199 if copier.Copy(&employees, users); len(employees) != 2 {
200 t.Errorf("Should have two elems when copy slice to slice")
201 } else {
207:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:207:5

206 employees2 := &[]Employee{}
207 if copier.Copy(&employees2, &users); len(*employees2) != 2 {
208 t.Errorf("Should have two elems when copy slice to slice")
208:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:208:12

207 if copier.Copy(&employees2, &users); len(*employees2) != 2 {
208 t.Errorf("Should have two elems when copy slice to slice")
209 } else {
215:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:215:5

214 employees3 := []*Employee{}
215 if copier.Copy(&employees3, users); len(employees3) != 2 {
216 t.Errorf("Should have two elems when copy slice to slice")
216:12add-constantstring literal "Should have two elems when copy slice to slice" appears more than twice; define a constant

copier_test.go:216:12

215 if copier.Copy(&employees3, users); len(employees3) != 2 {
216 t.Errorf("Should have two elems when copy slice to slice")
217 } else {
216:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:216:12

215 if copier.Copy(&employees3, users); len(employees3) != 2 {
216 t.Errorf("Should have two elems when copy slice to slice")
217 } else {
223:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:223:5

222 employees4 := &[]*Employee{}
223 if copier.Copy(&employees4, users); len(*employees4) != 2 {
224 t.Errorf("Should have two elems when copy slice to slice")
224:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:224:12

223 if copier.Copy(&employees4, users); len(*employees4) != 2 {
224 t.Errorf("Should have two elems when copy slice to slice")
225 } else {
231:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:231:6

230
231func TestCopyFromSliceToSlice2(t *testing.T) {
232 users := []*User{{Name: "Jinzhu", Age: 18, Role: "Admin", Notes: []string{"hello world"}}, nil}
235:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:235:5

234
235 if copier.Copy(&employees, users); len(employees) != 2 {
236 t.Errorf("Should have two elems when copy slice to slice")
236:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:236:12

235 if copier.Copy(&employees, users); len(employees) != 2 {
236 t.Errorf("Should have two elems when copy slice to slice")
237 } else {
243:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:243:5

242 employees2 := &[]Employee{}
243 if copier.Copy(&employees2, &users); len(*employees2) != 2 {
244 t.Errorf("Should have two elems when copy slice to slice")
244:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:244:12

243 if copier.Copy(&employees2, &users); len(*employees2) != 2 {
244 t.Errorf("Should have two elems when copy slice to slice")
245 } else {
251:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:251:5

250 employees3 := []*Employee{}
251 if copier.Copy(&employees3, users); len(employees3) != 2 {
252 t.Errorf("Should have two elems when copy slice to slice")
252:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:252:12

251 if copier.Copy(&employees3, users); len(employees3) != 2 {
252 t.Errorf("Should have two elems when copy slice to slice")
253 } else {
259:5discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:259:5

258 employees4 := &[]*Employee{}
259 if copier.Copy(&employees4, users); len(*employees4) != 2 {
260 t.Errorf("Should have two elems when copy slice to slice")
260:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:260:12

259 if copier.Copy(&employees4, users); len(*employees4) != 2 {
260 t.Errorf("Should have two elems when copy slice to slice")
261 } else {
267:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:267:6

266
267func TestCopyFromSliceToSlice3(t *testing.T) {
268 type CollectionAlias struct {
268:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:268:7

267func TestCopyFromSliceToSlice3(t *testing.T) {
268 type CollectionAlias struct {
269 CollectionName string `json:"collection_name"`
276:4add-constantstring literal "collection" appears more than twice; define a constant

copier_test.go:276:4

275 {"collection", "collection_alias2"},
276 {"collection", "collection_alias3"},
277 }
280:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:280:2

279 mockedResult := []*CollectionAlias{}
280 copier.Copy(&mockedResult, &expectedResult)
281
287:6identical-binary-operandsidentical expressions appear on both sides of !=

copier_test.go:287:6

286 for idx := range mockedResult {
287 if mockedResult[idx].Name != mockedResult[idx].Name || mockedResult[idx].CollectionName != mockedResult[idx].CollectionName {
288 t.Fatalf("failed to copy results")
287:58identical-binary-operandsidentical expressions appear on both sides of !=

copier_test.go:287:58

286 for idx := range mockedResult {
287 if mockedResult[idx].Name != mockedResult[idx].Name || mockedResult[idx].CollectionName != mockedResult[idx].CollectionName {
288 t.Fatalf("failed to copy results")
293:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:293:6

292
293func TestEmbeddedAndBase(t *testing.T) {
294 type Base struct {
294:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:294:7

293func TestEmbeddedAndBase(t *testing.T) {
294 type Base struct {
295 BaseField1 int
300:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:300:7

299
300 type Embed struct {
301 EmbedField1 int
318:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:318:2

317
318 copier.Copy(&base, &embedded)
319
331:2discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:331:2

330
331 copier.Copy(&embedded, &base)
332 if embedded.BaseField1 != 11 || embedded.User.Name != "testName1" {
337:6cognitive-complexityfunction has cognitive complexity 48; maximum is 7

copier_test.go:337:6

336
337func TestStructField(t *testing.T) {
338 type Detail struct {
337:6cyclomatic-complexityfunction complexity is 51; maximum is 10

copier_test.go:337:6

336
337func TestStructField(t *testing.T) {
338 type Detail struct {
337:6function-lengthfunction has 208 statements and 371 lines; maximum is 50 statements or 75 lines

copier_test.go:337:6

336
337func TestStructField(t *testing.T) {
338 type Detail struct {
337:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:337:6

336
337func TestStructField(t *testing.T) {
338 type Detail struct {
338:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:338:7

337func TestStructField(t *testing.T) {
338 type Detail struct {
339 Info1 string
338:7max-public-structsfile declares more than 5 exported structs

copier_test.go:338:7

337func TestStructField(t *testing.T) {
338 type Detail struct {
339 Info1 string
343:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:343:7

342
343 type SimilarDetail struct {
344 Info1 string
343:7max-public-structsfile declares more than 5 exported structs

copier_test.go:343:7

342
343 type SimilarDetail struct {
344 Info1 string
348:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:348:7

347
348 type UserWithDetailsPtr struct {
349 Details []*Detail
348:7max-public-structsfile declares more than 5 exported structs

copier_test.go:348:7

347
348 type UserWithDetailsPtr struct {
349 Details []*Detail
354:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:354:7

353 }
354 type UserWithDetails struct {
355 Details []Detail
354:7max-public-structsfile declares more than 5 exported structs

copier_test.go:354:7

353 }
354 type UserWithDetails struct {
355 Details []Detail
360:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:360:7

359 }
360 type UserWithSimilarDetailsPtr struct {
361 Detail *SimilarDetail
360:7max-public-structsfile declares more than 5 exported structs

copier_test.go:360:7

359 }
360 type UserWithSimilarDetailsPtr struct {
361 Detail *SimilarDetail
363:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:363:7

362 }
363 type UserWithSimilarDetails struct {
364 Detail SimilarDetail
363:7max-public-structsfile declares more than 5 exported structs

copier_test.go:363:7

362 }
363 type UserWithSimilarDetails struct {
364 Detail SimilarDetail
366:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:366:7

365 }
366 type EmployeeWithDetails struct {
367 Detail Detail
366:7max-public-structsfile declares more than 5 exported structs

copier_test.go:366:7

365 }
366 type EmployeeWithDetails struct {
367 Detail Detail
369:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:369:7

368 }
369 type EmployeeWithDetailsPtr struct {
370 Detail *Detail
369:7max-public-structsfile declares more than 5 exported structs

copier_test.go:369:7

368 }
369 type EmployeeWithDetailsPtr struct {
370 Detail *Detail
372:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:372:7

371 }
372 type EmployeeWithSimilarDetails struct {
373 Detail SimilarDetail
372:7max-public-structsfile declares more than 5 exported structs

copier_test.go:372:7

371 }
372 type EmployeeWithSimilarDetails struct {
373 Detail SimilarDetail
375:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:375:7

374 }
375 type EmployeeWithSimilarDetailsPtr struct {
376 Detail *SimilarDetail
375:7max-public-structsfile declares more than 5 exported structs

copier_test.go:375:7

374 }
375 type EmployeeWithSimilarDetailsPtr struct {
376 Detail *SimilarDetail
388:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:388:6

387
388 if (source.Info2 != nil || target.Info2 != nil) && (*source.Info2 != *target.Info2) {
389 t.Errorf("info2 is diff: source: %v, target: %v", *source.Info2, *target.Info2)
393:40test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:393:40

392
393 t.Run("Should work without deepCopy", func(t *testing.T) {
394 t.Run("Should work with same type and both ptr field", func(t *testing.T) {
394:58test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:394:58

393 t.Run("Should work without deepCopy", func(t *testing.T) {
394 t.Run("Should work with same type and both ptr field", func(t *testing.T) {
395 info2 := "world"
398:32add-constantstring literal "hello" appears more than twice; define a constant

copier_test.go:398:32

397 Detail: &Detail{Info1: "hello", Info2: &info2},
398 Details: []*Detail{{Info1: "hello", Info2: &info2}},
399 }
401:4discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:401:4

400 to := UserWithDetailsPtr{}
401 copier.Copy(&to, from)
402
419:62test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:419:62

418
419 t.Run("Should work with same type and both not ptr field", func(t *testing.T) {
420 info2 := "world"
426:4discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:426:4

425 to := UserWithDetails{}
426 copier.Copy(&to, from)
427
444:63test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:444:63

443
444 t.Run("Should work with different type and both ptr field", func(t *testing.T) {
445 info2 := "world"
445:13add-constantstring literal "world" appears more than twice; define a constant

copier_test.go:445:13

444 t.Run("Should work with different type and both ptr field", func(t *testing.T) {
445 info2 := "world"
446 from := UserWithDetailsPtr{Detail: &Detail{Info1: "hello", Info2: &info2}}
448:4discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:448:4

447 to := EmployeeWithDetailsPtr{}
448 copier.Copy(&to, from)
449
450:16add-constantstring literal "new value" appears more than twice; define a constant

copier_test.go:450:16

449
450 newValue := "new value"
451 to.Detail.Info2 = &newValue
464:67test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:464:67

463
464 t.Run("Should work with different type and both not ptr field", func(t *testing.T) {
465 info2 := "world"
468:4discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:468:4

467 to := EmployeeWithDetails{}
468 copier.Copy(&to, from)
469
484:65test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:484:65

483
484 t.Run("Should work with from ptr field and to not ptr field", func(t *testing.T) {
485 info2 := "world"
488:4discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:488:4

487 to := EmployeeWithDetails{}
488 copier.Copy(&to, from)
489
494:14add-constantstring literal "should not be empty" appears more than twice; define a constant

copier_test.go:494:14

493 if to.Detail.Info1 == "" {
494 t.Errorf("should not be empty")
495 }
497:14add-constantstring literal "should be the same" appears more than twice; define a constant

copier_test.go:497:14

496 if to.Detail.Info1 != from.Detail.Info1 {
497 t.Errorf("should be the same")
498 }
500:14add-constantstring literal "should be different" appears more than twice; define a constant

copier_test.go:500:14

499 if to.Detail.Info2 == from.Detail.Info2 {
500 t.Errorf("should be different")
501 }
504:65test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:504:65

503
504 t.Run("Should work with from not ptr field and to ptr field", func(t *testing.T) {
505 info2 := "world"
508:4discarded-error-resulterror result returned by copier.Copy is discarded

copier_test.go:508:4

507 to := EmployeeWithDetailsPtr{}
508 copier.Copy(&to, from)
509
524:73test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:524:73

523
524 t.Run("Should work with from a nil ptr slice field to a slice field", func(t *testing.T) {
525 notes := []string{"hello", "world"}
546:37test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:546:37

545
546 t.Run("Should work with deepCopy", func(t *testing.T) {
547 t.Run("Should work with same type and both ptr field", func(t *testing.T) {
547:58test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:547:58

546 t.Run("Should work with deepCopy", func(t *testing.T) {
547 t.Run("Should work with same type and both ptr field", func(t *testing.T) {
548 info2 := "world"
554:4discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_test.go:554:4

553 to := UserWithDetailsPtr{}
554 copier.CopyWithOption(&to, from, optionsDeepCopy)
555
564:14add-constantstring literal "slice should be copied" appears more than twice; define a constant

copier_test.go:564:14

563 if len(from.Details) != len(to.Details) {
564 t.Fatalf("slice should be copied")
565 }
571:62test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:571:62

570 })
571 t.Run("Should work with same type and both not ptr field", func(t *testing.T) {
572 info2 := "world"
578:4discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_test.go:578:4

577 to := UserWithDetails{}
578 copier.CopyWithOption(&to, from, optionsDeepCopy)
579
596:63test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:596:63

595
596 t.Run("Should work with different type and both ptr field", func(t *testing.T) {
597 info2 := "world"
600:4discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_test.go:600:4

599 to := EmployeeWithDetailsPtr{}
600 copier.CopyWithOption(&to, from, optionsDeepCopy)
601
616:67test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:616:67

615
616 t.Run("Should work with different type and both not ptr field", func(t *testing.T) {
617 info2 := "world"
620:4discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_test.go:620:4

619 to := EmployeeWithDetails{}
620 copier.CopyWithOption(&to, from, optionsDeepCopy)
621
636:65test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:636:65

635
636 t.Run("Should work with from ptr field and to not ptr field", func(t *testing.T) {
637 info2 := "world"
640:4discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_test.go:640:4

639 to := EmployeeWithDetails{}
640 copier.CopyWithOption(&to, from, optionsDeepCopy)
641
656:65test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:656:65

655
656 t.Run("Should work with from not ptr field and to ptr field", func(t *testing.T) {
657 info2 := "world"
660:4discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_test.go:660:4

659 to := EmployeeWithDetailsPtr{}
660 copier.CopyWithOption(&to, from, optionsDeepCopy)
661
676:73test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:676:73

675
676 t.Run("Should work with from a nil ptr slice field to a slice field", func(t *testing.T) {
677 notes := []string{"hello", "world"}
709:6cognitive-complexityfunction has cognitive complexity 10; maximum is 7

copier_test.go:709:6

708
709func TestMapInterface(t *testing.T) {
710 type Inner struct {
709:6cyclomatic-complexityfunction complexity is 15; maximum is 10

copier_test.go:709:6

708
709func TestMapInterface(t *testing.T) {
710 type Inner struct {
709:6function-lengthfunction has 48 statements and 115 lines; maximum is 50 statements or 75 lines

copier_test.go:709:6

708
709func TestMapInterface(t *testing.T) {
710 type Inner struct {
709:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:709:6

708
709func TestMapInterface(t *testing.T) {
710 type Inner struct {
710:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:710:7

709func TestMapInterface(t *testing.T) {
710 type Inner struct {
711 IntPtr *int
710:7max-public-structsfile declares more than 5 exported structs

copier_test.go:710:7

709func TestMapInterface(t *testing.T) {
710 type Inner struct {
711 IntPtr *int
715:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:715:7

714
715 type Outer struct {
716 Inner Inner
715:7max-public-structsfile declares more than 5 exported structs

copier_test.go:715:7

714
715 type Outer struct {
716 Inner Inner
719:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:719:7

718
719 type DriverOptions struct {
720 GenOptions map[string]interface{}
719:7max-public-structsfile declares more than 5 exported structs

copier_test.go:719:7

718
719 type DriverOptions struct {
720 GenOptions map[string]interface{}
720:25use-anyuse any instead of interface{}

copier_test.go:720:25

719 type DriverOptions struct {
720 GenOptions map[string]interface{}
721 }
723:40test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:723:40

722
723 t.Run("Should work without deepCopy", func(t *testing.T) {
724 intVal := 5
732:27use-anyuse any instead of interface{}

copier_test.go:732:27

731 from := DriverOptions{
732 GenOptions: map[string]interface{}{
733 "key": outer,
738:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:738:13

737 if err := copier.Copy(&to, &from); nil != err {
738 t.Errorf("Unexpected error: %v", err)
739 return
742:24unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:742:24

741
742 *to.GenOptions["key"].(Outer).Inner.IntPtr = 6
743
744:20add-constantstring literal "key" appears more than twice; define a constant

copier_test.go:744:20

743
744 if to.GenOptions["key"].(Outer).Inner.IntPtr != from.GenOptions["key"].(Outer).Inner.IntPtr {
745 t.Errorf("should be the same")
744:26unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:744:26

743
744 if to.GenOptions["key"].(Outer).Inner.IntPtr != from.GenOptions["key"].(Outer).Inner.IntPtr {
745 t.Errorf("should be the same")
744:73unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:744:73

743
744 if to.GenOptions["key"].(Outer).Inner.IntPtr != from.GenOptions["key"].(Outer).Inner.IntPtr {
745 t.Errorf("should be the same")
749:37test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:749:37

748
749 t.Run("Should work with deepCopy", func(t *testing.T) {
750 intVal := 5
758:27use-anyuse any instead of interface{}

copier_test.go:758:27

757 from := DriverOptions{
758 GenOptions: map[string]interface{}{
759 "key": outer,
766:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:766:13

765 }); nil != err {
766 t.Errorf("Unexpected error: %v", err)
767 return
770:24unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:770:24

769
770 *to.GenOptions["key"].(Outer).Inner.IntPtr = 6
771
772:26unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:772:26

771
772 if to.GenOptions["key"].(Outer).Inner.IntPtr == from.GenOptions["key"].(Outer).Inner.IntPtr {
773 t.Errorf("should be different")
772:73unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:772:73

771
772 if to.GenOptions["key"].(Outer).Inner.IntPtr == from.GenOptions["key"].(Outer).Inner.IntPtr {
773 t.Errorf("should be different")
777:44test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:777:44

776
777 t.Run("Test copy map with nil interface", func(t *testing.T) {
778 from := map[string]interface{}{"eventId": nil}
778:22use-anyuse any instead of interface{}

copier_test.go:778:22

777 t.Run("Test copy map with nil interface", func(t *testing.T) {
778 from := map[string]interface{}{"eventId": nil}
779 to := map[string]interface{}{"eventId": nil}
779:20use-anyuse any instead of interface{}

copier_test.go:779:20

778 from := map[string]interface{}{"eventId": nil}
779 to := map[string]interface{}{"eventId": nil}
780 copier.CopyWithOption(&to, &from, copier.Option{IgnoreEmpty: true, DeepCopy: true})
780:3discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_test.go:780:3

779 to := map[string]interface{}{"eventId": nil}
780 copier.CopyWithOption(&to, &from, copier.Option{IgnoreEmpty: true, DeepCopy: true})
781 if v, ok := to["eventId"]; !ok || v != nil {
781:18add-constantstring literal "eventId" appears more than twice; define a constant

copier_test.go:781:18

780 copier.CopyWithOption(&to, &from, copier.Option{IgnoreEmpty: true, DeepCopy: true})
781 if v, ok := to["eventId"]; !ok || v != nil {
782 t.Errorf("failed to deep copy map with nil, got %v", v)
790:3discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_test.go:790:3

789
790 copier.CopyWithOption(&to, &from, copier.Option{IgnoreEmpty: true, DeepCopy: true})
791 if v, ok := to["eventId"]; !ok || v != 1 {
801:47test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:801:47

800
801 t.Run("Test copy map with nested slice map", func(t *testing.T) {
802 var out map[string]interface{}
802:22use-anyuse any instead of interface{}

copier_test.go:802:22

801 t.Run("Test copy map with nested slice map", func(t *testing.T) {
802 var out map[string]interface{}
803 value := map[string]interface{}{
803:23use-anyuse any instead of interface{}

copier_test.go:803:23

802 var out map[string]interface{}
803 value := map[string]interface{}{
804 "list": []map[string]interface{}{
804:25use-anyuse any instead of interface{}

copier_test.go:804:25

803 value := map[string]interface{}{
804 "list": []map[string]interface{}{
805 {
809:15use-anyuse any instead of interface{}

copier_test.go:809:15

808 },
809 "list2": []interface{}{
810 map[string]interface{}{
810:16use-anyuse any instead of interface{}

copier_test.go:810:16

809 "list2": []interface{}{
810 map[string]interface{}{
811 "shop_id": 123,
825:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:825:6

824
825func TestInterface(t *testing.T) {
826 type Inner struct {
826:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:826:7

825func TestInterface(t *testing.T) {
826 type Inner struct {
827 IntPtr *int
826:7max-public-structsfile declares more than 5 exported structs

copier_test.go:826:7

825func TestInterface(t *testing.T) {
826 type Inner struct {
827 IntPtr *int
830:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:830:7

829
830 type Outer struct {
831 Inner Inner
830:7max-public-structsfile declares more than 5 exported structs

copier_test.go:830:7

829
830 type Outer struct {
831 Inner Inner
834:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:834:7

833
834 type DriverOptions struct {
835 GenOptions interface{}
834:7max-public-structsfile declares more than 5 exported structs

copier_test.go:834:7

833
834 type DriverOptions struct {
835 GenOptions interface{}
835:14use-anyuse any instead of interface{}

copier_test.go:835:14

834 type DriverOptions struct {
835 GenOptions interface{}
836 }
838:8add-constantstring literal "Should work without deepCopy" appears more than twice; define a constant

copier_test.go:838:8

837
838 t.Run("Should work without deepCopy", func(t *testing.T) {
839 intVal := 5
838:40test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:838:40

837
838 t.Run("Should work without deepCopy", func(t *testing.T) {
839 intVal := 5
850:13add-constantstring literal "Unexpected error: %v" appears more than twice; define a constant

copier_test.go:850:13

849 if err := copier.Copy(&to, from); nil != err {
850 t.Errorf("Unexpected error: %v", err)
851 return
850:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:850:13

849 if err := copier.Copy(&to, from); nil != err {
850 t.Errorf("Unexpected error: %v", err)
851 return
854:17unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:854:17

853
854 *to.GenOptions.(Outer).Inner.IntPtr = 6
855
856:19unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:856:19

855
856 if to.GenOptions.(Outer).Inner.IntPtr != from.GenOptions.(Outer).Inner.IntPtr {
857 t.Errorf("should be the same")
856:59unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:856:59

855
856 if to.GenOptions.(Outer).Inner.IntPtr != from.GenOptions.(Outer).Inner.IntPtr {
857 t.Errorf("should be the same")
861:8add-constantstring literal "Should work with deepCopy" appears more than twice; define a constant

copier_test.go:861:8

860
861 t.Run("Should work with deepCopy", func(t *testing.T) {
862 intVal := 5
861:37test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:861:37

860
861 t.Run("Should work with deepCopy", func(t *testing.T) {
862 intVal := 5
875:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:875:13

874 }); nil != err {
875 t.Errorf("Unexpected error: %v", err)
876 return
879:17unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:879:17

878
879 *to.GenOptions.(Outer).Inner.IntPtr = 6
880
881:19unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:881:19

880
881 if to.GenOptions.(Outer).Inner.IntPtr == from.GenOptions.(Outer).Inner.IntPtr {
882 t.Errorf("should be different")
881:59unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:881:59

880
881 if to.GenOptions.(Outer).Inner.IntPtr == from.GenOptions.(Outer).Inner.IntPtr {
882 t.Errorf("should be different")
887:6cognitive-complexityfunction has cognitive complexity 16; maximum is 7

copier_test.go:887:6

886
887func TestSlice(t *testing.T) {
888 type ElemOption struct {
887:6cyclomatic-complexityfunction complexity is 17; maximum is 10

copier_test.go:887:6

886
887func TestSlice(t *testing.T) {
888 type ElemOption struct {
887:6function-lengthfunction has 65 statements and 128 lines; maximum is 50 statements or 75 lines

copier_test.go:887:6

886
887func TestSlice(t *testing.T) {
888 type ElemOption struct {
887:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:887:6

886
887func TestSlice(t *testing.T) {
888 type ElemOption struct {
888:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:888:7

887func TestSlice(t *testing.T) {
888 type ElemOption struct {
889 Value int
888:7max-public-structsfile declares more than 5 exported structs

copier_test.go:888:7

887func TestSlice(t *testing.T) {
888 type ElemOption struct {
889 Value int
892:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:892:7

891
892 type A struct {
893 X []int
892:7max-public-structsfile declares more than 5 exported structs

copier_test.go:892:7

891
892 type A struct {
893 X []int
897:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:897:7

896
897 type B struct {
898 X []int
897:7max-public-structsfile declares more than 5 exported structs

copier_test.go:897:7

896
897 type B struct {
898 X []int
902:41test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:902:41

901
902 t.Run("Should work with simple slice", func(t *testing.T) {
903 from := []int{1, 2}
907:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:907:13

906 if err := copier.Copy(&to, from); nil != err {
907 t.Errorf("Unexpected error: %v", err)
908 return
923:40test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:923:40

922
923 t.Run("Should work with empty slice", func(t *testing.T) {
924 from := []int{}
928:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:928:13

927 if err := copier.Copy(&to, from); nil != err {
928 t.Errorf("Unexpected error: %v", err)
929 return
937:40test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:937:40

936
937 t.Run("Should work without deepCopy", func(t *testing.T) {
938 x := []int{1, 2}
947:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:947:13

946 if err := copier.Copy(&to, from); nil != err {
947 t.Errorf("Unexpected error: %v", err)
948 return
977:37test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:977:37

976
977 t.Run("Should work with deepCopy", func(t *testing.T) {
978 x := []int{1, 2}
989:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:989:13

988 }); nil != err {
989 t.Errorf("Unexpected error: %v", err)
990 return
1016:6cognitive-complexityfunction has cognitive complexity 10; maximum is 7

copier_test.go:1016:6

1015
1016func TestAnonymousFields(t *testing.T) {
1017 t.Run("Should work with unexported ptr fields", func(t *testing.T) {
1016:6cyclomatic-complexityfunction complexity is 11; maximum is 10

copier_test.go:1016:6

1015
1016func TestAnonymousFields(t *testing.T) {
1017 t.Run("Should work with unexported ptr fields", func(t *testing.T) {
1016:6function-lengthfunction has 68 statements and 148 lines; maximum is 50 statements or 75 lines

copier_test.go:1016:6

1015
1016func TestAnonymousFields(t *testing.T) {
1017 t.Run("Should work with unexported ptr fields", func(t *testing.T) {
1016:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1016:6

1015
1016func TestAnonymousFields(t *testing.T) {
1017 t.Run("Should work with unexported ptr fields", func(t *testing.T) {
1017:50test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:1017:50

1016func TestAnonymousFields(t *testing.T) {
1017 t.Run("Should work with unexported ptr fields", func(t *testing.T) {
1018 type nested struct {
1035:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1035:13

1034 if err != nil {
1035 t.Errorf("Unexpected error: %v", err)
1036 return
1045:46test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:1045:46

1044 })
1045 t.Run("Should work with unexported fields", func(t *testing.T) {
1046 type nested struct {
1063:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1063:13

1062 if err != nil {
1063 t.Errorf("Unexpected error: %v", err)
1064 return
1074:48test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:1074:48

1073
1074 t.Run("Should work with exported ptr fields", func(t *testing.T) {
1075 type Nested struct {
1075:8exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1075:8

1074 t.Run("Should work with exported ptr fields", func(t *testing.T) {
1075 type Nested struct {
1076 A string
1075:8max-public-structsfile declares more than 5 exported structs

copier_test.go:1075:8

1074 t.Run("Should work with exported ptr fields", func(t *testing.T) {
1075 type Nested struct {
1076 A string
1085:17add-constantstring literal "a" appears more than twice; define a constant

copier_test.go:1085:17

1084
1085 fieldValue := "a"
1086 from := parentA{Nested: &Nested{A: fieldValue}}
1093:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1093:13

1092 if err != nil {
1093 t.Errorf("Unexpected error: %v", err)
1094 return
1097:19add-constantstring literal "b" appears more than twice; define a constant

copier_test.go:1097:19

1096
1097 from.Nested.A = "b"
1098
1104:73test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:1104:73

1103
1104 t.Run("Should work with exported ptr fields with same name src field", func(t *testing.T) {
1105 type Nested struct {
1105:8exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1105:8

1104 t.Run("Should work with exported ptr fields with same name src field", func(t *testing.T) {
1105 type Nested struct {
1106 A string
1105:8max-public-structsfile declares more than 5 exported structs

copier_test.go:1105:8

1104 t.Run("Should work with exported ptr fields with same name src field", func(t *testing.T) {
1105 type Nested struct {
1106 A string
1123:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1123:13

1122 if err != nil {
1123 t.Errorf("Unexpected error: %v", err)
1124 return
1134:44test-parallelismconsider calling t.Parallel() when this subtest begins

copier_test.go:1134:44

1133
1134 t.Run("Should work with exported fields", func(t *testing.T) {
1135 type Nested struct {
1135:8exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1135:8

1134 t.Run("Should work with exported fields", func(t *testing.T) {
1135 type Nested struct {
1136 A string
1135:8max-public-structsfile declares more than 5 exported structs

copier_test.go:1135:8

1134 t.Run("Should work with exported fields", func(t *testing.T) {
1135 type Nested struct {
1136 A string
1153:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1153:13

1152 if err != nil {
1153 t.Errorf("Unexpected error: %v", err)
1154 return
1160:13add-constantstring literal "should not change" appears more than twice; define a constant

copier_test.go:1160:13

1159 if to.Nested.A != fieldValue {
1160 t.Errorf("should not change")
1161 }
1186:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1186:6

1185
1186func TestCopyFieldsWithSameNameButDifferentTypes(t *testing.T) {
1187 obj1 := structSameName1{A: "123", B: 2, C: time.Now()}
1195:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1195:12

1194 if obj2.A != obj1.A {
1195 t.Errorf("Field A should be copied")
1196 }
1199:6exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1199:6

1198
1199type Foo1 struct {
1200 Name string
1199:6max-public-structsfile declares more than 5 exported structs

copier_test.go:1199:6

1198
1199type Foo1 struct {
1200 Name string
1204:6exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1204:6

1203
1204type Foo2 struct {
1205 Name string
1204:6max-public-structsfile declares more than 5 exported structs

copier_test.go:1204:6

1203
1204type Foo2 struct {
1205 Name string
1208:6exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1208:6

1207
1208type StructWithMap1 struct {
1209 Map map[int]Foo1
1208:6max-public-structsfile declares more than 5 exported structs

copier_test.go:1208:6

1207
1208type StructWithMap1 struct {
1209 Map map[int]Foo1
1212:6exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1212:6

1211
1212type StructWithMap2 struct {
1213 Map map[int32]Foo2
1212:6max-public-structsfile declares more than 5 exported structs

copier_test.go:1212:6

1211
1212type StructWithMap2 struct {
1213 Map map[int32]Foo2
1216:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1216:6

1215
1216func TestCopyMapOfStruct(t *testing.T) {
1217 obj1 := StructWithMap1{Map: map[int]Foo1{2: {Name: "A pure foo"}}}
1226:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1226:13

1225 if !ok || v1.Name != v2.Name {
1226 t.Errorf("Map should be copied")
1227 }
1231:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1231:6

1230
1231func TestCopyMapOfInt(t *testing.T) {
1232 map1 := map[int]int{3: 6, 4: 8}
1236:11add-constantstring literal "Should not raise error" appears more than twice; define a constant

copier_test.go:1236:11

1235 if err != nil {
1236 t.Error("Should not raise error")
1237 }
1242:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1242:13

1241 if !ok || v1 != int(v2) {
1242 t.Errorf("Map should be copied")
1243 }
1247:6cognitive-complexityfunction has cognitive complexity 38; maximum is 7

copier_test.go:1247:6

1246
1247func TestCopyMapOfSliceValue(t *testing.T) {
1248 // case1: map's value is a simple slice
1247:6cyclomatic-complexityfunction complexity is 24; maximum is 10

copier_test.go:1247:6

1246
1247func TestCopyMapOfSliceValue(t *testing.T) {
1248 // case1: map's value is a simple slice
1247:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1247:6

1246
1247func TestCopyMapOfSliceValue(t *testing.T) {
1248 // case1: map's value is a simple slice
1265:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:1265:6

1264 v2, ok := dst1[k]
1265 if !ok || len(v1) != len(v2) || k != key {
1266 t.Errorf("Map should be copied")
1266:13add-constantstring literal "Map should be copied" appears more than twice; define a constant

copier_test.go:1266:13

1265 if !ok || len(v1) != len(v2) || k != key {
1266 t.Errorf("Map should be copied")
1267 }
1266:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1266:13

1265 if !ok || len(v1) != len(v2) || k != key {
1266 t.Errorf("Map should be copied")
1267 }
1270:14error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1270:14

1269 if v2[i] != value {
1270 t.Errorf("Map's slice value shoud be copied")
1271 }
1276:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1276:13

1275 if !ok || len(v1) != len(v3) {
1276 t.Errorf("Map should be copied")
1277 }
1280:14error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1280:14

1279 if v3[i] != value {
1280 t.Errorf("Map's slice value shoud be copied")
1281 }
1296:3discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_test.go:1296:3

1295 for i := range ms {
1296 copier.CopyWithOption(&ms[i], s, copier.Option{IgnoreEmpty: false, DeepCopy: true})
1297
1296:25range-value-addresstaking the address of range value i can be misleading

copier_test.go:1296:25

1295 for i := range ms {
1296 copier.CopyWithOption(&ms[i], s, copier.Option{IgnoreEmpty: false, DeepCopy: true})
1297
1299:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1299:13

1298 if len(ms[i]) != len(s) {
1299 t.Errorf("Number of map's keys should be equal")
1300 }
1303:14error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1303:14

1302 if k != key1 {
1303 t.Errorf("Map's key should be copied")
1304 }
1305:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:1305:7

1304 }
1305 if len(sliceMap) != len(s[key1]) || len(sliceMap) != 1 {
1306 t.Errorf("Map's slice value should be copied")
1306:14error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1306:14

1305 if len(sliceMap) != len(s[key1]) || len(sliceMap) != 1 {
1306 t.Errorf("Map's slice value should be copied")
1307 }
1309:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:1309:7

1308 m := sliceMap[0]
1309 if len(m) != len(s[key1][0]) || len(m) != 1 {
1310 t.Errorf("Map's slice value should be copied recursively")
1310:14error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1310:14

1309 if len(m) != len(s[key1][0]) || len(m) != 1 {
1310 t.Errorf("Map's slice value should be copied recursively")
1311 }
1314:15error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1314:15

1313 if k != key2 || v != value {
1314 t.Errorf("Map's slice value should be copied recursively")
1315 }
1321:6cyclomatic-complexityfunction complexity is 13; maximum is 10

copier_test.go:1321:6

1320
1321func TestCopyMapOfPtrValue(t *testing.T) {
1322 intV := 3
1321:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1321:6

1320
1321func TestCopyMapOfPtrValue(t *testing.T) {
1322 intV := 3
1338:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:1338:6

1337 v2, ok := dst1[k]
1338 if !ok || v2 == nil || v1 == nil || *v2 != *v1 || *v2 != intV {
1339 t.Errorf("Map should be copied")
1338:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:1338:6

1337 v2, ok := dst1[k]
1338 if !ok || v2 == nil || v1 == nil || *v2 != *v1 || *v2 != intV {
1339 t.Errorf("Map should be copied")
1338:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:1338:6

1337 v2, ok := dst1[k]
1338 if !ok || v2 == nil || v1 == nil || *v2 != *v1 || *v2 != intV {
1339 t.Errorf("Map should be copied")
1339:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1339:13

1338 if !ok || v2 == nil || v1 == nil || *v2 != *v1 || *v2 != intV {
1339 t.Errorf("Map should be copied")
1340 }
1343:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:1343:6

1342 v3, ok := dst2[k]
1343 if !ok || v3 == nil || *v3 != *v1 || *v3 != intV {
1344 t.Errorf("Map should be copied")
1343:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

copier_test.go:1343:6

1342 v3, ok := dst2[k]
1343 if !ok || v3 == nil || *v3 != *v1 || *v3 != intV {
1344 t.Errorf("Map should be copied")
1343:33possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

copier_test.go:1343:33

1342 v3, ok := dst2[k]
1343 if !ok || v3 == nil || *v3 != *v1 || *v3 != intV {
1344 t.Errorf("Map should be copied")
1344:13error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1344:13

1343 if !ok || v3 == nil || *v3 != *v1 || *v3 != intV {
1344 t.Errorf("Map should be copied")
1345 }
1349:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1349:6

1348
1349func TestCopyWithOption(t *testing.T) {
1350 from := structSameName2{D: "456", E: &someStruct{IntField: 100, UIntField: 1000}}
1351:59add-constantstring literal "123" appears more than twice; define a constant

copier_test.go:1351:59

1350 from := structSameName2{D: "456", E: &someStruct{IntField: 100, UIntField: 1000}}
1351 to := &structSameName1{A: "123", B: 2, C: time.Now(), D: "123", E: &someStruct{UIntField: 5000}}
1352 if err := copier.CopyWithOption(to, &from, copier.Option{IgnoreEmpty: true}); err != nil {
1357:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1357:12

1356 if to.A == from.A {
1357 t.Errorf("Field A should not be copied")
1358 } else if to.D != from.D {
1359:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1359:12

1358 } else if to.D != from.D {
1359 t.Errorf("Field D should be copied")
1360 }
1363:6exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1363:6

1362
1363type ScannerValue struct {
1364 V int
1363:6max-public-structsfile declares more than 5 exported structs

copier_test.go:1363:6

1362
1363type ScannerValue struct {
1364 V int
1367:7unused-receiverreceiver s is unused

copier_test.go:1367:7

1366
1367func (s *ScannerValue) Scan(src interface{}) error {
1368 return errors.New("I failed")
1367:24exported-declaration-commentexported function or method should have a comment beginning with its name

copier_test.go:1367:24

1366
1367func (s *ScannerValue) Scan(src interface{}) error {
1368 return errors.New("I failed")
1367:29unused-parameterparameter src is unused

copier_test.go:1367:29

1366
1367func (s *ScannerValue) Scan(src interface{}) error {
1368 return errors.New("I failed")
1367:33use-anyuse any instead of interface{}

copier_test.go:1367:33

1366
1367func (s *ScannerValue) Scan(src interface{}) error {
1368 return errors.New("I failed")
1368:20error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1368:20

1367func (s *ScannerValue) Scan(src interface{}) error {
1368 return errors.New("I failed")
1369}
1371:6exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1371:6

1370
1371type ScannerStruct struct {
1372 V *ScannerValue
1371:6max-public-structsfile declares more than 5 exported structs

copier_test.go:1371:6

1370
1371type ScannerStruct struct {
1372 V *ScannerValue
1375:6exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1375:6

1374
1375type ScannerStructTo struct {
1376 V *ScannerValue
1375:6max-public-structsfile declares more than 5 exported structs

copier_test.go:1375:6

1374
1375type ScannerStructTo struct {
1376 V *ScannerValue
1379:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1379:6

1378
1379func TestScanner(t *testing.T) {
1380 s := &ScannerStruct{
1394:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1394:12

1393 if s.V.V != s2.V.V {
1394 t.Errorf("Field V should be copied")
1395 }
1398:6cognitive-complexityfunction has cognitive complexity 10; maximum is 7

copier_test.go:1398:6

1397
1398func TestScanFromPtrToSqlNullable(t *testing.T) {
1399 var (
1398:6cyclomatic-complexityfunction complexity is 12; maximum is 10

copier_test.go:1398:6

1397
1398func TestScanFromPtrToSqlNullable(t *testing.T) {
1399 var (
1398:6function-lengthfunction has 29 statements and 76 lines; maximum is 50 statements or 75 lines

copier_test.go:1398:6

1397
1398func TestScanFromPtrToSqlNullable(t *testing.T) {
1399 var (
1398:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1398:6

1397
1398func TestScanFromPtrToSqlNullable(t *testing.T) {
1399 var (
1400:8nested-structsmove nested anonymous struct types to named declarations

copier_test.go:1400:8

1399 var (
1400 from struct {
1401 S string
1409:6nested-structsmove nested anonymous struct types to named declarations

copier_test.go:1409:6

1408
1409 to struct {
1410 S sql.NullString
1428:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1428:12

1427 if from.T1.Valid || from.T2.Valid {
1428 t.Errorf("Must be not valid")
1429 }
1450:2discarded-error-resulterror result returned by from.T1.Scan is discarded

copier_test.go:1450:2

1449
1450 from.T1.Scan(now)
1451 from.T2.Scan(now)
1451:2discarded-error-resulterror result returned by from.T2.Scan is discarded

copier_test.go:1451:2

1450 from.T1.Scan(now)
1451 from.T2.Scan(now)
1452
1459:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1459:12

1458 if to.S.String != from.S {
1459 t.Errorf("Field S should be copied")
1460 }
1463:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1463:12

1462 if to.Sptr.String != *from.Sptr {
1463 t.Errorf("Field Sptr should be copied")
1464 }
1466:5time-value-equalitycompare time.Time values with Time.Equal instead of == or !=

copier_test.go:1466:5

1465
1466 if from.T1.Time != to.T1 {
1467 t.Errorf("Fields T1 fields should be equal")
1467:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1467:12

1466 if from.T1.Time != to.T1 {
1467 t.Errorf("Fields T1 fields should be equal")
1468 }
1470:5time-value-equalitycompare time.Time values with Time.Equal instead of == or !=

copier_test.go:1470:5

1469
1470 if from.T2.Time != *to.T2 {
1471 t.Errorf("Fields T2 fields should be equal")
1471:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1471:12

1470 if from.T2.Time != *to.T2 {
1471 t.Errorf("Fields T2 fields should be equal")
1472 }
1475:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1475:6

1474
1475func TestDeepCopyInterface(t *testing.T) {
1476 m := make(map[string]string)
1479:12use-anyuse any instead of interface{}

copier_test.go:1479:12

1478
1479 from := []interface{}{[]int{7, 8, 9}, 2, 3, m, errors.New("aaaa")}
1480 var to []interface{}
1480:11use-anyuse any instead of interface{}

copier_test.go:1480:11

1479 from := []interface{}{[]int{7, 8, 9}, 2, 3, m, errors.New("aaaa")}
1480 var to []interface{}
1481
1482:2discarded-error-resulterror result returned by copier.CopyWithOption is discarded

copier_test.go:1482:2

1481
1482 copier.CopyWithOption(&to, &from, copier.Option{
1483 IgnoreEmpty: false,
1487:9unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:1487:9

1486
1487 from[0].([]int)[0] = 10
1488 from[1] = "3"
1489:9unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:1489:9

1488 from[1] = "3"
1489 from[3].(map[string]string)["a"] = "bbb"
1490
1499:10unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:1499:10

1498
1499 if to[3].(map[string]string)["a"] != "ccc" {
1500 t.Errorf("to value failed to be deep copied")
1500:12add-constantstring literal "to value failed to be deep copied" appears more than twice; define a constant

copier_test.go:1500:12

1499 if to[3].(map[string]string)["a"] != "ccc" {
1500 t.Errorf("to value failed to be deep copied")
1501 }
1504:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1504:6

1503
1504func TestDeepCopyTime(t *testing.T) {
1505 type embedT1 struct {
1514:8nested-structsmove nested anonymous struct types to named declarations

copier_test.go:1514:8

1513 var (
1514 from struct {
1515 T1 time.Time
1524:6nested-structsmove nested anonymous struct types to named declarations

copier_test.go:1524:6

1523
1524 to struct {
1525 T1 time.Time
1554:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1554:12

1553 if !to.T1.Equal(from.T1) {
1554 t.Errorf("Field T1 should be copied")
1555 }
1557:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1557:12

1556 if !to.T2.Equal(*from.T2) {
1557 t.Errorf("Field T2 should be copied")
1558 }
1560:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1560:12

1559 if !to.T3.Equal(*from.T3) {
1560 t.Errorf("Field T3 should be copied")
1561 }
1563:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1563:12

1562 if !to.T4.Equal(from.T4) {
1563 t.Errorf("Field T4 should be copied")
1564 }
1566:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1566:12

1565 if !to.T5.Equal(from.T5) {
1566 t.Errorf("Field T5 should be copied")
1567 }
1569:12error-stringserror string should not be capitalized or end with punctuation

copier_test.go:1569:12

1568 if !to.T6.Equal(from.T6) {
1569 t.Errorf("Field T6 should be copied")
1570 }
1573:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1573:6

1572
1573func TestNestedPrivateData(t *testing.T) {
1574 type hasPrivate struct {
1610:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1610:6

1609
1610func TestDeepMapCopyTime(t *testing.T) {
1611 t1 := time.Now()
1613:23use-anyuse any instead of interface{}

copier_test.go:1613:23

1612 t2 := t1.Add(time.Second)
1613 from := []map[string]interface{}{
1614 {
1619:26use-anyuse any instead of interface{}

copier_test.go:1619:26

1618 }
1619 to := make([]map[string]interface{}, len(from))
1620
1628:17unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:1628:17

1627 }
1628 if !to[0]["t1"].(time.Time).Equal(from[0]["t1"].(time.Time)) {
1629 t.Errorf("nested time ptr should be copied")
1628:44add-constantstring literal "t1" appears more than twice; define a constant

copier_test.go:1628:44

1627 }
1628 if !to[0]["t1"].(time.Time).Equal(from[0]["t1"].(time.Time)) {
1629 t.Errorf("nested time ptr should be copied")
1628:49unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:1628:49

1627 }
1628 if !to[0]["t1"].(time.Time).Equal(from[0]["t1"].(time.Time)) {
1629 t.Errorf("nested time ptr should be copied")
1631:17unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:1631:17

1630 }
1631 if !to[0]["t2"].(*time.Time).Equal(*from[0]["t2"].(*time.Time)) {
1632 t.Errorf("nested time ptr should be copied")
1631:46add-constantstring literal "t2" appears more than twice; define a constant

copier_test.go:1631:46

1630 }
1631 if !to[0]["t2"].(*time.Time).Equal(*from[0]["t2"].(*time.Time)) {
1632 t.Errorf("nested time ptr should be copied")
1631:51unchecked-type-assertionuse the checked two-result form of the type assertion

copier_test.go:1631:51

1630 }
1631 if !to[0]["t2"].(*time.Time).Equal(*from[0]["t2"].(*time.Time)) {
1632 t.Errorf("nested time ptr should be copied")
1636:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1636:6

1635
1636func TestCopySimpleTime(t *testing.T) {
1637 from := time.Now()
1649:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1649:6

1648
1649func TestDeepCopySimpleTime(t *testing.T) {
1650 from := time.Now()
1655:11add-constantstring literal "should not error" appears more than twice; define a constant

copier_test.go:1655:11

1654 if err != nil {
1655 t.Error("should not error")
1656 }
1662:6exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1662:6

1661
1662type TimeWrapper struct {
1663 time.Time
1662:6max-public-structsfile declares more than 5 exported structs

copier_test.go:1662:6

1661
1662type TimeWrapper struct {
1663 time.Time
1666:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1666:6

1665
1666func TestDeepCopyAnonymousFieldTime(t *testing.T) {
1667 from := TimeWrapper{time.Now()}
1675:12add-constantstring literal "to (%v) value should equal from (%v) value" appears more than twice; define a constant

copier_test.go:1675:12

1674 if !from.Time.Equal(to.Time) {
1675 t.Errorf("to (%v) value should equal from (%v) value", to.Time, from.Time)
1676 }
1679:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1679:6

1678
1679func TestSqlNullFiled(t *testing.T) {
1680
1718:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1718:6

1717
1718func TestEmptySlice(t *testing.T) {
1719 type Str1 string
1719:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1719:7

1718func TestEmptySlice(t *testing.T) {
1719 type Str1 string
1720 type Str2 string
1720:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1720:7

1719 type Str1 string
1720 type Str2 string
1721 type Input1 struct {
1721:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1721:7

1720 type Str2 string
1721 type Input1 struct {
1722 Val Str1
1721:7max-public-structsfile declares more than 5 exported structs

copier_test.go:1721:7

1720 type Str2 string
1721 type Input1 struct {
1722 Val Str1
1724:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1724:7

1723 }
1724 type Input2 struct {
1725 Val Str2
1724:7max-public-structsfile declares more than 5 exported structs

copier_test.go:1724:7

1723 }
1724 type Input2 struct {
1725 Val Str2
1748:6test-parallelismconsider calling t.Parallel() when this test begins

copier_test.go:1748:6

1747
1748func TestNestedNilPointerStruct(t *testing.T) {
1749 type destination struct {
1753:7exported-declaration-commentexported type should have a comment beginning with its name

copier_test.go:1753:7

1752
1753 type NestedSource struct {
1754 ID int
1753:7max-public-structsfile declares more than 5 exported structs

copier_test.go:1753:7

1752
1753 type NestedSource struct {
1754 ID int

errors.go11

1:9package-commentspackage should have a documentation comment

errors.go:1:9

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

errors.go:6:2

5var (
6 ErrInvalidCopyDestination = errors.New("copy destination must be non-nil and addressable")
7 ErrInvalidCopyFrom = errors.New("copy from must be non-nil and addressable")
6:2no-package-varpackage variables introduce mutable global state

errors.go:6:2

5var (
6 ErrInvalidCopyDestination = errors.New("copy destination must be non-nil and addressable")
7 ErrInvalidCopyFrom = errors.New("copy from must be non-nil and addressable")
7:2exported-declaration-commentexported declaration should have a comment beginning with its name

errors.go:7:2

6 ErrInvalidCopyDestination = errors.New("copy destination must be non-nil and addressable")
7 ErrInvalidCopyFrom = errors.New("copy from must be non-nil and addressable")
8 ErrMapKeyNotMatch = errors.New("map's key type doesn't match")
7:2no-package-varpackage variables introduce mutable global state

errors.go:7:2

6 ErrInvalidCopyDestination = errors.New("copy destination must be non-nil and addressable")
7 ErrInvalidCopyFrom = errors.New("copy from must be non-nil and addressable")
8 ErrMapKeyNotMatch = errors.New("map's key type doesn't match")
8:2exported-declaration-commentexported declaration should have a comment beginning with its name

errors.go:8:2

7 ErrInvalidCopyFrom = errors.New("copy from must be non-nil and addressable")
8 ErrMapKeyNotMatch = errors.New("map's key type doesn't match")
9 ErrNotSupported = errors.New("not supported")
8:2no-package-varpackage variables introduce mutable global state

errors.go:8:2

7 ErrInvalidCopyFrom = errors.New("copy from must be non-nil and addressable")
8 ErrMapKeyNotMatch = errors.New("map's key type doesn't match")
9 ErrNotSupported = errors.New("not supported")
9:2exported-declaration-commentexported declaration should have a comment beginning with its name

errors.go:9:2

8 ErrMapKeyNotMatch = errors.New("map's key type doesn't match")
9 ErrNotSupported = errors.New("not supported")
10 ErrFieldNameTagStartNotUpperCase = errors.New("copier field name tag must be start upper case")
9:2no-package-varpackage variables introduce mutable global state

errors.go:9:2

8 ErrMapKeyNotMatch = errors.New("map's key type doesn't match")
9 ErrNotSupported = errors.New("not supported")
10 ErrFieldNameTagStartNotUpperCase = errors.New("copier field name tag must be start upper case")
10:2exported-declaration-commentexported declaration should have a comment beginning with its name

errors.go:10:2

9 ErrNotSupported = errors.New("not supported")
10 ErrFieldNameTagStartNotUpperCase = errors.New("copier field name tag must be start upper case")
11)
10:2no-package-varpackage variables introduce mutable global state

errors.go:10:2

9 ErrNotSupported = errors.New("not supported")
10 ErrFieldNameTagStartNotUpperCase = errors.New("copier field name tag must be start upper case")
11)