Skip to content
Myr

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

6 files+16 added−19 removed

modified:doc/man_docs.go+1 added-1 removed
131 unmodified lines
132 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 nil
106 unmodified lines
modified:doc/util.go+1 added-1 removed
38 unmodified lines
39// Temporary workaround for yaml lib generating incorrect yaml with long strings40// that do not contain \n.41func 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 lines
modified:.golangci.yml+2 added-2 removed
modified:bash_completions.go+9 added-12 removed
595 unmodified lines
596 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))607610 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 lines
modified:command_test.go+1 added-1 removed
2775 unmodified lines
2776}27772778func 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 lines
modified:powershell_completions.go+2 added-2 removed
26 unmodified lines
2728func 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, ":", "_")3334 compCmd := ShellCompRequestCmd35 if !includeDesc {36 compCmd = ShellCompNoDescRequestCmd
289 unmodified lines