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: docs/linters.md
+5-13Lines changed: 5 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -629,13 +629,13 @@ lintersConfig:
629
629
-**Allows** fields containing 'Ref' or 'Refs' without reporting errors
630
630
631
631
**Strict mode (policy: NoReferences):**
632
-
-Reports errors for any reference-related words in field names
633
-
-Suggests removing 'Ref', 'Refs', 'Reference', or 'References' entirely from the beginning or end of field names
634
-
- In this strict mode, the goal is to avoid all reference-related words in field names
632
+
-**Warns** about any reference-related words ('Ref', 'Refs', 'Reference', or 'References') in field names
633
+
-Does not provide automatic fixes - serves as an informational warning
634
+
- In this strict mode, the goal is to inform developers about reference-related words in field names
635
635
636
636
### Fixes
637
637
638
-
The `noreferences` linter can automatically fix field names based on the policy:
638
+
The `noreferences` linter can automatically fix field names in **PreferAbbreviatedReference mode**:
639
639
640
640
**PreferAbbreviatedReference mode:**
641
641
- Replaces 'Reference' with 'Ref' and 'References' with 'Refs' at the start or end of field names
@@ -647,15 +647,7 @@ The `noreferences` linter can automatically fix field names based on the policy:
647
647
-`ReferencesCount` → `RefsCount` (start)
648
648
-`PreferenceType` → no change (middle - not flagged)
649
649
650
-
**NoReferences mode:**
651
-
- Removes all reference-related words (Ref/Refs/Reference/References) from the beginning or end of field names
652
-
- Like PreferAbbreviatedReference, this only matches at word boundaries to avoid false positives
653
-
- Examples:
654
-
-`RefNode` → `Node` (start)
655
-
-`NodeRef` → `Node` (end)
656
-
-`ReferenceName` → `Name` (start)
657
-
-`ConfigReferences` → `Config` (end)
658
-
-`ReferenceCount` → `Count` (start)
650
+
**Note:** NoReferences policy does not provide automatic fixes. It only reports warnings to inform developers about the presence of reference-related words in field names.
Copy file name to clipboardExpand all lines: pkg/analysis/noreferences/testdata/src/b/b.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
package b
2
2
3
3
// TestWithPolicyNoReferences tests the linter with PolicyNoReferences (strict mode)
4
-
// In this mode, all reference-related words (Reference/References/Ref/Refs) are removed
4
+
// In this mode, all reference-related words (Reference/References/Ref/Refs) are warned about but not removed
5
5
typeTestWithPolicyNoReferencesstruct {
6
6
// Fields ending with Reference should be flagged
7
7
NodeReferencestring`json:"nodeReference"`// want `naming convention "no-references": field NodeReference: field names should not contain reference-related words`
0 commit comments