More linting (#2099)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Address gocritic findings, enable it * Enable gosimple, no new findings to address
authored by Ville Skyttä · committed by GitHub · parent bd914e5 · Browse files · 6 files·+16 added−19 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+16 added−19 removed
- other:+16 added−19 removed
Provenance
- Commit
6b5f577- Tree
a935bf3- Author
Ville Skyttä <ville.skytta@upcloud.com>- Committer
GitHub <noreply@github.com>- Parent
bd914e5
6 files changed+16 added−19 removed
modified:doc/man_docs.go+1 added-1 removed
131 unmodified lines132 now = time.Unix(unixEpoch, 0)133 }134 header.Date = &now135 }136- header.date = (*header.Date).Format("Jan 2006")136+ header.date = header.Date.Format("Jan 2006")137 if header.Source == "" && !disableAutoGen {138 header.Source = "Auto generated by spf13/cobra"139 }140 return nil106 unmodified linesmodified:doc/util.go+1 added-1 removed
38 unmodified lines39 // Temporary workaround for yaml lib generating incorrect yaml with long strings40 // that do not contain \n.41 func forceMultiLine(s string) string {42 if len(s) > 60 && !strings.Contains(s, "\n") {43- s = s + "\n"43+ s += "\n"44 }45 return s46 }47 5 unmodified linesmodified:.golangci.yml+2 added-2 removed
27 unmodified lines2829303132323334353637383940404142434418 unmodified lines27 unmodified lines #- funlen - gas #- gochecknoinits - goconst #- gocritic - gocritic #- gocyclo #- gofmt - goimports - golint #- gomnd #- goprintffuncname #- gosec #- gosimple - gosimple - govet - ineffassign - interfacer #- lll18 unmodified linesmodified:bash_completions.go+9 added-12 removed
595 unmodified lines596 flags.VisitAll(func(flag *pflag.Flag) {597 if nonCompletableFlag(flag) {598 return599 }600- for key := range flag.Annotations {601- switch key {602- case BashCompOneRequiredFlag:603- format := " must_have_one_flag+=(\"--%s"604- if flag.Value.Type() != "bool" {605- format += "="606- }607- format += cbn608- WriteStringAndCheck(buf, fmt.Sprintf(format, flag.Name))600+ if _, ok := flag.Annotations[BashCompOneRequiredFlag]; ok {601+ format := " must_have_one_flag+=(\"--%s"602+ if flag.Value.Type() != "bool" {603+ format += "="604+ }605+ format += cbn606+ WriteStringAndCheck(buf, fmt.Sprintf(format, flag.Name))607 610- if len(flag.Shorthand) > 0 {611- WriteStringAndCheck(buf, fmt.Sprintf(" must_have_one_flag+=(\"-%s"+cbn, flag.Shorthand))612- }608+ if len(flag.Shorthand) > 0 {609+ WriteStringAndCheck(buf, fmt.Sprintf(" must_have_one_flag+=(\"-%s"+cbn, flag.Shorthand))610 }611 }612 })613 }96 unmodified linesmodified:command_test.go+1 added-1 removed
2775 unmodified lines2776 }2777 2778 func TestUnknownFlagShouldReturnSameErrorRegardlessOfArgPosition(t *testing.T) {2779 testCases := [][]string{2780- //{"--unknown", "--namespace", "foo", "child", "--bar"}, // FIXME: This test case fails, returning the error `unknown command "foo" for "root"` instead of the expected error `unknown flag: --unknown`2780+ // {"--unknown", "--namespace", "foo", "child", "--bar"}, // FIXME: This test case fails, returning the error `unknown command "foo" for "root"` instead of the expected error `unknown flag: --unknown`2781 {"--namespace", "foo", "--unknown", "child", "--bar"},2782 {"--namespace", "foo", "child", "--unknown", "--bar"},2783 {"--namespace", "foo", "child", "--bar", "--unknown"},2784 35 unmodified linesmodified:powershell_completions.go+2 added-2 removed
26 unmodified lines27 28 func genPowerShellComp(buf io.StringWriter, name string, includeDesc bool) {29 // Variables should not contain a '-' or ':' character30 nameForVar := name31- nameForVar = strings.Replace(nameForVar, "-", "_", -1)32- nameForVar = strings.Replace(nameForVar, ":", "_", -1)31+ nameForVar = strings.ReplaceAll(nameForVar, "-", "_")32+ nameForVar = strings.ReplaceAll(nameForVar, ":", "_")33 34 compCmd := ShellCompRequestCmd35 if !includeDesc {36 compCmd = ShellCompNoDescRequestCmd289 unmodified lines