PMM-15129 Fix revive Go linter issues (p2)#5586
Conversation
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## PMM-15129-fix-go-linter-revive-p1 #5586 +/- ##
=====================================================================
+ Coverage 43.60% 43.64% +0.04%
=====================================================================
Files 414 414
Lines 43057 43058 +1
=====================================================================
+ Hits 18775 18793 +18
+ Misses 22404 22390 -14
+ Partials 1878 1875 -3
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 continues the PMM-15129 effort to address Go linter (revive) findings by removing now-unneeded suppressions, tightening naming/unused-parameter patterns, and improving clarity around a few agent/server behaviors (notably MySQL explain action errors and DB calls with context).
Changes:
- Replaces several
//nolint:reviveusages with either proper documentation comments or unused-parameter elision. - Refactors MySQL EXPLAIN action errors into sentinel error variables and updates related tests accordingly.
- Improves server-side DB access patterns by threading request contexts into reform queries (
WithContext(ctx)).
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| version/features.go | Simplifies feature minimum-version definitions (now inline parsing). |
| utils/sqlmetrics/sqlmetrics.go | Replaces revive suppressions with proper exported-method doc comments. |
| utils/logger/grpc.go | Removes unused parameter name from V to satisfy linters. |
| qan-api2/utils/logger/grpc.go | Same V signature cleanup for qan-api2 logger wrapper. |
| managed/utils/validators/validators.go | Removes unnecessary revive suppressions on exported constants. |
| managed/services/telemetry/datasource_victoria_metrics.go | Drops unused ctx parameter names in Init/Dispose. |
| managed/services/telemetry/datasource_qandb_select.go | Drops unused ctx parameter names in Init/Dispose. |
| managed/services/telemetry/datasource_pmmdb_select.go | Drops unused ctx parameter names in Init/Dispose. |
| managed/services/telemetry/datasource_grafanadb_select.go | Drops unused ctx parameter names in Init/Dispose. |
| managed/services/server/server.go | Removes revive suppressions; uses request context in DB calls. |
| managed/services/management/grpc/actions_server.go | Uses context-aware DB querier for model lookups. |
| managed/services/management/backup/backup_service.go | Uses context-aware DB querier; removes unused request parameter. |
| managed/services/inventory/grpc/services_server.go | Removes unused request parameter name to satisfy linter. |
| managed/services/ha/leaderservice_test.go | Fixes context.WithValue key typing to satisfy staticcheck/revive. |
| managed/services/backup/pitr_timerange_service.go | Replaces += 1 with ++ per revive preference. |
| managed/services/agents/channel/channel.go | Adds documentation to the Stream interface instead of suppressing revive. |
| managed/pi/common/severity.go | Adds a proper package comment (removing revive suppression). |
| agent/utils/mongo_fix/mongo_fix.go | Removes revive suppression from package declaration. |
| agent/utils/mongo_fix/mongo_fix_test.go | Removes revive suppression from package declaration in tests. |
| agent/utils/backoff/backoff_test.go | Removes unused test parameter name. |
| agent/runner/runner_test.go | Removes unused parameter name in test job’s Run. |
| agent/runner/jobs/pbm_helpers.go | Simplifies control flow by removing unnecessary else. |
| agent/runner/actions/mysql_explain_action.go | Introduces sentinel errors for EXPLAIN action validation failures. |
| agent/runner/actions/mysql_explain_action_test.go | Updates assertions to use require.ErrorIs for sentinel errors. |
| agent/config/logger.go | Removes unused parameter name in gRPC logger wrapper V. |
| agent/commands/setup.go | Removes unnecessary revive suppression from file-level nolint. |
| agent/client/token_auth.go | Removes unused parameter names from credential metadata method. |
| agent/client/basic_auth.go | Removes unused parameter names from credential metadata method. |
| agent/agents/supervisor/supervisor.go | Renames constants to match naming conventions; avoids pkg/var name shadowing. |
| agent/agents/supervisor/supervisor_test.go | Updates tests to match renamed supervisor constants. |
💡 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>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Ticket number: PMM-15129
Feature build: Percona-Lab/pmm-submodules#4452
This pull request primarily refactors code for improved consistency and clarity by standardizing naming conventions and updating import paths across several MongoDB agent components and the supervisor module.
Naming and Import Refactoring
Replaced all occurrences of the import path
github.com/percona/pmm/agent/utils/mongo_fixwithgithub.com/percona/pmm/agent/utils/mongofixin MongoDB agent files and related tests to match the new package naming convention. (mongolog/internal/mongolog.go,profiler/internal/collector/collector_test.go,profiler/internal/profiler.go,realtimeanalytics/connection.go,shared/fingerprinter/fingerprinter_test.go) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Updated all usages of the
mongo_fixidentifier tomongofixfor theClientOptionsForDSNfunction to align with the updated import. [1] [2] [3] [4] [5]Supervisor Module Improvements
Renamed test agent type constants from
type_TEST_SLEEPandtype_TEST_NOOPtotypeTestSleepandtypeTestNoop, and updated all references throughoutsupervisor.goandsupervisor_test.gofor consistency with Go naming conventions. [1] [2] [3] [4] [5] [6] [7] [8] [9]Refactored variable names in
supervisor.gofromprocess_Retry_Timeandstart_Process_WaitingtoprocessRetryTimeandstartProcessWaitingfor improved readability and code style. [1] [2]Renamed the local variable
processtoprocessWrapperinstartProcessto avoid confusion with the package name and improve code clarity. [1] [2] [3]These changes do not alter functionality but improve maintainability and code quality.