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

fix: update .golangci.yml for more recent version of linter #8677

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 65 additions & 76 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
linters-settings:
depguard:
list-type: blacklist
packages:
- github.com/jenkins-x/jx/v2/pkg/log/
- github.com/satori/go.uuid
- github.com/pborman/uuid
packages-with-error-message:
- github.com/jenkins-x/jx/v2/pkg/log/: "use jenkins-x/jx-logging instead"
- github.com/satori/go.uuid: "use github.com/google/uuid instead"
- github.com/pborman/uuid: "use github.com/google/uuid instead"
rules:
main:
list-mode: original
deny:
- pkg: github.com/jenkins-x/jx/v2/pkg/log
desc: "use jenkins-x/jx-logging instead"
- pkg: github.com/satori/go.uuid
desc: "use github.com/google/uuid instead"
- pkg: github.com/pborman/uuid
desc: "use github.com/google/uuid instead"
dupl:
threshold: 100
exhaustive:
Expand All @@ -21,48 +22,42 @@ linters-settings:
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
- importShadow # not important for now
- unnamedResult # not important
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
- importShadow # not important for now
- unnamedResult # not important
gocyclo:
min-complexity: 15
goimports: {}
golint:
min-confidence: 0
revive:
confidence: 0
gofmt:
simplify: true
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: [argument, case, condition, return]
mnd:
# don't include the "operation" and "assign"
checks: [argument, case, condition, return]
govet:
check-shadowing: true
settings:
printf:
funcs:
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Debugf
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Infof
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Warnf
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Errorf
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Fatalf
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Debugf
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Infof
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Warnf
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Errorf
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Fatalf
lll:
line-length: 140
maligned:
suggest-new: true
misspell: {}
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
Expand All @@ -71,52 +66,46 @@ linters:
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- asciicheck
- bodyclose
- deadcode
- depguard
- errcheck
- gofmt
- goimports
- goprintffuncname
- gosec
- gosimple
- ineffassign
- misspell
- nakedret
- rowserrcheck
- staticcheck
- structcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- revive
- gocritic
- govet
- dupl
- asciicheck
- bodyclose
- depguard
- errcheck
- gofmt
- goimports
- goprintffuncname
- gosec
- gosimple
- ineffassign
- misspell
- mnd
- nakedret
- rowserrcheck
- staticcheck
- typecheck
- unconvert
- unparam
- unused
- revive
- gocritic
- govet
- dupl
issues:
exclude-dirs:
- cmd/docs
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# - path: _test\.go
# linters:
# - gomnd
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"
# - path: _test\.go
# linters:
# - gomnd
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"
exclude:
- 'shadow: declaration of "err" shadows declaration at'
- 'shadow: declaration of "err" shadows declaration at'
max-same-issues: 0

run:
timeout: 30m
skip-dirs:
- cmd/docs
# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.42.x # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"
2 changes: 1 addition & 1 deletion pkg/cmd/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func NewCmdDashboard() (*cobra.Command, *Options) {
Short: "View the Jenkins X Pipelines Dashboard",
Long: cmdLong,
Example: cmdExample,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
err := o.Run()
helper.CheckErr(err)
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/namespace/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewCmdNamespace() (*cobra.Command, *Options) {
Short: "View or change the current namespace context in the current Kubernetes cluster",
Long: cmdLong,
Example: cmdExample,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
o.Args = args
err := o.Run()
helper.CheckErr(err)
Expand Down
14 changes: 7 additions & 7 deletions pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Main(args []string) *cobra.Command {
getCmd := &cobra.Command{
Use: "get TYPE [flags]",
Short: "Display one or more resources",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Help()
helper.CheckErr(err)
},
Expand All @@ -75,7 +75,7 @@ func Main(args []string) *cobra.Command {
addCmd := &cobra.Command{
Use: "add TYPE [flags]",
Short: "Adds one or more resources",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Help()
helper.CheckErr(err)
},
Expand All @@ -84,15 +84,15 @@ func Main(args []string) *cobra.Command {
Use: "build TYPE [flags]",
Short: "Display one or more resources relating to a pipeline build",
Aliases: []string{"builds"},
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Help()
helper.CheckErr(err)
},
}
createCmd := &cobra.Command{
Use: "create TYPE [flags]",
Short: "Create one or more resources",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Help()
helper.CheckErr(err)
},
Expand All @@ -101,15 +101,15 @@ func Main(args []string) *cobra.Command {
startCmd := &cobra.Command{
Use: "start TYPE [flags]",
Short: "Starts a resource",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Help()
helper.CheckErr(err)
},
}
stopCmd := &cobra.Command{
Use: "stop TYPE [flags]",
Short: "Stops a resource",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Help()
helper.CheckErr(err)
},
Expand Down Expand Up @@ -206,7 +206,7 @@ func aliasCommand(rootCmd *cobra.Command, fn func(cmd *cobra.Command, args []str
Use: name,
Short: "alias for: " + strings.Join(realArgs, " "),
Aliases: aliases,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
realArgs = append(realArgs, args...)
log.Logger().Debugf("about to invoke alias: %s", strings.Join(realArgs, " "))
fn(rootCmd, realArgs)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewCmdUI() (*cobra.Command, *Options) {
Short: "Views the Jenkins X UI (octant)",
Long: cmdLong,
Example: cmdExample,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
err := o.Run()
helper.CheckErr(err)
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewCmdUpgrade() (*cobra.Command, *Options) {
Short: "Upgrades resources",
Long: cmdLong,
Example: cmdExample,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
err := o.Run()
helper.CheckErr(err)
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/upgrade/upgrade_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func NewCmdUpgradeCLI() (*cobra.Command, *CLIOptions) {
Short: "Upgrades your local Jenkins X CLI",
Long: cmdCLILong,
Example: cmdCLIExample,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
err := o.Run()
helper.CheckErr(err)
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/upgrade/upgrade_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewCmdUpgradePlugins() (*cobra.Command, *PluginOptions) {
Short: "Upgrades all of the plugins in your local Jenkins X CLI",
Long: cmdPluginsLong,
Example: cmdPluginsExample,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
err := o.Run()
helper.CheckErr(err)
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func NewCmdVersion() (*cobra.Command, *Options) {
cmd := &cobra.Command{
Use: "version",
Short: "Displays the version of this command",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
o.run()
},
}
Expand Down
Loading