-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Refactoring of redundant condition checks #13104
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: keitosuwahara <[email protected]>
Signed-off-by: keitosuwahara <[email protected]>
d90aa86
to
bd14f68
Compare
ndeloof
approved these changes
Jul 27, 2025
Thanks for the review! Since I don’t have write access, auto-merge is disabled. |
Signed-off-by: keitosuwahara <[email protected]>
auto-merge was automatically disabled
July 27, 2025 14:52
Head branch was pushed to by a user without write access
d1de435
to
430ae71
Compare
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this pull request
Aug 11, 2025
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [docker/compose](https://github.com/docker/compose) | patch | `v2.39.1` -> `v2.39.2` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>docker/compose (docker/compose)</summary> ### [`v2.39.2`](https://github.com/docker/compose/releases/tag/v2.39.2) [Compare Source](docker/compose@v2.39.1...v2.39.2) #### What's Changed ##### 🐛 Fixes - Fix (regression): compose build render build output with tty support by [@​ndeloof](https://github.com/ndeloof) in docker/compose#13107 - Add missing `_MODEL` suffix to model variable pass to dependent services of a model by [@​glours](https://github.com/glours) in docker/compose#13109 - Apply `BUILDKIT_PROGRESS` value when building with bake by [@​glours](https://github.com/glours) in docker/compose#13110 - Define `pull` and `no_cache` from either service or flags values when building with bake by [@​glours](https://github.com/glours) in docker/compose#13133 - Only monitor attached services on `up` command by [@​glours](https://github.com/glours) in docker/compose#13114 ##### 🔧 Internal - Add Streams Comment by [@​suwakei](https://github.com/suwakei) in docker/compose#13103 - Add test of `json.go` by [@​suwakei](https://github.com/suwakei) in docker/compose#13106 - Refactoring of redundant condition checks by [@​suwakei](https://github.com/suwakei) in docker/compose#13104 - Eliminated magic string by [@​suwakei](https://github.com/suwakei) in docker/compose#13105 - Use log API for containers we didn't attached to by [@​ndeloof](https://github.com/ndeloof) in docker/compose#13111 - Use `cli-plugins/metadata` package by [@​thaJeztah](https://github.com/thaJeztah) in docker/compose#13130 - `pkg/compose`: simplify getting auth-config key by [@​thaJeztah](https://github.com/thaJeztah) in docker/compose#13120 - Add go as a prerequisite in build instructions by [@​mattrunyon](https://github.com/mattrunyon) in docker/compose#13131 ##### ⚙️ Dependencies - Build(deps): bump github.com/docker/cli from `28.3.2+incompatible` to `28.3.3+incompatible` by [@​dependabot](https://github.com/dependabot)\[bot] in docker/compose#13116 - Build(deps): bump github.com/docker/docker from `28.3.2+incompatible` to `28.3.3+incompatible` by [@​dependabot](https://github.com/dependabot)\[bot] in docker/compose#13115 - Build(deps): bump github.com/containerd/containerd/v2 from `2.1.3` to `2.1.4` by [@​dependabot](https://github.com/dependabot)\[bot] in docker/compose#13119 - Build(deps): bump github.com/docker/go-connections from `0.5.0` to `0.6.0` by [@​dependabot](https://github.com/dependabot)\[bot] in docker/compose#13137 - Build(deps): bump golang.org/x/sys from `0.34.0` to `0.35.0` by [@​dependabot](https://github.com/dependabot)\[bot] in docker/compose#13138 - Bump golang to `1.23.12` by [@​austinvazquez](https://github.com/austinvazquez) in docker/compose#13142 #### New Contributors - [@​mattrunyon](https://github.com/mattrunyon) made their first contribution in docker/compose#13131 - [@​austinvazquez](https://github.com/austinvazquez) made their first contribution in docker/compose#13142 **Full Changelog**: docker/compose@v2.39.1...v2.39.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS41OC4yIiwidXBkYXRlZEluVmVyIjoiNDEuNTguMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
Redundant condition check:
In the init() function, the version string is parsed using the github.com/hashicorp/go-version library.
The NewVersion function of this library always returns a version object with three segments: major, minor, and patch, if parsed successfully (e.g., “v1.2” is interpreted as “v1.2.0”).
Thus, the check if len(segments) > 2 after if err == nil is always true and redundant.
How to construct the version string:
Rather than manually reconstructing the version string using fmt.Sprintf, it is clearer in intent and more idiomatic to use the Core() method provided by the go-version library.
Lack of test
No tests were included to verify the behavior of pkg/api/labels.go, especially the initialization logic of the global variable ComposeVersion by the init() function.
Fix:
To improve these points, the init() function has been modified as follows Remove the redundant if statement and use v.Core().String() to set the ComposeVersion.
Create a new test file called pkg/api/labels_test.go and add a test case that validates the initialization logic of ComposeVersion.
ComposeVersion should be the core version such as 2.1.0 even if internal.Version contains pre-release information such as v2.1.0-beta.
ComposeVersion should remain an empty string if internal.Version is a non-parsable string such as “devel”.
Added tests to validate these cases.
This improves maintainability and correctness of version handling.