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 (part7) #12772

Merged
merged 2 commits into from
Mar 3, 2023
Merged

chore: Fix linter findings for errorlint (part7) #12772

merged 2 commits into from
Mar 3, 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/[r-z]* packages were fixed:

plugins/inputs/rabbitmq/rabbitmq.go:384:15              errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/rabbitmq/rabbitmq.go:393:62              errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/raindrops/raindrops.go:57:75             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/ras/ras.go:189:90                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/redfish/redfish.go:202:48                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/redis/redis.go:241:65                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/redis/redis.go:332:59                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/redis_sentinel/redis_sentinel.go:65:65   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/redis_sentinel/redis_sentinel.go:139:64  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb.go:83:59             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:25:56      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:29:54      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:33:55      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:37:54      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:41:53      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:115:54     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:120:59     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:143:53     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:148:58     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:167:52     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:190:52     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/rethinkdb/rethinkdb_server.go:196:57     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/riak/riak.go:111:72                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/riak/riak.go:129:59                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sensors/sensors.go:48:55                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sensors/sensors.go:81:87                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sflow/packetdecoder.go:42:19             errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/sflow/sflow.go:118:66                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/slab/slab.go:101:77                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/smart/smart.go:412:130                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/smart/smart.go:505:101                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/smart/smart.go:669:100                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/smart/smart.go:738:110                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/smart/smart.go:885:20                    errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/snmp/netsnmp.go:49:17                    errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/snmp/netsnmp.go:197:17                   errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/snmp/netsnmp.go:197:42                   errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/snmp/snmp.go:491:17                      errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/snmp_trap/snmp_trap.go:176:52            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/snmp_trap/snmp_trap.go:180:52            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/snmp_trap/snmp_trap.go:184:52            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/socketstat/socketstat.go:71:67           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:113:55                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:121:72                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:132:83                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:141:81                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:150:82                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:159:82                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:168:84                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:258:65                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:271:56                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:278:68                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:284:66                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:290:67                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:296:67                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:302:69                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:309:58                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:363:47                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:384:58                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sql/sql.go:394:64                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sqlserver/sqlserver.go:280:114           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sqlserver/sqlserver.go:293:70            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sqlserver/sqlserver.go:329:20            errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/stackdriver/stackdriver.go:150:8         errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/stackdriver/stackdriver.go:179:8         errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/stackdriver/stackdriver.go:411:76        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/statsd/statsd.go:522:10                  errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/supervisor/supervisor.go:65:57           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/supervisor/supervisor.go:72:57           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/supervisor/supervisor.go:78:66           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/supervisor/supervisor.go:93:58           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/supervisor/supervisor.go:116:68          errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/supervisor/supervisor.go:128:68          errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/supervisor/supervisor.go:147:65          errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/supervisor/supervisor.go:152:56          errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/suricata/suricata.go:119:7               errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/swap/swap.go:27:59                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/syslog/rfc3164_test.go:97:19             errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/syslog/rfc5426_test.go:261:19            errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/syslog/syslog.go:244:82                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/syslog/syslog.go:277:65                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/syslog/syslog.go:304:64                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sysstat/sysstat.go:88:55                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sysstat/sysstat.go:116:54                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sysstat/sysstat.go:162:87                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/sysstat/sysstat.go:221:6                 errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/sysstat/sysstat.go:276:33                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/system/ps.go:201:5                       errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/systemd_units/systemd_units.go:210:88    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/temp/temp.go:29:70                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/temp/temp.go:31:60                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/tengine/tengine.go:126:75                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/tengine/tengine.go:137:20                errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/udp_listener/udp_listener.go:143:82      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/udp_listener/udp_listener.go:167:19      errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/inputs/unbound/unbound.go:60:85                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/unbound/unbound.go:63:77                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/unbound/unbound.go:88:72                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/unbound/unbound.go:110:52                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/upsd/upsd.go:116:88                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/upsd/upsd.go:124:93                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/varnish/varnish.go:95:73                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/varnish/varnish.go:110:50                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/varnish/varnish.go:145:52                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/varnish/varnish.go:154:54                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/varnish/varnish.go:158:54                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/varnish/varnish.go:274:71                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/varnish/varnish.go:279:93                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/vault/vault.go:67:49                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/vault/vault.go:74:64                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/vault/vault.go:107:70                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/vault/vault.go:118:61                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/vault/vault.go:128:47                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/vault/vault.go:136:72                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/vault/vault.go:158:71                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/vault/vault.go:175:72                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/vsphere/endpoint.go:284:22               errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/vsphere/endpoint.go:298:19               errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/vsphere/endpoint.go:1000:8               errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/vsphere/vsphere.go:139:7                 errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/inputs/webhooks/webhooks.go:95:50               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/webhooks/webhooks.go:101:52              errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/wireguard/wireguard.go:56:64             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/x509_cert/x509_cert.go:284:64            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/x509_cert/x509_cert.go:293:61            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/x509_cert/x509_cert.go:433:70            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/zipkin/zipkin.go:136:51                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/inputs/zipkin/zipkin_test.go:657:83             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors

@telegraf-tiger
Copy link
Contributor

telegraf-tiger bot commented Mar 1, 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.

Thanks! Almost there!

@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 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 @zak-pawel for the epic effort. How many of those will follow? :-)

@srebhan srebhan merged commit e2a510f into influxdata:master Mar 3, 2023
@zak-pawel
Copy link
Collaborator Author

Thanks @zak-pawel for the epic effort. How many of those will follow? :-)

@srebhan Only this short one #12785

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore linter 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