mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-05-09 18:23:21 +08:00
chore: update and streamline linting configuration and error formatting
- Update `.golangci.yaml` to version 2 and streamline settings - Remove specific linters from `.golangci.yaml` configuration - Add exclusion and formatter settings to `.golangci.yaml` - Change error message formatting in `plugin.go` to lowercase - Use `strings.ReplaceAll` instead of `strings.Replace` for better readability and performance in `plugin.go` and `plugin_test.go` Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
parent
07c75984e5
commit
0ec46c4fd2
@ -1,15 +1,9 @@
|
|||||||
run:
|
version: "2"
|
||||||
timeout: 5m
|
|
||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- asciicheck
|
- asciicheck
|
||||||
- durationcheck
|
- durationcheck
|
||||||
- errcheck
|
|
||||||
- errorlint
|
- errorlint
|
||||||
- exportloopref
|
|
||||||
- gci
|
|
||||||
- gofmt
|
|
||||||
- goimports
|
|
||||||
- gosec
|
- gosec
|
||||||
- misspell
|
- misspell
|
||||||
- nakedret
|
- nakedret
|
||||||
@ -19,12 +13,8 @@ linters:
|
|||||||
- revive
|
- revive
|
||||||
- usestdlibvars
|
- usestdlibvars
|
||||||
- wastedassign
|
- wastedassign
|
||||||
|
settings:
|
||||||
linters-settings:
|
|
||||||
gosec:
|
gosec:
|
||||||
# To select a subset of rules to run.
|
|
||||||
# Available rules: https://github.com/securego/gosec#available-rules
|
|
||||||
# Default: [] - means include all rules
|
|
||||||
includes:
|
includes:
|
||||||
- G102
|
- G102
|
||||||
- G106
|
- G106
|
||||||
@ -35,8 +25,30 @@ linters-settings:
|
|||||||
- G201
|
- G201
|
||||||
- G203
|
- G203
|
||||||
perfsprint:
|
perfsprint:
|
||||||
|
int-conversion: true
|
||||||
err-error: true
|
err-error: true
|
||||||
errorf: true
|
errorf: true
|
||||||
int-conversion: true
|
|
||||||
sprintf1: true
|
sprintf1: true
|
||||||
strconcat: true
|
strconcat: true
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
presets:
|
||||||
|
- comments
|
||||||
|
- common-false-positives
|
||||||
|
- legacy
|
||||||
|
- std-error-handling
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
formatters:
|
||||||
|
enable:
|
||||||
|
- gci
|
||||||
|
- gofmt
|
||||||
|
- goimports
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
@ -14,9 +14,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errMissingHost = errors.New("Error: missing server host")
|
errMissingHost = errors.New("error: missing server host")
|
||||||
errMissingPasswordOrKey = errors.New("Error: can't connect without a private SSH key or password")
|
errMissingPasswordOrKey = errors.New("error: can't connect without a private SSH key or password")
|
||||||
errCommandTimeOut = errors.New("Error: command timeout")
|
errCommandTimeOut = errors.New("error: command timeout")
|
||||||
envsFormat = "export {NAME}={VALUE}"
|
envsFormat = "export {NAME}={VALUE}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ type (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func escapeArg(arg string) string {
|
func escapeArg(arg string) string {
|
||||||
return "'" + strings.Replace(arg, "'", `'\''`, -1) + "'"
|
return "'" + strings.ReplaceAll(arg, "'", `'\''`) + "'"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Plugin) hostPort(host string) (string, string) {
|
func (p Plugin) hostPort(host string) (string, string) {
|
||||||
|
@ -638,7 +638,7 @@ func TestEnvOutput(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func unindent(text string) string {
|
func unindent(text string) string {
|
||||||
return strings.TrimSpace(strings.Replace(text, "\t", "", -1))
|
return strings.TrimSpace(strings.ReplaceAll(text, "\t", ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPlugin_scriptCommands(t *testing.T) {
|
func TestPlugin_scriptCommands(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user