chore: enable and fix some gocritic issues - #3287
Open
mmorel-35 wants to merge 1 commit into
Open
Conversation
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3287 +/- ##
=======================================
Coverage 14.73% 14.73%
=======================================
Files 200 200
Lines 93077 93028 -49
=======================================
Hits 13712 13712
+ Misses 78019 77978 -41
+ Partials 1346 1338 -8 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR enables the gocritic linter in the repository’s golangci-lint configuration and applies a set of small refactors across the codebase to address the newly enabled gocritic findings, primarily simplifying conditional chains and avoiding unnecessary string operations.
Changes:
- Enable
gocriticin.golangci.ymland configure it withenable-all: trueplus a curated list of disabled checks. - Refactor several
if/elsechains into conditionlessswitchstatements to satisfy linter expectations and reduce nesting. - Replace a small
strings.Joinusage with direct string concatenation and usestrings.EqualFoldfor case-insensitive comparisons.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
swarmd/dockerexec/container.go |
Simplifies label key construction by replacing strings.Join with string concatenation. |
protobuf/plugin/deepcopy/deepcopy.go |
Replaces if/else chains with switch blocks in generated-code emission logic. |
manager/orchestrator/update/updater.go |
Refactors task selection logic from if/else into a switch chain. |
manager/orchestrator/restart/restart.go |
Refactors service-type branching logic into a switch with grouped cases. |
manager/orchestrator/jobs/replicated/reconciler.go |
Reduces nesting by converting an inner conditional into an else if. |
manager/logbroker/broker.go |
Simplifies session subscription ID validation by removing an unnecessary else block. |
manager/controlapi/cluster.go |
Uses strings.EqualFold for clearer case-insensitive algorithm validation. |
cli/external_ca.go |
Uses strings.EqualFold for protocol parsing without allocating a lowercased copy. |
ca/renewer.go |
Refactors renewal retry decision logic into a switch chain. |
ca/keyreadwriter.go |
Minor comment formatting tweak in a switch case. |
api/defaults/service.go |
Removes superfluous nesting by converting nested if blocks into else if checks. |
.golangci.yml |
Enables and configures gocritic checks under the v2 config format. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
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.
- What I did
enable and fix some gocritic issues
- How I did it
- How to test it
- Description for the changelog