diff --git a/.golangci.yml b/.golangci.yml index 1532b8c6..7cd4b2ab 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -55,7 +55,7 @@ linters: # - dupl # - errcheck - exhaustive - # - gocritic + - gocritic - golint - gci - gomodguard diff --git a/internal/cmd/config/add.go b/internal/cmd/config/add.go index 8d1cc56a..b040d353 100644 --- a/internal/cmd/config/add.go +++ b/internal/cmd/config/add.go @@ -51,8 +51,7 @@ func runAdd(s state.State, cmd *cobra.Command, args []string) error { switch opt.T().(type) { case []string: before := util.AnyToStringSlice(val) - newVal := append(before, values...) - newVal = util.RemoveDuplicates(newVal) + newVal := util.RemoveDuplicates(append(before, values...)) val = newVal added = util.ToAnySlice(util.SliceDiff[[]string](newVal, before)) default: diff --git a/internal/cmd/output/output.go b/internal/cmd/output/output.go index 03f06b5f..22a7926b 100644 --- a/internal/cmd/output/output.go +++ b/internal/cmd/output/output.go @@ -265,7 +265,7 @@ func (o *Table) WriteHeader(columns []string) { if alias, ok := o.fieldAlias[col]; ok { col = alias } - header = append(header, strings.Replace(strings.ToUpper(col), "_", " ", -1)) + header = append(header, strings.ReplaceAll(strings.ToUpper(col), "_", " ")) } _, _ = fmt.Fprintln(o.w, strings.Join(header, "\t")) } @@ -296,7 +296,7 @@ func (o *Table) Write(columns []string, obj interface{}) { out = append(out, fn(obj)) continue } - if value, ok := dataL[strings.Replace(colName, "_", "", -1)]; ok { + if value, ok := dataL[strings.ReplaceAll(colName, "_", "")]; ok { if value == nil { out = append(out, util.NA("")) continue diff --git a/internal/cmd/util/util.go b/internal/cmd/util/util.go index 7e1d91f3..7d60e021 100644 --- a/internal/cmd/util/util.go +++ b/internal/cmd/util/util.go @@ -72,6 +72,8 @@ func GrossPrice(price hcloud.Price) string { switch price.Currency { case "EUR": currencyDisplay = "€" + default: + // unchanged } // The code/symbol and the amount are separated by a non-breaking space: @@ -176,7 +178,7 @@ func PrefixLines(text, prefix string) string { // DescribeFormat prints the passed object using the passed format string to stdout. func DescribeFormat(object interface{}, format string) error { if !strings.HasSuffix(format, "\n") { - format = format + "\n" + format += "\n" } t, err := template.New("").Parse(format) if err != nil { diff --git a/internal/state/config/options.go b/internal/state/config/options.go index 1d143a76..51674331 100644 --- a/internal/state/config/options.go +++ b/internal/state/config/options.go @@ -365,8 +365,9 @@ func (o *Option[T]) Completions() []string { switch any(t).(type) { case bool: return []string{"true", "false"} + default: + return nil } - return nil } func (o *Option[T]) Parse(values []string) (any, error) {