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 Windows (part2) #13096

Merged
merged 1 commit into from
Apr 25, 2023
Merged

chore: Fix linter findings for Windows (part2) #13096

merged 1 commit into from
Apr 25, 2023

Conversation

zak-pawel
Copy link
Collaborator

It is only part of the bigger job: #13036
After all findings in whole project are handled for Windows, linter CI job for Windows can be enabled.

Fixes for following linters have been made:

  • gosec
  • ineffassign
  • interfacebloat
  • lll
  • nakedret
  • nilerr
  • prealloc
  • staticcheck
  • unconvert

Following findings were addressed:

logger\event_logger.go:42:2                                                   nakedret        naked return in func `Write` with 18 lines of code
logger\event_logger_test.go:33                                                lll             line is 162 characters
plugins\inputs\win_eventlog\util.go:47:82                                     unconvert       unnecessary conversion
plugins\inputs\win_eventlog\util.go:58:30                                     unconvert       unnecessary conversion
plugins\inputs\win_eventlog\util.go:60:17                                     unconvert       unnecessary conversion
plugins\inputs\win_eventlog\util.go:60:47                                     unconvert       unnecessary conversion
plugins\inputs\win_eventlog\util.go:139:2                                     prealloc        Consider pre-allocating `fieldsUnique`
plugins\inputs\win_eventlog\win_eventlog.go:137:27                            gosec           G601: Implicit memory aliasing in for loop.
plugins\inputs\win_eventlog\win_eventlog.go:407:28                            unconvert       unnecessary conversion
plugins\inputs\win_eventlog\win_eventlog.go:412:3                             nilerr          error is not nil (line 407) but it returns nil
plugins\inputs\win_eventlog\win_eventlog.go:430:3                             nilerr          error is not nil (line 428) but it returns nil
plugins\inputs\win_eventlog\zsyscall_windows.go:92:15                         staticcheck     SA1019: syscall.Syscall9 has been deprecated since Go 1.18: Use SyscallN instead.
plugins\inputs\win_eventlog\zsyscall_windows.go:96:10                         unconvert       unnecessary conversion
plugins\inputs\win_eventlog\zsyscall_windows.go:100:10                        unconvert       unnecessary conversion
plugins\inputs\win_eventlog\zsyscall_windows.go:113:2                         nakedret        naked return in func `_EvtSubscribe` with 32 lines of code
plugins\inputs\win_eventlog\zsyscall_windows.go:125:15                        staticcheck     SA1019: syscall.Syscall9 has been deprecated since Go 1.18: Use SyscallN instead.
plugins\inputs\win_eventlog\zsyscall_windows.go:145:2                         nakedret        naked return in func `_EvtRender` with 30 lines of code
plugins\inputs\win_eventlog\zsyscall_windows.go:149:15                        staticcheck     SA1019: syscall.Syscall has been deprecated since Go 1.18: Use SyscallN instead.
plugins\inputs\win_eventlog\zsyscall_windows.go:157:2                         nakedret        naked return in func `_EvtClose` with 10 lines of code
plugins\inputs\win_eventlog\zsyscall_windows.go:161:15                        staticcheck     SA1019: syscall.Syscall6 has been deprecated since Go 1.18: Use SyscallN instead.
plugins\inputs\win_eventlog\zsyscall_windows.go:178:2                         nakedret        naked return in func `_EvtNext` with 19 lines of code
plugins\inputs\win_eventlog\zsyscall_windows.go:192:15                        staticcheck     SA1019: syscall.Syscall9 has been deprecated since Go 1.18: Use SyscallN instead.
plugins\inputs\win_eventlog\zsyscall_windows.go:199:10                        unconvert       unnecessary conversion
plugins\inputs\win_eventlog\zsyscall_windows.go:212:2                         nakedret        naked return in func `_EvtFormatMessage` with 32 lines of code
plugins\inputs\win_eventlog\zsyscall_windows.go:216:15                        staticcheck     SA1019: syscall.Syscall6 has been deprecated since Go 1.18: Use SyscallN instead.
plugins\inputs\win_eventlog\zsyscall_windows.go:234:2                         nakedret        naked return in func `_EvtOpenPublisherMetadata` with 20 lines of code
plugins\inputs\win_eventlog\zsyscall_windows.go:239:15                        staticcheck     SA1019: syscall.Syscall has been deprecated since Go 1.18: Use SyscallN instead.
plugins\inputs\win_eventlog\zsyscall_windows.go:251:15                        staticcheck     SA1019: syscall.Syscall has been deprecated since Go 1.18: Use SyscallN instead.
plugins\inputs\win_perf_counters\pdh.go:513                                   lll             line is 170 characters
plugins\inputs\win_perf_counters\pdh.go:518                                   lll             line is 163 characters
plugins\inputs\win_perf_counters\pdh.go:535                                   lll             line is 168 characters
plugins\inputs\win_perf_counters\pdh.go:539                                   lll             line is 170 characters
plugins\inputs\win_perf_counters\pdh.go:580                                   lll             line is 208 characters
plugins\inputs\win_perf_counters\pdh.go:583                                   lll             line is 428 characters
plugins\inputs\win_perf_counters\pdh.go:586                                   lll             line is 321 characters
plugins\inputs\win_perf_counters\pdh_amd64.go:75                              lll             line is 182 characters
plugins\inputs\win_perf_counters\pdh_amd64.go:103                             lll             line is 162 characters
plugins\inputs\win_perf_counters\pdh_amd64.go:116                             lll             line is 173 characters
plugins\inputs\win_perf_counters\pdh_amd64.go:118                             lll             line is 180 characters
plugins\inputs\win_perf_counters\performance_query.go:20:23                   interfacebloat  the interface has more than 10 methods: 13
plugins\inputs\win_perf_counters\win_perf_counters.go:168                     lll             line is 204 characters
plugins\inputs\win_perf_counters\win_perf_counters.go:367                     lll             line is 164 characters
plugins\inputs\win_perf_counters\win_perf_counters_integration_test.go:541:2  ineffassign     ineffectual assignment to err
plugins\inputs\win_perf_counters\win_perf_counters_integration_test.go:541:2  staticcheck     SA4006: this value of `err` is never used
plugins\inputs\win_perf_counters\win_perf_counters_test.go:235:2              ineffassign     ineffectual assignment to ret
plugins\inputs\win_perf_counters\win_perf_counters_test.go:242                lll             line is 185 characters
plugins\inputs\win_perf_counters\win_perf_counters_test.go:1352               lll             line is 162 characters
plugins\inputs\win_perf_counters\win_perf_counters_test.go:1731               lll             line is 163 characters
plugins\inputs\win_perf_counters\win_perf_counters_test.go:1926               lll             line is 163 characters
plugins\inputs\win_services\win_services_test.go:214:24                       unconvert       unnecessary conversion
plugins\inputs\win_services\win_services_test.go:215:31                       unconvert       unnecessary conversion
plugins\inputs\win_services\win_services_test.go:237:24                       unconvert       unnecessary conversion
plugins\inputs\win_services\win_services_test.go:238:31                       unconvert       unnecessary conversion

@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 Apr 18, 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.

Looks good to me, just have one comment regarding the win_eventlog finding. I think this is actually a true-positive and I think the current code is wrong... Not completely sure though...

plugins/inputs/win_eventlog/win_eventlog.go 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.

Looks good to me. Thanks @zak-pawel!

@srebhan srebhan merged commit 4d4bed4 into influxdata:master Apr 25, 2023
powersj pushed a commit that referenced this pull request May 22, 2023
Co-authored-by: pzak <pzak>
(cherry picked from commit 4d4bed4)
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