Skip to content

Conversation

@saschagrunert
Copy link
Member

Markers separated from field declarations by blank lines were not being detected.

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.

Fixes #53

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 5, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: saschagrunert
Once this PR has been reviewed and has the lgtm label, please assign jpbetz for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 5, 2025
@saschagrunert saschagrunert changed the title WIP: Fix marker detection for fields with orphaned markers Fix marker detection for fields with orphaned markers Dec 5, 2025
@saschagrunert saschagrunert force-pushed the fix-field-orphaned-markers branch 4 times, most recently from 2082515 to c0f32c7 Compare December 5, 2025 10:28
@saschagrunert saschagrunert marked this pull request as ready for review December 5, 2025 13:00
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 5, 2025
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

kubernetes-sigs#53
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
@saschagrunert saschagrunert force-pushed the fix-field-orphaned-markers branch from c0f32c7 to 19f1732 Compare December 5, 2025 13:00
@saschagrunert saschagrunert changed the title Fix marker detection for fields with orphaned markers WIP: Fix marker detection for fields with orphaned markers Dec 5, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

markers helper can't detect markers which are separated with space.

2 participants