Skip to content

Commit

Permalink
gocritic
Browse files Browse the repository at this point in the history
  • Loading branch information
phm07 committed Aug 12, 2024
1 parent de9854a commit d2b6433
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ linters:
# - dupl
# - errcheck
- exhaustive
# - gocritic
- gocritic
- golint
- gci
- gomodguard
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/config/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion internal/cmd/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion internal/state/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d2b6433

Please sign in to comment.