Skip to content

chore: enable and fix some gocritic issues - #3287

Open
mmorel-35 wants to merge 1 commit into
moby:masterfrom
mmorel-35:gocritic
Open

chore: enable and fix some gocritic issues#3287
mmorel-35 wants to merge 1 commit into
moby:masterfrom
mmorel-35:gocritic

Conversation

@mmorel-35

Copy link
Copy Markdown
Contributor

- What I did

enable and fix some gocritic issues

- How I did it

- How to test it

- Description for the changelog

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 22.50000% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 14.73%. Comparing base (6e9e7b8) to head (939f5a4).
⚠️ Report is 68 commits behind head on master.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 gocritic in .golangci.yml and configure it with enable-all: true plus a curated list of disabled checks.
  • Refactor several if/else chains into conditionless switch statements to satisfy linter expectations and reduce nesting.
  • Replace a small strings.Join usage with direct string concatenation and use strings.EqualFold for 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants