Skip to content

PMM-15129 Disable cyclop, gocognit and maintidx Go linters#5613

Open
maxkondr wants to merge 44 commits into
mainfrom
PMM-15129-fix-go-linter-gocognit
Open

PMM-15129 Disable cyclop, gocognit and maintidx Go linters#5613
maxkondr wants to merge 44 commits into
mainfrom
PMM-15129-fix-go-linter-gocognit

Conversation

@maxkondr

@maxkondr maxkondr commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Ticket number: PMM-15129
This pull request removes several //nolint comments that previously suppressed linter warnings for code complexity (such as gocognit, cyclop, and maintidx) and disables related linters in the .golangci.yml configuration. This change means that complex or lengthy functions will no longer be flagged by these linters, reflecting the project's acceptance of such patterns in its codebase.

Linter configuration changes:

  • .golangci.yml: Disabled the cyclop, gocognit, and maintidx linters, which check for function complexity, as well as added comments explaining the rationale for each. [1] [2]

Code cleanup:

Minor adjustments:

  • In a few cases, retained other nolint directives where still relevant (e.g., //nolint:unparam).

These changes streamline the codebase by reducing linter noise and acknowledging the project's use of complex or lengthy functions where appropriate.

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.97297% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.17%. Comparing base (31318c7) to head (d53f79a).
⚠️ Report is 65 commits behind head on main.

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/external.go 0.00% 1 Missing ⚠️
managed/services/management/haproxy.go 0.00% 1 Missing ⚠️
managed/services/management/mongodb.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5613      +/-   ##
==========================================
+ Coverage   43.59%   45.17%   +1.58%     
==========================================
  Files         415      418       +3     
  Lines       43134    43315     +181     
==========================================
+ Hits        18804    19569     +765     
+ Misses      22454    21806     -648     
- Partials     1876     1940      +64     
Flag Coverage Δ
admin 34.94% <100.00%> (+0.15%) ⬆️
agent 50.27% <60.00%> (+1.22%) ⬆️
managed 44.92% <74.19%> (+1.94%) ⬆️
vmproxy 72.22% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates PMM’s Go linting posture by disabling complexity-related linters (cyclop, gocognit, maintidx) in .golangci.yml and then removing now-redundant //nolint suppressions across the Go codebase so the code and linter configuration remain aligned.

Changes:

  • Disabled cyclop, gocognit, and maintidx in .golangci.yml (with rationale comments).
  • Removed //nolint:{gocognit,cyclop,maintidx} annotations from multiple functions across managed/, agent/, qan-api2/, admin/, and api/.
  • Kept unrelated nolint directives where still applicable (e.g., //nolint:unparam, //nolint:ireturn, //nolint:mnd).

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
qan-api2/services/analytics/profile.go Removes //nolint:gocognit from GetReport.
managed/utils/envvars/parser.go Removes complexity nolint from ParseEnvVars.
managed/services/victoriametrics/prometheus.go Removes complexity nolint from AddScrapeConfigs.
managed/services/telemetry/telemetry.go Removes //nolint:gocognit from prepareReport.
managed/services/supervisord/supervisord.go Removes //nolint:gocognit from Run.
managed/services/qan/client.go Removes //nolint:gocognit from Collect.
managed/services/preconditions.go Removes //nolint:gocognit from CheckArtifactOverlapping.
managed/services/management/service.go Removes //nolint:gocognit from ListServices / RemoveService.
managed/services/management/rds.go Removes //nolint:gocognit from DiscoverRDS and drops a complexity nolint block comment before addRDS.
managed/services/management/postgresql.go Removes //nolint:gocognit from addPostgreSQL.
managed/services/management/node.go Removes //nolint:gocognit from RegisterNode / ListNodes.
managed/services/management/mysql.go Removes //nolint:gocognit from addMySQL.
managed/services/management/mongodb.go Removes //nolint:gocognit from addMongoDB.
managed/services/management/haproxy.go Removes //nolint:gocognit from addHAProxy.
managed/services/management/external.go Removes //nolint:gocognit from addExternal.
managed/services/management/azure_database.go Drops a //nolint:gocognit block comment before AddAzureDatabase.
managed/services/inventory/services.go Removes //nolint:gocognit from Remove.
managed/services/converters.go Removes maintidx from an existing //nolint list on ToAPIAgent.
managed/services/backup/pitr_timerange_service.go Removes //nolint:gocognit from mergeTimelines.
managed/services/backup/backup_service.go Removes complexity nolint from PerformBackup.
managed/services/agents/state.go Removes complexity nolint from sendSetStateRequest.
managed/services/agents/jobs.go Removes complexity nolint from RestartJob and handleJobResult.
managed/services/agents/handler.go Removes //nolint:gocognit from Run.
managed/models/settings_helpers.go Removes complexity nolint while keeping //nolint:unparam on UpdateSettings.
managed/models/service_helpers.go Removes //nolint:gocognit from RemoveService.
managed/models/node_helpers.go Removes //nolint:gocognit from RemoveNode.
managed/models/encryption_helpers.go Removes //nolint:gocognit from agentEncryption.
managed/models/agent_model.go Removes complexity nolint from DSN and Files.
managed/models/agent_helpers.go Removes cyclop,maintidx suppression from ChangeAgent.
managed/cmd/pmm-managed/main.go Removes complexity nolint from main().
api/agent/v1/query.go Removes //nolint:cyclop from makeValue.
agent/config/config.go Removes complexity nolint from get (test helper).
agent/cmd/pmm-agent-entrypoint/main.go Removes //nolint:gocognit from main().
agent/client/client.go Removes //nolint:gocognit from processSupervisorRequests.
agent/agents/postgres/pgstatmonitor/stat_monitor_cache.go Drops a //nolint:gocognit block comment above getStatMonitorExtended.
agent/agents/postgres/pgstatmonitor/pgstatmonitor.go Removes cyclop from an existing //nolint list and removes //nolint:gocognit from makeBuckets.
agent/agents/mysql/slowlog/slowlog.go Drops a complexity nolint block comment above makeBuckets.
agent/agents/mysql/perfschema/perfschema.go Removes //nolint:gocognit from getNewBuckets.
admin/commands/inventory/change_agent_mongodb_exporter.go Removes //nolint:cyclop from RunCmd.
.golangci.yml Disables cyclop, gocognit, maintidx (adds rationale comments).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .golangci.yml Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@maxkondr
maxkondr marked this pull request as ready for review July 8, 2026 08:57
@maxkondr
maxkondr requested a review from a team as a code owner July 8, 2026 08:57
@maxkondr
maxkondr requested review from JiriCtvrtka and ademidoff and removed request for a team July 8, 2026 08:57
@maxkondr maxkondr added the auto-update-branch used by .github/workflows/auto-update-base.yaml label Jul 10, 2026

@ademidoff ademidoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think those are very useful linters. Why would we disable them all?

I think it's much better to disable them occasionally with //nolint rather than create a false perception that we don't care about code complexity.

pmm-prbot Bot added 27 commits July 15, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-update-branch used by .github/workflows/auto-update-base.yaml

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants