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
Fix marker detection for fields with orphaned markers
Markers separated from field declarations by blank lines were not being
detected.
Example:
type FooStatus struct {
// +optional
// +listType=map
// Conditions update as changes occur.
Conditions []metav1.Condition
}
The fix detects orphaned marker blocks (containing only markers, no
prose) that precede a field's doc comment, while avoiding false
positives from adjacent field markers.
Performance optimizations:
- Pre-compute field Doc comment map to avoid O(n²) complexity
- Use regex validation instead of full marker parsing in containsOnlyMarkers
- Results in 93-95% reduction in AST node visits for files with orphaned markers
#53
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Copy file name to clipboardExpand all lines: pkg/analysis/conditions/testdata/src/a/a.go
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -104,3 +104,16 @@ type IncorrectFieldTag struct {
104
104
// +optional
105
105
Conditions []metav1.Condition`json:"conditions" patchMergeKey:"type" protobuf:"bytes,3,rep,name=conditions"`// want "Conditions field in IncorrectFieldTag has incorrect tags, should be: `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`"
106
106
}
107
+
108
+
// ConditionsWithOrphanedMarkers tests the fix for orphaned markers where markers
109
+
// separated from the field doc comment by a blank line were not being detected.
110
+
typeConditionsWithOrphanedMarkersstruct {
111
+
// +optional
112
+
// +listType=map
113
+
// +listMapKey=type
114
+
// +patchStrategy=merge
115
+
// +patchMergeKey=type
116
+
117
+
// Conditions update as changes occur in the status.
0 commit comments