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 (part3) #12704

Merged
merged 2 commits into from
Feb 22, 2023
Merged

chore: Fix linter findings for errorlint (part3) #12704

merged 2 commits into from
Feb 22, 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/outputs package were fixed:

plugins/outputs/amon/amon.go:86:57                                          errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/amon/amon.go:90:58                                          errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/amon/amon.go:96:50                                          errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/amon/amon.go:116:69                                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/amqp/amqp.go:164:19                                         errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/amqp/client.go:73:55                                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/amqp/client.go:113:53                                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/amqp/client.go:142:19                                       errorlint  comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/outputs/azure_data_explorer/azure_data_explorer.go:193:74           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/azure_data_explorer/azure_data_explorer.go:198:77           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/azure_monitor/azure_monitor.go:190:59                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/azure_monitor/azure_monitor.go:326:71                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/azure_monitor/azure_monitor.go:331:6                        errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/azure_monitor/azure_monitor.go:331:6                        errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/outputs/cloud_pubsub/cloud_pubsub.go:125:61                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/datadog/datadog.go:134:57                                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/datadog/datadog.go:195:88                                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/dynatrace/dynatrace.go:137:53                               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/dynatrace/dynatrace.go:150:63                               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/dynatrace/dynatrace.go:168:62                               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/elasticsearch/elasticsearch.go:172:47                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/elasticsearch/elasticsearch.go:208:63                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/elasticsearch/elasticsearch.go:313:72                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/elasticsearch/elasticsearch.go:341:106                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/elasticsearch/elasticsearch.go:373:95                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/exec/exec.go:103:6                                          errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/outputs/exec/exec.go:117:63                                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/exec/exec.go:120:51                                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/exec/exec.go:167:7                                          errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/outputs/execd/execd.go:92:50                                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/execd/execd_test.go:165:7                                   errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/outputs/execd/execd_test.go:168:33                                  errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/file/file.go:100:58                                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/graphite/graphite.go:141:5                                  errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/outputs/graphite/graphite.go:152:14                                 errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/graphite/graphite.go:187:49                                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/graylog/graylog.go:462:63                                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/groundwork/groundwork.go:118:45                             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/groundwork/groundwork.go:126:46                             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/http/http.go:242:71                                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/http/http.go:265:68                                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/http/http.go:270:61                                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb/http.go:333:52                                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb/http.go:341:52                                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb/http.go:347:45                                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb/http.go:464:61                                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb/influxdb.go:90:55                                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb/influxdb.go:97:72                                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb/influxdb.go:148:22                                 errorlint  type switch on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/influxdb/influxdb.go:182:73                                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb/influxdb.go:218:74                                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb/udp.go:88:63                                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb_v2/http.go:190:18                                  errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/influxdb_v2/http.go:222:19                                  errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/influxdb_v2/influxdb_v2.go:68:55                            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb_v2/influxdb_v2.go:75:72                            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/influxdb_v2/influxdb_v2.go:147:74                           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/instrumental/instrumental.go:82:74                          errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/instrumental/instrumental.go:151:6                          errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/outputs/kafka/kafka.go:149:63                                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/kafka/kafka.go:212:60                                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/kafka/kafka.go:224:18                                       errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/kafka/kafka.go:226:8                                        errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/outputs/kafka/kafka.go:230:8                                        errorlint  comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error
plugins/outputs/librato/librato.go:132:54                                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/librato/librato.go:142:58                                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/librato/librato.go:162:50                                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/librato/librato.go:209:73                                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/logzio/logzio.go:100:54                                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/logzio/logzio.go:105:56                                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/logzio/logzio.go:111:49                                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/logzio/logzio.go:125:58                                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/logzio/logzio.go:132:50                                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/mongodb/mongodb.go:31:62                                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/mongodb/mongodb.go:36:62                                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/mongodb/mongodb.go:172:69                                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/mongodb/mongodb.go:183:46                                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/mongodb/mongodb.go:187:85                                   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/mqtt/mqtt.go:129:61                                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/mqtt/mqtt.go:142:60                                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/nats/nats.go:111:57                                         errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/newrelic/newrelic.go:72:57                                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/nsq/nsq.go:66:57                                            errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/opentsdb/opentsdb.go:70:54                                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/opentsdb/opentsdb.go:76:68                                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/opentsdb/opentsdb.go:80:57                                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/opentsdb/opentsdb.go:93:54                                  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/opentsdb/opentsdb.go:192:60                                 errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/postgresql/postgresql.go:357:16                             errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/postgresql/postgresql.go:403:93                             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/postgresql/table_manager.go:388:57                          errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/prometheus_client/prometheus_client.go:116:52               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/redistimeseries/redistimeseries.go:83:51                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/riemann/riemann.go:73:62                                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/riemann/riemann.go:86:59                                    errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/riemann_legacy/riemann_legacy.go:67:69                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/riemann_legacy/riemann_legacy.go:80:90                      errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/sensu/sensu.go:354:56                                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/socket_writer/socket_writer.go:122:18                       errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/socket_writer/socket_writer.go:126:49                       errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/sql/sql.go:245:43                                           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/sql/sql.go:249:45                                           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/sql/sql.go:255:47                                           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/sql/sql.go:259:44                                           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/sql/sql.go:264:47                                           errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/stomp/stomp.go:87:51                                        errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/syslog/syslog.go:123:21                                     errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/syslog/syslog.go:126:49                                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/timestream/timestream.go:290:51                             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/timestream/timestream.go:305:51                             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/timestream/timestream.go:311:51                             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/timestream/timestream.go:318:51                             errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/timestream/timestream.go:371:15                             errorlint  type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors
plugins/outputs/warp10/warp10.go:125:68                                     errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/wavefront/wavefront.go:129:55                               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/websocket/websocket.go:71:54                                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/websocket/websocket.go:76:49                                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/websocket/websocket.go:88:62                                errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/websocket/websocket.go:100:39                               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/websocket/websocket.go:165:58                               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/websocket/websocket.go:176:56                               errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/yandex_cloud_monitoring/yandex_cloud_monitoring.go:161:56   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/yandex_cloud_monitoring/yandex_cloud_monitoring.go:189:91   errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
plugins/outputs/yandex_cloud_monitoring/yandex_cloud_monitoring.go:205:101  errorlint  non-wrapping format verb for fmt.Errorf. Use `%w` to format errors

@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 17, 2023
plugins/outputs/amon/amon.go Outdated Show resolved Hide resolved
plugins/outputs/amon/amon.go Outdated Show resolved Hide resolved
plugins/outputs/dynatrace/dynatrace.go Outdated Show resolved Hide resolved
plugins/outputs/dynatrace/dynatrace.go Outdated Show resolved Hide resolved
plugins/outputs/dynatrace/dynatrace.go Outdated Show resolved Hide resolved
plugins/outputs/postgresql/postgresql.go Show resolved Hide resolved
plugins/outputs/riemann_legacy/riemann_legacy.go Outdated Show resolved Hide resolved
plugins/outputs/riemann_legacy/riemann_legacy.go Outdated Show resolved Hide resolved
plugins/outputs/timestream/timestream.go Outdated Show resolved Hide resolved
plugins/outputs/warp10/warp10.go Outdated Show resolved Hide resolved
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.

I do have a few minor comments. Thanks for this epic effort @zak-pawel!

plugins/outputs/azure_monitor/azure_monitor.go Outdated Show resolved Hide resolved
plugins/outputs/dynatrace/dynatrace.go Outdated Show resolved Hide resolved
plugins/outputs/graylog/graylog.go Show resolved Hide resolved
@telegraf-tiger
Copy link
Contributor

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.

Huge thank you @zak-pawel!

@srebhan srebhan merged commit 39d6b1d into influxdata:master Feb 22, 2023
powersj pushed a commit that referenced this pull request Feb 27, 2023
Co-authored-by: Pawel Zak <Pawel Zak>
(cherry picked from commit 39d6b1d)
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.

4 participants