PMM-15129 Disable cyclop, gocognit and maintidx Go linters#5613
PMM-15129 Disable cyclop, gocognit and maintidx Go linters#5613maxkondr wants to merge 44 commits into
Conversation
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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, andmaintidxin.golangci.yml(with rationale comments). - Removed
//nolint:{gocognit,cyclop,maintidx}annotations from multiple functions acrossmanaged/,agent/,qan-api2/,admin/, andapi/. - Kept unrelated
nolintdirectives 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
ademidoff
left a comment
There was a problem hiding this comment.
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.
Ticket number: PMM-15129
This pull request removes several
//nolintcomments that previously suppressed linter warnings for code complexity (such asgocognit,cyclop, andmaintidx) and disables related linters in the.golangci.ymlconfiguration. 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 thecyclop,gocognit, andmaintidxlinters, which check for function complexity, as well as added comments explaining the rationale for each. [1] [2]Code cleanup:
//nolint:gocognit,//nolint:cyclop, and//nolint:maintidxcomments from numerous functions across the codebase, including main entry points, database helpers, and agent logic, to align with the updated linter configuration. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22]Minor adjustments:
nolintdirectives 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.