Skip to content

Conversation

@majiayu000
Copy link

Summary

This PR fixes #2343

Changes

  • Removed gocognit from the disabled linters list in .golangci.yml to enable the linter
  • Added //nolint:gocognit directives to 36 functions that trigger gocognit warnings, as these functions have high cognitive complexity that is inherent to their functionality
  • Removed an unused //nolint:gocognit directive in managed/services/telemetry/config.go that was revealed when the linter was enabled

The approach of using //nolint:gocognit directives rather than refactoring the functions is appropriate here because:

  1. These are complex functions that handle multiple related operations
  2. Refactoring them would add complexity without clear benefit
  3. The gocognit linter is already excluded for test files (in .golangci.yml exclusions)

Test plan

  • Verified golangci-lint run --enable-only gocognit returns 0 issues
  • Verified no unused //nolint:gocognit directives remain

Enables the gocognit linter by removing it from the disabled list in
.golangci.yml and adds //nolint:gocognit directives to functions that
trigger warnings. Also removes an unused //nolint:gocognit directive
that was revealed by enabling the linter.

Signed-off-by: majiayu000 <1835304752@qq.com>
@majiayu000 majiayu000 requested review from a team and JiriCtvrtka as code owners December 30, 2025 15:00
@majiayu000 majiayu000 requested review from idoqo and maxkondr and removed request for a team December 30, 2025 15:00
@it-percona-cla
Copy link
Contributor

it-percona-cla commented Dec 30, 2025

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

❌ Patch coverage is 65.78947% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.93%. Comparing base (4e3b1ff) to head (d16348d).
⚠️ Report is 1 commits behind head on v3.

Files with missing lines Patch % Lines
managed/services/agents/jobs.go 0.00% 2 Missing ⚠️
...ent/agents/postgres/pgstatmonitor/pgstatmonitor.go 0.00% 1 Missing ⚠️
agent/cmd/pmm-agent-entrypoint/main.go 0.00% 1 Missing ⚠️
managed/cmd/pmm-managed/main.go 0.00% 1 Missing ⚠️
managed/services/agents/handler.go 0.00% 1 Missing ⚠️
managed/services/agents/state.go 0.00% 1 Missing ⚠️
managed/services/management/azure_database.go 0.00% 1 Missing ⚠️
managed/services/management/external.go 0.00% 1 Missing ⚠️
managed/services/management/haproxy.go 0.00% 1 Missing ⚠️
managed/services/management/mongodb.go 0.00% 1 Missing ⚠️
... and 2 more
Additional details and impacted files
@@           Coverage Diff           @@
##               v3    #4879   +/-   ##
=======================================
  Coverage   45.93%   45.93%           
=======================================
  Files         364      364           
  Lines       37880    37880           
=======================================
  Hits        17399    17399           
- Misses      18805    18806    +1     
+ Partials     1676     1675    -1     
Flag Coverage Δ
admin 17.82% <ø> (ø)
agent 53.51% <60.00%> (-0.03%) ⬇️
managed 46.58% <66.66%> (+<0.01%) ⬆️
vmproxy 72.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Enable gocognit linter rule

3 participants