You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pkg/analysis/optionalfields/testdata/src/a/a.go
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -19,36 +19,36 @@ type A struct {
19
19
20
20
// string is a string field.
21
21
// +optional
22
-
Stringstring`json:"string,omitempty"`// want "field String should be a pointer."
22
+
Stringstring`json:"string,omitempty"`// want "field A.String should be a pointer."
23
23
24
24
// NonOmittedString is a string field without omitempty
25
25
// +optional
26
-
NonOmittedStringstring`json:"nonOmittedString"`// want "field NonOmittedString should be a pointer." "field NonOmittedString should have the omitempty tag."
26
+
NonOmittedStringstring`json:"nonOmittedString"`// want "field A.NonOmittedString should be a pointer." "field A.NonOmittedString should have the omitempty tag."
27
27
28
28
// int is an int field.
29
29
// +optional
30
-
Intint`json:"int,omitempty"`// want "field Int should be a pointer."
30
+
Intint`json:"int,omitempty"`// want "field A.Int should be a pointer."
31
31
32
32
// nonOmittedInt is an int field without omitempty
33
33
// +optional
34
-
NonOmittedIntint`json:"nonOmittedInt"`// want "field NonOmittedInt should be a pointer." "field NonOmittedInt should have the omitempty tag."
34
+
NonOmittedIntint`json:"nonOmittedInt"`// want "field A.NonOmittedInt should be a pointer." "field A.NonOmittedInt should have the omitempty tag."
35
35
36
36
// struct is a struct field.
37
37
// +optional
38
-
StructB`json:"struct,omitempty"`// want "field Struct should be a pointer."
38
+
StructB`json:"struct,omitempty"`// want "field A.Struct should be a pointer."
39
39
40
40
// nonOmittedStruct is a struct field without omitempty.
41
41
// +optional
42
-
NonOmittedStructB`json:"nonOmittedStruct"`// want "field NonOmittedStruct should be a pointer." "field NonOmittedStruct should have the omitempty tag."
42
+
NonOmittedStructB`json:"nonOmittedStruct"`// want "field A.NonOmittedStruct should be a pointer." "field A.NonOmittedStruct should have the omitempty tag."
43
43
44
44
// structWithMinProperties is a struct field with a minimum number of properties.
45
45
// +kubebuilder:validation:MinProperties=1
46
46
// +optional
47
-
StructWithMinPropertiesB`json:"structWithMinProperties,omitempty"`// want "field StructWithMinProperties should be a pointer."
47
+
StructWithMinPropertiesB`json:"structWithMinProperties,omitempty"`// want "field A.StructWithMinProperties should be a pointer."
48
48
49
49
// structWithMinPropertiesOnStruct is a struct field with a minimum number of properties on the struct.
50
50
// +optional
51
-
StructWithMinPropertiesOnStructD`json:"structWithMinPropertiesOnStruct,omitempty"`// want "field StructWithMinPropertiesOnStruct should be a pointer."
51
+
StructWithMinPropertiesOnStructD`json:"structWithMinPropertiesOnStruct,omitempty"`// want "field A.StructWithMinPropertiesOnStruct should be a pointer."
52
52
53
53
// slice is a slice field.
54
54
// +optional
@@ -60,15 +60,15 @@ type A struct {
60
60
61
61
// PointerSlice is a pointer slice field.
62
62
// +optional
63
-
PointerSlice*[]string`json:"pointerSlice,omitempty"`// want "field PointerSlice underlying type does not need to be a pointer. The pointer should be removed."
63
+
PointerSlice*[]string`json:"pointerSlice,omitempty"`// want "field A.PointerSlice underlying type does not need to be a pointer. The pointer should be removed."
64
64
65
65
// PointerMap is a pointer map field.
66
66
// +optional
67
-
PointerMap*map[string]string`json:"pointerMap,omitempty"`// want "field PointerMap underlying type does not need to be a pointer. The pointer should be removed."
67
+
PointerMap*map[string]string`json:"pointerMap,omitempty"`// want "field A.PointerMap underlying type does not need to be a pointer. The pointer should be removed."
68
68
69
69
// PointerPointerString is a double pointer string field.
70
70
// +optional
71
-
DoublePointerString**string`json:"doublePointerString,omitempty"`// want "field DoublePointerString underlying type does not need to be a pointer. The pointer should be removed."
71
+
DoublePointerString**string`json:"doublePointerString,omitempty"`// want "field A.DoublePointerString underlying type does not need to be a pointer. The pointer should be removed."
72
72
73
73
// PointerStringAlias is a pointer string alias field.
74
74
// +optional
@@ -93,16 +93,16 @@ type A struct {
93
93
94
94
// PointerSliceAlias is a pointer slice alias field.
95
95
// +optional
96
-
PointerSliceAlias*SliceAlias`json:"pointerSliceAlias,omitempty"`// want "field PointerSliceAlias underlying type does not need to be a pointer. The pointer should be removed."
96
+
PointerSliceAlias*SliceAlias`json:"pointerSliceAlias,omitempty"`// want "field A.PointerSliceAlias underlying type does not need to be a pointer. The pointer should be removed."
97
97
98
98
// PointerMapAlias is a pointer map alias field.
99
99
// +optional
100
-
PointerMapAlias*MapAlias`json:"pointerMapAlias,omitempty"`// want "field PointerMapAlias underlying type does not need to be a pointer. The pointer should be removed."
100
+
PointerMapAlias*MapAlias`json:"pointerMapAlias,omitempty"`// want "field A.PointerMapAlias underlying type does not need to be a pointer. The pointer should be removed."
101
101
102
102
// StringAliasWithEnum is a string alias field with enum validation.
103
103
// With the "Always" pointer preference, optional fields should be pointers regardless of zero value validity.
104
104
// +optional
105
-
StringAliasWithEnumStringAliasWithEnum`json:"stringAliasWithEnum,omitempty"`// want "field StringAliasWithEnum should be a pointer."
105
+
StringAliasWithEnumStringAliasWithEnum`json:"stringAliasWithEnum,omitempty"`// want "field A.StringAliasWithEnum should be a pointer."
106
106
107
107
// StringAliasWithEnumPointer is a pointer string alias field with enum validation.
108
108
// This is correctly a pointer since the zero value is not valid.
@@ -111,7 +111,7 @@ type A struct {
111
111
112
112
// StringAliasWithEnumNoOmitEmpty is a string alias field with enum validation and no omitempty.
113
113
// +optional
114
-
StringAliasWithEnumNoOmitEmpty*StringAliasWithEnum`json:"stringAliasWithEnumNoOmitEmpty"`// want "field StringAliasWithEnumNoOmitEmpty should have the omitempty tag."
114
+
StringAliasWithEnumNoOmitEmpty*StringAliasWithEnum`json:"stringAliasWithEnumNoOmitEmpty"`// want "field A.StringAliasWithEnumNoOmitEmpty should have the omitempty tag."
Copy file name to clipboardExpand all lines: pkg/analysis/optionalfields/testdata/src/a/a.go.golden
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -19,36 +19,36 @@ type A struct {
19
19
20
20
// string is a string field.
21
21
// +optional
22
-
String *string `json:"string,omitempty"` // want "field String should be a pointer."
22
+
String *string `json:"string,omitempty"` // want "field A.String should be a pointer."
23
23
24
24
// NonOmittedString is a string field without omitempty
25
25
// +optional
26
-
NonOmittedString *string `json:"nonOmittedString,omitempty"` // want "field NonOmittedString should be a pointer." "field NonOmittedString should have the omitempty tag."
26
+
NonOmittedString *string `json:"nonOmittedString,omitempty"` // want "field A.NonOmittedString should be a pointer." "field A.NonOmittedString should have the omitempty tag."
27
27
28
28
// int is an int field.
29
29
// +optional
30
-
Int *int `json:"int,omitempty"` // want "field Int should be a pointer."
30
+
Int *int `json:"int,omitempty"` // want "field A.Int should be a pointer."
31
31
32
32
// nonOmittedInt is an int field without omitempty
33
33
// +optional
34
-
NonOmittedInt *int `json:"nonOmittedInt,omitempty"` // want "field NonOmittedInt should be a pointer." "field NonOmittedInt should have the omitempty tag."
34
+
NonOmittedInt *int `json:"nonOmittedInt,omitempty"` // want "field A.NonOmittedInt should be a pointer." "field A.NonOmittedInt should have the omitempty tag."
35
35
36
36
// struct is a struct field.
37
37
// +optional
38
-
Struct *B `json:"struct,omitempty"` // want "field Struct should be a pointer."
38
+
Struct *B `json:"struct,omitempty"` // want "field A.Struct should be a pointer."
39
39
40
40
// nonOmittedStruct is a struct field without omitempty.
41
41
// +optional
42
-
NonOmittedStruct *B `json:"nonOmittedStruct,omitempty"` // want "field NonOmittedStruct should be a pointer." "field NonOmittedStruct should have the omitempty tag."
42
+
NonOmittedStruct *B `json:"nonOmittedStruct,omitempty"` // want "field A.NonOmittedStruct should be a pointer." "field A.NonOmittedStruct should have the omitempty tag."
43
43
44
44
// structWithMinProperties is a struct field with a minimum number of properties.
45
45
// +kubebuilder:validation:MinProperties=1
46
46
// +optional
47
-
StructWithMinProperties *B `json:"structWithMinProperties,omitempty"` // want "field StructWithMinProperties should be a pointer."
47
+
StructWithMinProperties *B `json:"structWithMinProperties,omitempty"` // want "field A.StructWithMinProperties should be a pointer."
48
48
49
49
// structWithMinPropertiesOnStruct is a struct field with a minimum number of properties on the struct.
50
50
// +optional
51
-
StructWithMinPropertiesOnStruct *D `json:"structWithMinPropertiesOnStruct,omitempty"` // want "field StructWithMinPropertiesOnStruct should be a pointer."
51
+
StructWithMinPropertiesOnStruct *D `json:"structWithMinPropertiesOnStruct,omitempty"` // want "field A.StructWithMinPropertiesOnStruct should be a pointer."
52
52
53
53
// slice is a slice field.
54
54
// +optional
@@ -60,15 +60,15 @@ type A struct {
60
60
61
61
// PointerSlice is a pointer slice field.
62
62
// +optional
63
-
PointerSlice []string `json:"pointerSlice,omitempty"` // want "field PointerSlice underlying type does not need to be a pointer. The pointer should be removed."
63
+
PointerSlice []string `json:"pointerSlice,omitempty"` // want "field A.PointerSlice underlying type does not need to be a pointer. The pointer should be removed."
64
64
65
65
// PointerMap is a pointer map field.
66
66
// +optional
67
-
PointerMap map[string]string `json:"pointerMap,omitempty"` // want "field PointerMap underlying type does not need to be a pointer. The pointer should be removed."
67
+
PointerMap map[string]string `json:"pointerMap,omitempty"` // want "field A.PointerMap underlying type does not need to be a pointer. The pointer should be removed."
68
68
69
69
// PointerPointerString is a double pointer string field.
70
70
// +optional
71
-
DoublePointerString *string `json:"doublePointerString,omitempty"` // want "field DoublePointerString underlying type does not need to be a pointer. The pointer should be removed."
71
+
DoublePointerString *string `json:"doublePointerString,omitempty"` // want "field A.DoublePointerString underlying type does not need to be a pointer. The pointer should be removed."
72
72
73
73
// PointerStringAlias is a pointer string alias field.
74
74
// +optional
@@ -93,16 +93,16 @@ type A struct {
93
93
94
94
// PointerSliceAlias is a pointer slice alias field.
95
95
// +optional
96
-
PointerSliceAlias SliceAlias `json:"pointerSliceAlias,omitempty"` // want "field PointerSliceAlias underlying type does not need to be a pointer. The pointer should be removed."
96
+
PointerSliceAlias SliceAlias `json:"pointerSliceAlias,omitempty"` // want "field A.PointerSliceAlias underlying type does not need to be a pointer. The pointer should be removed."
97
97
98
98
// PointerMapAlias is a pointer map alias field.
99
99
// +optional
100
-
PointerMapAlias MapAlias `json:"pointerMapAlias,omitempty"` // want "field PointerMapAlias underlying type does not need to be a pointer. The pointer should be removed."
100
+
PointerMapAlias MapAlias `json:"pointerMapAlias,omitempty"` // want "field A.PointerMapAlias underlying type does not need to be a pointer. The pointer should be removed."
101
101
102
102
// StringAliasWithEnum is a string alias field with enum validation.
103
103
// With the "Always" pointer preference, optional fields should be pointers regardless of zero value validity.
104
104
// +optional
105
-
StringAliasWithEnum *StringAliasWithEnum `json:"stringAliasWithEnum,omitempty"` // want "field StringAliasWithEnum should be a pointer."
105
+
StringAliasWithEnum *StringAliasWithEnum `json:"stringAliasWithEnum,omitempty"` // want "field A.StringAliasWithEnum should be a pointer."
106
106
107
107
// StringAliasWithEnumPointer is a pointer string alias field with enum validation.
108
108
// This is correctly a pointer since the zero value is not valid.
@@ -111,7 +111,7 @@ type A struct {
111
111
112
112
// StringAliasWithEnumNoOmitEmpty is a string alias field with enum validation and no omitempty.
113
113
// +optional
114
-
StringAliasWithEnumNoOmitEmpty *StringAliasWithEnum `json:"stringAliasWithEnumNoOmitEmpty,omitempty"` // want "field StringAliasWithEnumNoOmitEmpty should have the omitempty tag."
114
+
StringAliasWithEnumNoOmitEmpty *StringAliasWithEnum `json:"stringAliasWithEnumNoOmitEmpty,omitempty"` // want "field A.StringAliasWithEnumNoOmitEmpty should have the omitempty tag."
0 commit comments