Skip to content

PMM-15129 Disable mnd Go linter#5614

Open
maxkondr wants to merge 14 commits into
mainfrom
PMM-15129-fix-go-linter-mnd
Open

PMM-15129 Disable mnd Go linter#5614
maxkondr wants to merge 14 commits into
mainfrom
PMM-15129-fix-go-linter-mnd

Conversation

@maxkondr

@maxkondr maxkondr commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Ticket number: PMM-15129

This pull request primarily removes the //nolint:mnd directive 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, the mnd linter is now explicitly disabled in the .golangci.yml configuration, preventing future linter errors related to magic numbers.

The most important changes are:

Linter configuration:

  • Disabled the mnd linter in .golangci.yml to avoid linter warnings about magic numbers across the codebase.

Code cleanup (removal of linter directives):

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.

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 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 mnd linter in .golangci.yml.
  • Removed //nolint:mnd suppressions from numerous Go files (and updated combined nolint tags like //nolint:gosec,mnd//nolint:gosec).
  • Minor incidental change in agent/agentlocal/agent_local.go that 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.

Comment thread agent/agentlocal/agent_local.go
Comment thread agent/agents/postgres/pgstatmonitor/pgstatmonitor.go
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.31250% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.07%. Comparing base (31318c7) to head (75fd528).
⚠️ Report is 27 commits behind head on main.

Files with missing lines Patch % Lines
managed/pi/check/check.go 0.00% 5 Missing ⚠️
agent/agentlocal/agent_local.go 0.00% 4 Missing ⚠️
managed/services/server/server.go 0.00% 4 Missing ⚠️
managed/services/agents/registry.go 0.00% 3 Missing ⚠️
agent/agents/mongodb/realtimeanalytics/mongodb.go 0.00% 2 Missing ⚠️
managed/models/agent_helpers.go 0.00% 2 Missing ⚠️
agent/agents/mongodb/mongolog/internal/mongolog.go 0.00% 1 Missing ⚠️
.../agents/mongodb/realtimeanalytics/parser/parser.go 0.00% 1 Missing ⚠️
...nts/postgres/pgstatmonitor/pgstatmonitor_models.go 0.00% 1 Missing ⚠️
agent/client/channel/rta_channel.go 0.00% 1 Missing ⚠️
... and 11 more
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     
Flag Coverage Δ
admin 34.78% <ø> (ø)
agent 50.15% <23.07%> (+1.11%) ⬆️
managed 43.27% <50.98%> (+0.29%) ⬆️
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.

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 09:28
@maxkondr maxkondr requested a review from a team as a code owner July 8, 2026 09:28
@maxkondr maxkondr requested review from JiriCtvrtka and ademidoff and removed request for a team July 8, 2026 09:28
Comment thread agent/agentlocal/agent_local.go Outdated

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

Copilot reviewed 37 out of 37 changed files in this pull request and generated 2 comments.

Comment thread qan-api2/models/reporter.go
Comment thread agent/agentlocal/agent_local.go
@maxkondr maxkondr added the auto-update-branch used by .github/workflows/auto-update-base.yaml label Jul 10, 2026
// 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)

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.

What is 54 here? Don't we want to know?

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