-
Notifications
You must be signed in to change notification settings - Fork 115
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
refactor: consolidate version normalization logic #3448
base: develop
Are you sure you want to change the base?
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughThis pull request introduces a comprehensive revision of version handling across multiple components of the system. The changes centralize version normalization logic within the Changes
Sequence DiagramsequenceDiagram
participant Constant as constant.Version
participant Handler as GetDefaultUpgradeHandlerVersion
participant Runner as E2ERunner
participant Client as ZetaClient
Constant->>Handler: Provide Version
Handler->>Constant: Call GetNormalizedVersion()
Constant-->>Handler: Return Normalized Version
Constant->>Runner: Provide Version
Runner->>Constant: Call NormalizeVersion()
Constant-->>Runner: Return Normalized Version
Constant->>Client: Provide Version
Client->>Constant: Call GetNormalizedVersion()
Constant-->>Client: Return Normalized Version
Possibly Related PRs
Suggested Labels
Suggested Reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
c3815d0
to
0219a3e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3448 +/- ##
===========================================
- Coverage 64.42% 64.39% -0.03%
===========================================
Files 436 437 +1
Lines 30368 30386 +18
===========================================
+ Hits 19565 19568 +3
- Misses 9962 9977 +15
Partials 841 841
|
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: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
app/setup_handlers.go
(1 hunks)e2e/runner/runner.go
(2 hunks)pkg/constant/version.go
(1 hunks)zetaclient/maintenance/shutdown_listener.go
(2 hunks)zetaclient/maintenance/shutdown_listener_test.go
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
app/setup_handlers.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
pkg/constant/version.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
e2e/runner/runner.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/maintenance/shutdown_listener_test.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/maintenance/shutdown_listener.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
🪛 GitHub Check: codecov/patch
pkg/constant/version.go
[warning] 16-21: pkg/constant/version.go#L16-L21
Added lines #L16 - L21 were not covered by tests
[warning] 25-26: pkg/constant/version.go#L25-L26
Added lines #L25 - L26 were not covered by tests
[warning] 29-33: pkg/constant/version.go#L29-L33
Added lines #L29 - L33 were not covered by tests
zetaclient/maintenance/shutdown_listener.go
[warning] 166-166: zetaclient/maintenance/shutdown_listener.go#L166
Added line #L166 was not covered by tests
🪛 GitHub Check: lint
pkg/constant/version.go
[failure] 19-19:
ineffectual assignment to version (ineffassign)
🪛 GitHub Actions: Linters and SAST
pkg/constant/version.go
[error] 19-19: ineffectual assignment to version (ineffassign)
🔇 Additional comments (6)
pkg/constant/version.go (1)
14-34
: Add test coverage for version normalization functions.The version normalization functions lack test coverage. Since these functions handle critical version string manipulation, they should be thoroughly tested.
Consider adding the following test cases:
GetNormalizedVersion
:
- Empty version string
- Version without 'v' prefix
- Version with 'v' prefix
NormalizeVersion
:
- Version without 'v' prefix
- Version with 'v' prefix
ensurePrefix
:
- String without prefix
- String with prefix
- Empty string
Would you like me to generate the test implementation?
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 16-21: pkg/constant/version.go#L16-L21
Added lines #L16 - L21 were not covered by tests
[warning] 25-26: pkg/constant/version.go#L25-L26
Added lines #L25 - L26 were not covered by tests
[warning] 29-33: pkg/constant/version.go#L29-L33
Added lines #L29 - L33 were not covered by tests🪛 GitHub Check: lint
[failure] 19-19:
ineffectual assignment to version (ineffassign)🪛 GitHub Actions: Linters and SAST
[error] 19-19: ineffectual assignment to version (ineffassign)
app/setup_handlers.go (1)
21-21
: LGTM: Version handling update is consistent.The change correctly uses the new centralized version normalization logic.
zetaclient/maintenance/shutdown_listener.go (1)
Line range hint
153-166
: LGTM: Version comparison logic is robust.The implementation correctly uses normalized versions for comparison, ensuring consistent version checks across the codebase.
zetaclient/maintenance/shutdown_listener_test.go (1)
110-110
: LGTM: Test cases properly updated.The test cases have been correctly updated to use version strings with the 'v' prefix, maintaining consistency with the new version normalization approach.
Also applies to: 138-138
e2e/runner/runner.go (2)
41-41
: LGTM!The addition of the
constant
package import aligns with the PR objective to consolidate version normalization logic.
440-440
: LGTM!The implementation correctly uses the consolidated
constant.NormalizeVersion
function and maintains the caching behavior.Let's verify that all version normalization logic has been consolidated:
✅ Verification successful
Version normalization logic is properly consolidated
All semantic version normalization in the codebase correctly uses the centralized
constant.NormalizeVersion
function. Other version-related code serves different purposes (protocol versions, API versions, etc.) and is correctly separated.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any remaining version normalization logic that should be consolidated # Test: Search for any remaining version normalization patterns rg -g '*.go' -i '(ensurePrefix|normalizeVersion|versionPrefix)' --type goLength of output: 627
Script:
#!/bin/bash # Search for any other version-related string manipulations rg -g '*.go' -i 'version.*string|strings.*version' --type go -A 2Length of output: 7237
Deduplicate the version
ensurePrefix
logic into the constant package.Summary by CodeRabbit
Release Notes
New Features
Improvements
Technical Updates