PMM-15129 Disable mnd Go linter#5614
Conversation
There was a problem hiding this comment.
Pull request overview
This PR disables the mnd (“magic numbers”) linter in the repository’s GolangCI configuration and removes many //nolint:mnd annotations across PMM’s Go components (agent, managed, qan-api2), aiming to reduce noise without changing runtime behavior.
Changes:
- Disabled the
mndlinter in.golangci.yml. - Removed
//nolint:mndsuppressions from numerous Go files (and updated combined nolint tags like//nolint:gosec,mnd→//nolint:gosec). - Minor incidental change in
agent/agentlocal/agent_local.gothat currently introduces a build issue.
Reviewed changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
utils/logger/protobuf.go |
Removed //nolint:mnd from masking-related constants. |
qan-api2/models/reporter.go |
Removed //nolint:mnd from sparkline/time alignment math. |
qan-api2/main.go |
Removed //nolint:mnd from gRPC max receive size constant. |
managed/utils/validators/alerting_rules.go |
Removed mnd from nolint tags and timeout constant suppression. |
managed/utils/testdb/db.go |
Removed //nolint:mnd from test DB name length argument. |
managed/utils/envvars/parser.go |
Removed //nolint:mnd around SplitN and len(...) checks. |
managed/services/victoriametrics/victoriametrics.go |
Removed //nolint:mnd from slice capacity and regex match length checks. |
managed/services/victoriametrics/scrape_configs.go |
Removed //nolint:mnd from scrape timeout factor and slice capacity math. |
managed/services/victoriametrics/prometheus.go |
Removed //nolint:mnd from scrape config slice capacity. |
managed/services/supervisord/supervisord.go |
Removed //nolint:mnd from SplitN, retention-day conversion, and file write permissions tags. |
managed/services/supervisord/maintail.go |
Removed //nolint:mnd from log line parsing logic. |
managed/services/server/server.go |
Removed //nolint:mnd from truncation, timeouts/sleeps, and file permission calls. |
managed/services/realtimeanalytics/store.go |
Removed //nolint:mnd from hash multiplier usage. |
managed/services/realtimeanalytics/service.go |
Removed //nolint:mnd from proto size threshold in debug logging. |
managed/services/nomad/nomad.go |
Removed //nolint:mnd from MkdirAll permissions. |
managed/services/ha/haservice.go |
Removed //nolint:mnd from regex match length check. |
managed/services/alerting/service.go |
Removed //nolint:mnd from alert rule relative time range constants. |
managed/services/agents/state.go |
Removed //nolint:mnd from concurrency limiter buffer size. |
managed/services/agents/registry.go |
Removed //nolint:mnd from Prometheus summary objectives and roundtrip/2. |
managed/services/agents/mongodb.go |
Removed //nolint:mnd while keeping the “default limit” comment. |
managed/pi/check/check.go |
Removed //nolint:mnd from parsing checks, algorithm byte check, and version switch cases. |
managed/pi/alert/parameter.go |
Removed //nolint:mnd from range length validation. |
managed/models/settings.go |
Removed //nolint:mnd from default durations and retention defaults. |
managed/models/postgresql_version.go |
Removed //nolint:mnd from regex submatch length check. |
managed/models/models.go |
Removed //nolint:mnd from map initial capacity. |
managed/models/database.go |
Removed //nolint:mnd from DB pool sizing and default PG port. |
managed/models/agent_helpers.go |
Removed //nolint:mnd from placeholders join and default interval creation. |
agent/utils/templates/template.go |
Removed //nolint:mnd from directory/file permissions when rendering templates. |
agent/config/config.go |
Removed mnd from //nolint:gosec,mnd on file write. |
agent/client/channel/rta_channel.go |
Removed //nolint:mnd from proto size threshold in debug logging. |
agent/agents/postgres/pgstatmonitor/pgstatmonitor.go |
Removed a //nolint:mnd,cyclop directive (needs follow-up for cyclop). |
agent/agents/postgres/pgstatmonitor/pgstatmonitor_models.go |
Removed //nolint:mnd from slice length constant. |
agent/agents/mongodb/realtimeanalytics/parser/parser.go |
Removed //nolint:mnd from duration rounding constant. |
agent/agents/mongodb/realtimeanalytics/mongodb.go |
Removed //nolint:mnd from channel buffer size and pipeline $gte value. |
agent/agents/mongodb/mongolog/internal/mongolog.go |
Removed //nolint:mnd from waitgroup Add(2). |
agent/agentlocal/agent_local.go |
Introduced wg.Go(...) usage on sync.WaitGroup (currently breaks build). |
.golangci.yml |
Disabled mnd linter globally. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5614 +/- ##
==========================================
+ Coverage 43.59% 44.07% +0.48%
==========================================
Files 415 416 +1
Lines 43134 43093 -41
==========================================
+ Hits 18804 18995 +191
+ Misses 22454 22221 -233
- Partials 1876 1877 +1
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:
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| // String returns a string representation of this struct or record. | ||
| func (s pgStatMonitor) String() string { | ||
| res := make([]string, 54) //nolint:mnd | ||
| res := make([]string, 54) |
There was a problem hiding this comment.
What is 54 here? Don't we want to know?
Ticket number: PMM-15129
This pull request primarily removes the
//nolint:mnddirective from many lines throughout the codebase, which previously suppressed linter warnings about "magic numbers." No functional code changes are introduced—only linter annotations are removed or updated. Additionally, themndlinter is now explicitly disabled in the.golangci.ymlconfiguration, preventing future linter errors related to magic numbers.The most important changes are:
Linter configuration:
mndlinter in.golangci.ymlto avoid linter warnings about magic numbers across the codebase.Code cleanup (removal of linter directives):
//nolint:mndcomments from various files and lines, including initialization of variables with constant values, function arguments, and struct initializations. This affects files inagent/,managed/, and related directories. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25]These changes simplify the code and make it cleaner now that the linter is configured to ignore magic numbers globally. No runtime behavior is affected.