Skip to content

Conversation

@saschagrunert
Copy link
Member

@saschagrunert saschagrunert commented Nov 10, 2025

This fixes issue #53 by detecting kubebuilder markers that are separated
from type declarations by blank lines. Both single-line and multi-line
marker groups are now properly detected.

  • Modified marker analyzer to check the previous comment group
  • Added extractOrphanedMarkers and helper functions
  • Added constants for marker prefix and separation limits
  • Added logic to skip commented-out code blocks
  • Renamed containsMultilineMarkers to containsMarkers for clarity
  • Added comprehensive test cases covering:
    • Multi-line markers with blank lines (BlankLineTest)
    • Single-line markers with blank lines (SingleLineMarkerTest)
    • Distance limits preventing false positives (TooFarAwayTest)
    • Commented-out code rejection (CommentedCodeTest)
    • List types with blank line markers (ServiceList)

@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 Nov 10, 2025
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 10, 2025
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 10, 2025
@saschagrunert saschagrunert force-pushed the fix-issue-53-second-level-comment-bug branch 13 times, most recently from 6e5b936 to 41060d9 Compare November 11, 2025 10:58
@saschagrunert saschagrunert changed the title WIP: Detect markers separated by blank lines from type declarations Detect markers separated by blank lines from type declarations Nov 11, 2025
@saschagrunert saschagrunert marked this pull request as ready for review November 11, 2025 10:59
@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 Nov 11, 2025
Comment on lines 214 to 218
// SingleLineMarkerTest has a single marker separated by blank line.
// This marker should still be detected because it's part of the Doc comment group.
type SingleLineMarkerTest struct {
Name string `json:"name"`
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we know that the marker is being detected?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right. I've updated the implementation to actually detect single-line markers separated by blank lines.

@saschagrunert saschagrunert force-pushed the fix-issue-53-second-level-comment-bug branch from 41060d9 to 847529f Compare November 13, 2025 08:50
@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 sivchari 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 13, 2025
@saschagrunert saschagrunert force-pushed the fix-issue-53-second-level-comment-bug branch from 847529f to 4a14f71 Compare November 13, 2025 08:57
This fixes issue kubernetes-sigs#53 by detecting kubebuilder markers that are separated
from type declarations by blank lines. Both single-line and multi-line
marker groups are now properly detected.

- Modified marker analyzer to check the previous comment group
- Added extractOrphanedMarkers and helper functions
- Added constants for marker prefix and separation limits
- Added logic to skip commented-out code blocks
- Renamed containsMultilineMarkers to containsMarkers for clarity
- Added comprehensive test cases covering:
  - Multi-line markers with blank lines (BlankLineTest)
  - Single-line markers with blank lines (SingleLineMarkerTest)
  - Distance limits preventing false positives (TooFarAwayTest)
  - Commented-out code rejection (CommentedCodeTest)
  - List types with blank line markers (ServiceList)

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
@saschagrunert saschagrunert force-pushed the fix-issue-53-second-level-comment-bug branch from 4a14f71 to f28c4cf Compare November 13, 2025 08:58
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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants