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
return field.ErrorList{field.Invalid(fldPath, operation, fmt.Sprintf("operation must be one of %q, %q, %q, or %q", OperationInform, OperationDrop, OperationDropField, OperationReplace))}
113
+
return field.ErrorList{field.Invalid(fldPath, operation, fmt.Sprintf("operation must be one of %q, %q, %q, or %q", OperationInform, OperationDrop, OperationDropField, OperationReplacement))}
expectedErr: "namingconventions.conventions[0].operation: Invalid value: \"Unknown\": operation must be one of \"Inform\", \"Drop\", \"DropField\", or \"Replace\"",
154
+
expectedErr: "namingconventions.conventions[0].operation: Invalid value: \"Unknown\": operation must be one of \"Inform\", \"Drop\", \"DropField\", or \"Replacement\"",
155
155
}),
156
-
Entry("With an invalid namingconventions configuration with a replace when operation is not 'Replace'", testCase{
156
+
Entry("With an invalid namingconventions configuration with a replacement when operation is not 'replacement'", testCase{
157
157
config: &namingconventions.Config{
158
158
Conventions: []namingconventions.Convention{
159
159
{
160
160
Name: "nothing",
161
161
ViolationMatcher: "(?i)thing",
162
162
Operation: namingconventions.OperationDrop,
163
163
Message: "no fields should have any variations of the word 'thing' in their name",
164
-
Replace: "item",
164
+
Replacement:"item",
165
165
},
166
166
},
167
167
},
168
-
expectedErr: "namingconventions.conventions[0].replace: Invalid value: \"item\": replace must be specified when operation is 'Replace' and is forbidden otherwise",
168
+
expectedErr: "namingconventions.conventions[0].replacement: Invalid value: \"item\": replacement must be specified when operation is 'Replacement' and is forbidden otherwise",
169
169
}),
170
-
Entry("With an invalid namingconventions configuration with no replace when operation is 'Replace'", testCase{
170
+
Entry("With an invalid namingconventions configuration with no replacement when operation is 'replacement'", testCase{
Message: "no fields should have any variations of the word 'thing' in their name",
178
178
},
179
179
},
180
180
},
181
-
expectedErr: "namingconventions.conventions[0].replace: Invalid value: \"\": replace must be specified when operation is 'Replace' and is forbidden otherwise",
181
+
expectedErr: "namingconventions.conventions[0].replacement: Invalid value: \"\": replacement must be specified when operation is 'Replacement' and is forbidden otherwise",
182
182
}),
183
183
Entry("With an invalid namingconventions configuration where replacement string matches violationMatcher", testCase{
Copy file name to clipboardExpand all lines: pkg/analysis/namingconventions/testdata/src/a/a.go
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,12 @@ package a
2
2
3
3
// Shouldn't care about Go types
4
4
typeBasketOfFruitstruct {
5
-
RedFruit []string`json:"redFruit,omitempty"`// want `naming convention "nofruit": no fields should contain any variations of the word 'fruit' in their name`
6
-
OrangeFruit []string`json:"orangeFruit,omitempty"`// want `naming convention "nofruit": no fields should contain any variations of the word 'fruit' in their name`
7
-
GreenFruit []string`json:"greenFruit,omitempty"`// want `naming convention "nofruit": no fields should contain any variations of the word 'fruit' in their name`
8
-
FruitBlue []string`json:"fruitBlue,omitempty"`// want `naming convention "nofruit": no fields should contain any variations of the word 'fruit' in their name`
9
-
Fruit []string`json:"fruit,omitempty"`// want `naming convention "nofruit": no fields should contain any variations of the word 'fruit' in their name`
10
-
AFruitstring`json:"aFruit,omitempty"`// want `naming convention "nofruit": no fields should contain any variations of the word 'fruit' in their name`
5
+
RedFruit []string`json:"redFruit,omitempty"`// want `naming convention "nofruit": field RedFruit: no fields should contain any variations of the word 'fruit' in their name`
6
+
OrangeFruit []string`json:"orangeFruit,omitempty"`// want `naming convention "nofruit": field OrangeFruit: no fields should contain any variations of the word 'fruit' in their name`
7
+
GreenFruit []string`json:"greenFruit,omitempty"`// want `naming convention "nofruit": field GreenFruit: no fields should contain any variations of the word 'fruit' in their name`
8
+
FruitBlue []string`json:"fruitBlue,omitempty"`// want `naming convention "nofruit": field FruitBlue: no fields should contain any variations of the word 'fruit' in their name`
9
+
Fruit []string`json:"fruit,omitempty"`// want `naming convention "nofruit": field Fruit: no fields should contain any variations of the word 'fruit' in their name`
10
+
AFruitstring`json:"aFruit,omitempty"`// want `naming convention "nofruit": field AFruit: no fields should contain any variations of the word 'fruit' in their name`
11
11
}
12
12
13
13
// Shouldn't care about methods
@@ -21,16 +21,16 @@ func IsFruit(in string) {
21
21
}
22
22
23
23
typeSpecialBehaviorsstruct {
24
-
SomethingBehaviorstring`json:"somethingBehavior,omitempty"`// want `naming convention "preferbehaviour": prefer the use of the word 'behaviour' instead of 'behavior'.`
25
-
BehaviorCrazybool`json:"behaviorCrazy,omitempty"`// want `naming convention "preferbehaviour": prefer the use of the word 'behaviour' instead of 'behavior'.`
24
+
SomethingBehaviorstring`json:"somethingBehavior,omitempty"`// want `naming convention "preferbehaviour": field SomethingBehavior: prefer the use of the word 'behaviour' instead of 'behavior'.`
25
+
BehaviorCrazybool`json:"behaviorCrazy,omitempty"`// want `naming convention "preferbehaviour": field BehaviorCrazy: prefer the use of the word 'behaviour' instead of 'behavior'.`
UnsupportedThingystring`json:"unsupportedThingy,omitempty"`// want `naming convention "nounsupported": no fields allowing for unsupported behaviors allowed`
30
+
UnsupportedThingystring`json:"unsupportedThingy,omitempty"`// want `naming convention "nounsupported": field UnsupportedThingy: no fields allowing for unsupported behaviors allowed`
31
31
}
32
32
33
33
typeTestSetstruct {
34
-
TestNamestring`json:"testName,omitempty"`// want `naming convention "notest": no temporary test fields`
35
-
Otherstring`json:"otherTest,omitempty"`// want `naming convention "notest": no temporary test fields`
34
+
TestNamestring`json:"testName,omitempty"`// want `naming convention "notest": field TestName: no temporary test fields`
35
+
Otherstring`json:"otherTest,omitempty"`// want `naming convention "notest": field Other: no temporary test fields`
0 commit comments