-
Notifications
You must be signed in to change notification settings - Fork 34
OCM-18954 | feat: Move GetBoolNotNil function to ocm-common #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
WalkthroughAdded an exported helper function GetBoolNotNil(f *bool) bool to pkg/utils and corresponding unit tests verifying nil, true, and false pointer behavior. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Utils as pkg/utils
Note over Utils: New function GetBoolNotNil(f *bool)
Caller->>Utils: GetBoolNotNil(f)
alt f is nil
Utils-->>Caller: false
else f != nil
alt *f is true
Utils-->>Caller: true
else
Utils-->>Caller: false
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/utils/utils.go (1)
74-76: Add documentation for the public function.The implementation is correct and safe. However, as an exported function, it should have a godoc comment explaining its behavior (returns true only when the pointer is non-nil and points to true).
Apply this diff to add documentation:
+// GetBoolNotNil returns true if the boolean pointer is non-nil and points to true, +// otherwise returns false. func GetBoolNotNil(f *bool) bool { return f != nil && *f }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (2)
pkg/utils/utils.go(2 hunks)pkg/utils/utils_test.go(1 hunks)
🔇 Additional comments (2)
pkg/utils/utils_test.go (1)
43-55: LGTM! Comprehensive test coverage.The test suite properly validates all edge cases for
GetBoolNotNil: nil pointer, pointer to true, and pointer to false. The use ofDescribeTablemakes the tests clear and maintainable.pkg/utils/utils.go (1)
6-7: LGTM! Standard import formatting.The blank line appropriately separates standard library imports from third-party imports, following Go conventions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/utils/utils.go (1)
74-76: Implementation looks good and addresses past review feedback.The implementation correctly handles nil pointers using short-circuit evaluation. This matches the cleaner approach suggested by ziccardi in the past review.
Consider adding a doc comment for this exported function, following Go conventions:
+// GetBoolNotNil returns true if f is non-nil and points to true, otherwise returns false. func GetBoolNotNil(f *bool) bool { return f != nil && *f }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (2)
pkg/utils/utils.go(2 hunks)pkg/utils/utils_test.go(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/utils/utils_test.go
|
lgtm |
No description provided.