From 2519a9a89451642d17d99f6d8d6dfbf1fd48a52c Mon Sep 17 00:00:00 2001 From: appleboy Date: Sat, 16 Nov 2024 09:58:21 +0800 Subject: [PATCH] ci(golangci): enable comprehensive linting and update variable initialization - Add a `.golangci.yaml` configuration file with various linters enabled and specific settings for `gosec` and `perfsprint`. - Change `isTimeout` from being initialized to `true` to being declared as a `bool` variable without an initial value in `plugin.go`. Signed-off-by: appleboy --- .golangci.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ plugin.go | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .golangci.yaml diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..377f2f1 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,42 @@ +run: + timeout: 5m +linters: + enable: + - asciicheck + - durationcheck + - errcheck + - errorlint + - exportloopref + - gci + - gofmt + - goimports + - gosec + - misspell + - nakedret + - nilerr + - nolintlint + - perfsprint + - revive + - usestdlibvars + - wastedassign + +linters-settings: + gosec: + # To select a subset of rules to run. + # Available rules: https://github.com/securego/gosec#available-rules + # Default: [] - means include all rules + includes: + - G102 + - G106 + - G108 + - G109 + - G111 + - G112 + - G201 + - G203 + perfsprint: + err-error: true + errorf: true + int-conversion: true + sprintf1: true + strconcat: true diff --git a/plugin.go b/plugin.go index c0e1fec..c81d893 100644 --- a/plugin.go +++ b/plugin.go @@ -137,7 +137,7 @@ func (p Plugin) exec(host string, wg *sync.WaitGroup, errChannel chan error) { return } // read from the output channel until the done signal is passed - isTimeout := true + var isTimeout bool loop: for { select {