|
1 | 1 | package b |
2 | 2 |
|
3 | | -// TestWithPolicyForbidRefAndRefs tests the linter with PolicyForbidRefAndRefs (strict mode) |
4 | | -// In this mode, Reference/References AND Ref/Refs (at end) are flagged |
5 | | -type TestWithPolicyForbidRefAndRefs struct { |
| 3 | +// TestWithPolicyNoReferences tests the linter with PolicyNoReferences (strict mode) |
| 4 | +// In this mode, all reference-related words (Reference/References/Ref/Refs) are removed |
| 5 | +type TestWithPolicyNoReferences struct { |
6 | 6 | // Fields ending with Reference should be flagged |
7 | | - NodeReference string `json:"nodeReference"` // want `naming convention "reference-to-ref": field NodeReference: field names should use 'Ref' instead of 'Reference'` |
8 | | - |
9 | | - ConfigReference string `json:"configReference"` // want `naming convention "reference-to-ref": field ConfigReference: field names should use 'Ref' instead of 'Reference'` |
| 7 | + NodeReference string `json:"nodeReference"` // want `naming convention "no-references": field NodeReference: field names should not contain reference-related words` |
10 | 8 |
|
11 | 9 | // Fields ending with References should be flagged |
12 | | - NodeReferences []string `json:"nodeReferences"` // want `naming convention "reference-to-ref": field NodeReferences: field names should use 'Ref' instead of 'Reference'` |
13 | | - |
14 | | - ConfigReferences []string `json:"configReferences"` // want `naming convention "reference-to-ref": field ConfigReferences: field names should use 'Ref' instead of 'Reference'` |
| 10 | + ConfigReferences []string `json:"configReferences"` // want `naming convention "no-references": field ConfigReferences: field names should not contain reference-related words` |
15 | 11 |
|
16 | 12 | // Fields with Reference at beginning should be flagged |
17 | | - ReferenceCount int `json:"referenceCount"` // want `naming convention "reference-to-ref": field ReferenceCount: field names should use 'Ref' instead of 'Reference'` |
18 | | - |
19 | | - ReferenceData string `json:"referenceData"` // want `naming convention "reference-to-ref": field ReferenceData: field names should use 'Ref' instead of 'Reference'` |
| 13 | + ReferenceCount int `json:"referenceCount"` // want `naming convention "no-references": field ReferenceCount: field names should not contain reference-related words` |
20 | 14 |
|
21 | 15 | // Fields with References at beginning should be flagged |
22 | | - ReferencesCount int `json:"referencesCount"` // want `naming convention "reference-to-ref": field ReferencesCount: field names should use 'Ref' instead of 'Reference'` |
23 | | - |
24 | | - ReferencesData []string `json:"referencesData"` // want `naming convention "reference-to-ref": field ReferencesData: field names should use 'Ref' instead of 'Reference'` |
25 | | - |
26 | | - // Fields with Reference in middle should be flagged |
27 | | - CrossReferenceID string `json:"crossReferenceID"` // want `naming convention "reference-to-ref": field CrossReferenceID: field names should use 'Ref' instead of 'Reference'` |
28 | | - |
29 | | - // Fields with References in middle should be flagged |
30 | | - CrossReferencesMap map[string]string `json:"crossReferencesMap"` // want `naming convention "reference-to-ref": field CrossReferencesMap: field names should use 'Ref' instead of 'Reference'` |
| 16 | + ReferencesData []string `json:"referencesData"` // want `naming convention "no-references": field ReferencesData: field names should not contain reference-related words` |
31 | 17 |
|
32 | | - // Fields ending with Ref should be FORBIDDEN in this mode |
33 | | - NodeRef string `json:"nodeRef"` // want `naming convention "forbid-ref": field NodeRef: should not use 'Ref'` |
| 18 | + // Fields ending with Ref should be flagged |
| 19 | + PodRef string `json:"podRef"` // want `naming convention "no-references": field PodRef: field names should not contain reference-related words` |
34 | 20 |
|
35 | | - ConfigRef string `json:"configRef"` // want `naming convention "forbid-ref": field ConfigRef: should not use 'Ref'` |
| 21 | + // Fields ending with Refs should be flagged |
| 22 | + ContainerRefs []string `json:"containerRefs"` // want `naming convention "no-references": field ContainerRefs: field names should not contain reference-related words` |
36 | 23 |
|
37 | | - // Fields ending with Refs should be FORBIDDEN in this mode |
38 | | - NodeRefs []string `json:"nodeRefs"` // want `naming convention "forbid-refs": field NodeRefs: should not use 'Refs'` |
| 24 | + // Fields starting with Ref should be flagged |
| 25 | + RefStatus string `json:"refStatus"` // want `naming convention "no-references": field RefStatus: field names should not contain reference-related words` |
39 | 26 |
|
40 | | - ConfigRefs []string `json:"configRefs"` // want `naming convention "forbid-refs": field ConfigRefs: should not use 'Refs'` |
| 27 | + // Fields starting with Refs should be flagged |
| 28 | + RefsTotal int `json:"refsTotal"` // want `naming convention "no-references": field RefsTotal: field names should not contain reference-related words` |
41 | 29 |
|
42 | | - // Normal fields should not be flagged (no Reference/References/Ref/Refs) |
| 30 | + // Normal fields should not be flagged |
43 | 31 | Name string `json:"name"` |
44 | 32 |
|
45 | 33 | Namespace string `json:"namespace"` |
46 | 34 |
|
47 | | - // Edge cases - Preference contains "reference" and will be flagged |
48 | | - PreferenceType string `json:"preferenceType"` // want `naming convention "reference-to-ref": field PreferenceType: field names should use 'Ref' instead of 'Reference'` |
| 35 | + // Edge cases - "erence" in the middle of a word is not flagged (only start/end boundaries) |
| 36 | + PreferenceType string `json:"preferenceType"` |
49 | 37 |
|
50 | | - Preferences map[string]string `json:"preferences,omitempty"` // want `naming convention "reference-to-ref": field Preferences: field names should use 'Ref' instead of 'Reference'` |
| 38 | + // But "Preferences" ending with 's' after "erence" IS flagged since it ends with "ences" |
| 39 | + Preferences map[string]string `json:"preferences,omitempty"` // want `naming convention "no-references": field Preferences: field names should not contain reference-related words` |
51 | 40 | } |
0 commit comments