refactor: fix modernize lint issues
Description
Enable modernize lint in Golangci-lint configuration and fix appeared lint issues.
modernize.omitzero is disabled because it requires behaviour changes.
Click to expand
$ golangci-lint run
cmd/gen-docs/docs.go:397:15: stringsseq: Ranging over SplitSeq is more efficient (modernize)
envLines := strings.Split(strings.TrimSpace(envHelp), "\n\n")
^
internal/commands/ci/run/run_test.go:210:56: any: interface{} can be replaced by any (modernize)
api.ListMRs = func(client *gitlab.Client, projectID interface{}, opts *gitlab.ListProjectMergeRequestsOptions, listOpts ...api.CliListMROption) ([]*gitlab.BasicMergeRequest, error) {
^
internal/commands/cluster/agent/bootstrap/agent_bootstrap_test.go:999:43: any: interface{} can be replaced by any (modernize)
func (m containsBytesMatcher) Matches(arg interface{}) bool {
^
internal/commands/issuable/view/issuable_view.go:304:6: stringsbuilder: using string += string in a loop is inefficient (modernize)
out += fmt.Sprintf("%s %s %s\n\n", note.Author.Username, note.Body, note.CreatedAt.String())
^
internal/commands/issue/board/view/issue_board_view.go:476:3: stringsbuilder: using string += string in a loop is inefficient (modernize)
boardIssues += fmt.Sprintf("[white::b]%s\n%s[green:-:-]#%d[darkgray] - %s\n\n",
^
internal/commands/issue/issueutils/utils.go:88:3: forvar: copying variable is unneeded (modernize)
i, arg := i, arg
^
internal/commands/mr/mrutils/mrutils.go:242:3: forvar: copying variable is unneeded (modernize)
i, arg := i, arg
^
internal/commands/release/releaseutils/releaseutils.go:52:3: stringsbuilder: using string += string in a loop is inefficient (modernize)
assetsSources += asset.URL + "\n"
^
internal/git/ssh_config.go:86:26: stringsseq: Ranging over FieldsSeq is more efficient (modernize)
for _, name := range strings.Fields(arguments) {
^
internal/git/ssh_config.go:94:24: stringsseq: Ranging over FieldsSeq is more efficient (modernize)
for _, arg := range strings.Fields(arguments) {
^
internal/git/ssh_config.go:128:5: stringscutprefix: HasPrefix + TrimPrefix can be simplified to CutPrefix (modernize)
if strings.HasPrefix(path, "~") {
^
internal/glrepo/resolver.go:71:13: stringscutprefix: HasPrefix + TrimPrefix can be simplified to CutPrefix (modernize)
} else if strings.HasPrefix(remote.Resolved, "base:") {
^
internal/glrepo/resolver.go:163:13: stringscutprefix: HasPrefix + TrimPrefix can be simplified to CutPrefix (modernize)
} else if strings.HasPrefix(remote.Resolved, "head:") {
^
internal/iostreams/iostreams.go:395:5: minmax: if statement can be modernized using min (modernize)
if len(options) < limit {
^
internal/testing/httpmock/mocker.go:80:18: any: interface{} can be replaced by any (modernize)
Logf(string, ...interface{})
^
15 issues:
* modernize: 15
How has this been tested?
go test ./...
Edited by Oleksandr Redko