PMM-15129 PMM-15129 Fix noinlineerr Go linter issues in agent#5483
Conversation
- gomodguard linter has been deprecated. gomodguard_v2 is suggested instead. - remove the limits for showing linter issues.
There was a problem hiding this comment.
Pull request overview
This PR addresses Go linter (noinlineerr) warnings across the PMM agent/admin code by refactoring inline error checks (e.g., if err := ...; err != nil) into separate assignment + conditional blocks, without changing intended behavior.
Changes:
- Replaced inline
if err := ...; err != nilpatterns witherr = .../if err != nilacross agent, admin, and API packages. - Adjusted a few spots where
:=previously scoped variables tightly (e.g., command responses, DB calls, file ops) to satisfy the linter’s requirements. - Minor import and local variable handling updates to support the refactors.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| api/agent/v1/metadata.go | Refactors metrics port parsing to avoid inline error initialization. |
| agent/utils/version/mongo.go | Splits MongoDB command error/decode checks into assignment + conditional. |
| agent/utils/tests/mongodb.go | Refactors decode error handling in test utility. |
| agent/utils/templates/template.go | Refactors temp dir cleanup/create error handling to satisfy linter. |
| agent/utils/filereader/continuous_file_reader.go | Refactors file seek/close error handling to avoid inline err declarations. |
| agent/serviceinfobroker/service_info_broker.go | Refactors DB ping/query/scan error checks across service info helpers. |
| agent/runner/runner.go | Refactors token acquisition error checks for jobs/actions. |
| agent/runner/jobs/mysql_restore_job.go | Refactors multiple restore-step error checks (systemctl, exec, filesystem). |
| agent/runner/jobs/mysql_backup_job.go | Refactors command start error checks during backup pipeline setup. |
| agent/runner/jobs/mongodb_restore_job.go | Refactors PBM configuration/wait error checks. |
| agent/runner/jobs/mongodb_backup_job.go | Refactors PBM configuration/wait error checks. |
| agent/runner/actions/pt_mysql_summary_action.go | Refactors arg validation and template execution error checks. |
| agent/runner/actions/mysql_show_create_table_action.go | Refactors row scan error check. |
| agent/runner/actions/mysql_explain_action.go | Refactors write/flush/unmarshal error checks to avoid inline err declarations. |
| agent/runner/actions/mongodb_query_admincommand_action.go | Refactors BSON decode error check. |
| agent/connectionchecker/connection_checker.go | Refactors ping checks for MySQL/MongoDB/PostgreSQL/ProxySQL. |
| agent/config/config.go | Refactors host/port parsing and config loading/unmarshal error checks. |
| agent/commands/setup.go | Refactors error checks and updates typed error extraction patterns for linter compliance. |
| agent/cmd/pmm-agent-entrypoint/main.go | Refactors signal/process waiting and prerun command error checks. |
| agent/client/client.go | Refactors timeout validity check to avoid inline err declaration. |
| agent/agents/supervisor/supervisor.go | Refactors port release and temp dir cleanup error handling. |
| agent/agents/postgres/pgstatstatements/pgstatstatements.go | Refactors cache get/set error handling around stat statement refresh. |
| agent/agents/postgres/pgstatmonitor/pgstatmonitor.go | Refactors initial cache seeding error handling. |
| agent/agents/postgres/parser/parser.go | Refactors parse-to-JSON error handling. |
| agent/agents/mysql/slowlog/slowlog.go | Refactors multiple query/scan/fs operations error handling in slowlog checks/rotation. |
| agent/agents/mysql/perfschema/perfschema.go | Refactors cache get/set and initial summary fetch error handling. |
| agent/agents/mongodb/mongolog/internal/monitor_test.go | Refactors scanner/write error checks in tests. |
| agent/agentlocal/agent_local.go | Refactors JSON gateway registration and HTTP server shutdown error checks. |
| agent/agentlocal/agent_local_test.go | Refactors zip entry read error check in test. |
| admin/commands/summary.go | Refactors URL parse and archive file create error checks. |
| admin/commands/status.go | Refactors URL parse error check when redacting server URL. |
| admin/commands/base.go | Refactors JSON unmarshal error check for credentials parsing. |
| admin/cmd/pmm-admin/main_test.go | Refactors JSON unmarshal error check in version output test. |
💡 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 @@
## PMM-15129-noinlineerr-linter-managed #5483 +/- ##
========================================================================
- Coverage 43.52% 43.51% -0.01%
========================================================================
Files 413 413
Lines 42849 42928 +79
========================================================================
+ Hits 18648 18682 +34
- Misses 22329 22374 +45
Partials 1872 1872
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:
|
Ticket number: PMM-15129
Percona-Lab/pmm-submodules#4400