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 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
@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
@saschagrunert saschagrunert changed the title WIP: Fix marker detection for fields with orphaned markers Fix marker detection for fields with orphaned markers Dec 8, 2025
@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 8, 2025
@saschagrunert
Copy link
Member Author

The lint issue is inherited from main and should be fixed in #201

@JoelSpeed
Copy link
Contributor

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 8, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JoelSpeed, saschagrunert

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

The pull request process is described 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 8, 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 19f1732 to e13a02f Compare December 8, 2025 10:04
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 8, 2025
@saschagrunert
Copy link
Member Author

Rebased to the the linter fixes in.

@JoelSpeed
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 8, 2025
@k8s-ci-robot k8s-ci-robot merged commit d3015c9 into kubernetes-sigs:main Dec 8, 2025
5 checks passed
@saschagrunert saschagrunert deleted the fix-field-orphaned-markers branch December 8, 2025 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

3 participants