Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix linter findings for errorlint (part6) #12733

Merged
merged 3 commits into from
Mar 1, 2023
Merged

chore: Fix linter findings for errorlint (part6) #12733

merged 3 commits into from
Mar 1, 2023

Conversation

zak-pawel
Copy link
Collaborator

Address findings for errorlint - finds code that can cause problems with the error wrapping scheme introduced in Go 1.13.

It is only part of the bigger job.
After all findings in whole project are handled, we can enable errorlint linter to guard this.

Following findings in plugins/inputs/[n-p]* packages were fixed:

plugins/inputs/neptune_apex/neptune_apex.go:98:4               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/neptune_apex/neptune_apex.go:148:27             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/neptune_apex/neptune_apex.go:162:27             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/neptune_apex/neptune_apex.go:201:14             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/neptune_apex/neptune_apex.go:249:64             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/neptune_apex/neptune_apex.go:258:49             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/neptune_apex/neptune_apex.go:269:68             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/net/net.go:35:54                                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/net/net.go:40:52                                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/net/net.go:46:61                                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/net_response/net_response.go:61:15              errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/netstat/netstat.go:28:63                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nfsclient/nfsclient.go:53:23                    errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/nfsclient/nfsclient.go:54:8                     errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/nginx/nginx.go:92:75                            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nginx_plus/nginx_plus.go:94:75                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nginx_plus_api/nginx_plus_api_metrics.go:50:5   errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/nginx_plus_api/nginx_plus_api_metrics.go:60:74  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nginx_sts/nginx_sts.go:92:75                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nginx_vts/nginx_vts.go:92:75                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nomad/nomad.go:52:64                            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nomad/nomad.go:88:65                            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nomad/nomad.go:98:56                            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nomad/nomad.go:108:47                           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nsd/nsd.go:68:68                                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nsd/nsd.go:82:52                                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nsq/nsq.go:115:63                               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nsq/nsq.go:125:47                               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nsq/nsq.go:131:51                               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nsq/nsq.go:138:52                               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/nsq_consumer/nsq_consumer.go:120:20             errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/nsq_consumer/nsq_consumer.go:127:20             errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/opcua/read_client.go:70:50                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/opcua/read_client.go:86:44                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/opcua/read_client.go:138:54                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/opcua_listener/subscribe_client.go:103:65       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/opcua_listener/subscribe_client.go:109:81       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openntpd/openntpd.go:72:55                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openntpd/openntpd.go:85:52                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/opensearch_query/opensearch_query.go:146:90     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/opensmtpd/opensmtpd.go:53:56                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/opensmtpd/opensmtpd.go:76:52                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:148:74                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:160:65                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:165:63                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:169:69                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:173:62                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:178:62                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:184:61                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:191:62                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:229:69                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:243:77                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:257:51                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:261:54                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:274:49                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:278:52                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:305:56                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:309:59                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:335:50                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:339:53                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:377:48                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:381:51                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:422:51                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:426:54                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:464:57                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:468:60                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:497:53                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:501:56                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:532:51                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:536:54                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:564:54                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:568:57                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:617:50                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:621:53                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:647:50                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:651:53                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:702:56                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:706:59                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:729:69                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:736:51                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:740:54                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openstack/openstack.go:751:87                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openweathermap/openweathermap.go:120:71         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/openweathermap/openweathermap.go:200:68         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/p4runtime/p4runtime.go:216:19                   errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/passenger/passenger.go:159:58                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/pf/pf.go:40:69                                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/pf/pf.go:189:13                                 errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/pf/pf.go:191:97                                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/pf/pf.go:193:76                                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/pf/pf.go:204:67                                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/pf/pf.go:211:56                                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/phpfpm/fcgi_client.go:64:7                      errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/phpfpm/fcgi_test.go:245:7                       errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/phpfpm/phpfpm.go:161:80                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/phpfpm/phpfpm.go:265:68                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/ping/ping_notwindows.go:29:23                   errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/ping/ping_notwindows.go:50:56                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/ping/ping_notwindows.go:52:47                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/ping/ping_notwindows.go:62:37                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/postfix/postfix.go:38:59                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/postfix/postfix.go:91:65                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/postfix/postfix.go:98:62                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/postgresql/service.go:107:51                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/postgresql/service.go:159:86                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/powerdns/powerdns.go:76:7                       errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/powerdns_recursor/powerdns_recursor.go:40:57    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/processes/processes_notwindows.go:203:18        errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/processes/processes_notwindows.go:203:45        errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/procstat/pgrep.go:21:61                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/procstat/pgrep.go:74:55                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/consul.go:58:63                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/kubernetes.go:53:77                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/kubernetes.go:60:57                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/kubernetes.go:67:76                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/kubernetes.go:72:62                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/kubernetes.go:243:53                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/parser.go:39:8                       errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/prometheus/parser.go:42:80                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/parser.go:49:61                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/prometheus.go:152:75                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/prometheus.go:156:75                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/prometheus.go:342:67                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/prometheus.go:352:47                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/prometheus/prometheus.go:367:11                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors

@zak-pawel zak-pawel closed this Feb 24, 2023
@zak-pawel zak-pawel reopened this Feb 24, 2023
Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@powersj powersj added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Feb 28, 2023
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the effort @zak-pawel! Some minor comments...

plugins/inputs/nginx_plus/nginx_plus.go Outdated Show resolved Hide resolved
plugins/inputs/nginx_sts/nginx_sts.go Outdated Show resolved Hide resolved
plugins/inputs/nginx_vts/nginx_vts.go Outdated Show resolved Hide resolved
@telegraf-tiger
Copy link
Contributor

telegraf-tiger bot commented Mar 1, 2023

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks six times @zak-pawel! ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants