Skip to content

Commit fe22ab4

Browse files
committed
fix lint warnings
1 parent aac64bc commit fe22ab4

15 files changed

Lines changed: 29 additions & 24 deletions

File tree

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: "2"
2+
linters:
3+
exclusions:
4+
paths:
5+
- third_party

action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func (a Action) split(pipelines bool) Action {
320320
case shlex.QUOTING_STATE:
321321
invoked.action.rawValues[index].Value = fmt.Sprintf(`'%v'`, strings.ReplaceAll(value.Value, `'`, `'"'"'`))
322322
default:
323-
invoked.action.rawValues[index].Value = strings.Replace(value.Value, ` `, `\ `, -1)
323+
invoked.action.rawValues[index].Value = strings.ReplaceAll(value.Value, ` `, `\ `)
324324
}
325325
}
326326
if !invoked.action.meta.Nospace.Matches(value.Value) {

action_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
func init() {
18-
os.Unsetenv("LS_COLORS")
18+
_ = os.Unsetenv("LS_COLORS")
1919
}
2020

2121
func assertEqual(t *testing.T, expected, actual InvokedAction) {

carapace_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
func init() {
15-
os.Unsetenv("LS_COLORS")
15+
_ = os.Unsetenv("LS_COLORS")
1616
}
1717

1818
func execCompletion(args ...string) (context Context) {
@@ -58,7 +58,7 @@ func execCompletion(args ...string) (context Context) {
5858
func testContext(t *testing.T, expected Context, args ...string) {
5959
t.Run(strings.Join(args, " "), func(t *testing.T) {
6060
null, _ := os.Open(os.DevNull)
61-
defer null.Close()
61+
defer null.Close() // nolint:errcheck
6262

6363
sOut := os.Stdout
6464
sErr := os.Stderr

command.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ func addCompletionCommand(targetCmd *cobra.Command) {
4040
}
4141

4242
if s, err := complete(parentCmd, args); err != nil {
43-
fmt.Fprintln(io.MultiWriter(parentCmd.OutOrStderr(), LOG.Writer()), err.Error())
43+
fmt.Fprintln(io.MultiWriter(parentCmd.OutOrStderr(), LOG.Writer()), err.Error()) // nolint:errcheck
4444
} else {
45-
fmt.Fprintln(io.MultiWriter(parentCmd.OutOrStdout(), LOG.Writer()), s)
45+
fmt.Fprintln(io.MultiWriter(parentCmd.OutOrStdout(), LOG.Writer()), s) // nolint:errcheck
4646
}
4747
},
4848
FParseErrWhitelist: cobra.FParseErrWhitelist{
@@ -93,7 +93,7 @@ func addCompletionCommand(targetCmd *cobra.Command) {
9393
specCmd := &cobra.Command{
9494
Use: "spec",
9595
Run: func(cmd *cobra.Command, args []string) {
96-
fmt.Fprint(cmd.OutOrStdout(), spec.Spec(targetCmd))
96+
fmt.Fprint(cmd.OutOrStdout(), spec.Spec(targetCmd)) // nolint:errcheck
9797
},
9898
}
9999
carapaceCmd.AddCommand(specCmd)
@@ -112,10 +112,10 @@ func addCompletionCommand(targetCmd *cobra.Command) {
112112
for _, arg := range args {
113113
if splitted := strings.SplitN(arg, "=", 2); len(splitted) == 2 {
114114
if err := style.Set(splitted[0], splitted[1]); err != nil {
115-
fmt.Fprint(cmd.ErrOrStderr(), err.Error())
115+
fmt.Fprint(cmd.ErrOrStderr(), err.Error()) // nolint:errcheck
116116
}
117117
} else {
118-
fmt.Fprintf(cmd.ErrOrStderr(), "invalid format: '%v'", arg)
118+
fmt.Fprintf(cmd.ErrOrStderr(), "invalid format: '%v'", arg) // nolint:errcheck
119119
}
120120
}
121121
},

compat_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestRegisterFlagCompletion(t *testing.T) {
5353
os.Args = []string{"", "__complete", "--flag", ""}
5454
_ = cmd.Execute()
5555

56-
w.Close()
56+
_ = w.Close()
5757
out, _ := io.ReadAll(r)
5858
os.Stdout = rescueStdout
5959

example/cmd/interspersed.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var interspersedCmd = &cobra.Command{
1111
Use: "interspersed",
1212
Short: "interspersed example",
1313
Run: func(cmd *cobra.Command, args []string) {
14-
fmt.Fprintf(cmd.OutOrStdout(), "#%v", args)
14+
fmt.Fprintf(cmd.OutOrStdout(), "#%v", args) // nolint:errcheck
1515
},
1616
}
1717

example/cmd/modifier_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestChdir(t *testing.T) {
101101
}
102102

103103
func TestChdirF(t *testing.T) {
104-
os.Unsetenv("LS_COLORS")
104+
_ = os.Unsetenv("LS_COLORS")
105105
sandbox.Package(t, "github.com/carapace-sh/carapace/example")(func(s *sandbox.Sandbox) {
106106
s.Files(
107107
".git/config", "",
@@ -159,7 +159,7 @@ func TestMultiParts(t *testing.T) {
159159
}
160160

161161
func TestPrefix(t *testing.T) {
162-
os.Unsetenv("LS_COLORS")
162+
_ = os.Unsetenv("LS_COLORS")
163163
sandbox.Package(t, "github.com/carapace-sh/carapace/example")(func(s *sandbox.Sandbox) {
164164
s.Files("subdir/file1.txt", "")
165165

@@ -294,7 +294,7 @@ func TestMultiPartsP(t *testing.T) {
294294
}
295295

296296
func TestSplit(t *testing.T) {
297-
os.Unsetenv("LS_COLORS")
297+
_ = os.Unsetenv("LS_COLORS")
298298
sandbox.Package(t, "github.com/carapace-sh/carapace/example")(func(s *sandbox.Sandbox) {
299299
s.Files("subdir/file1.txt", "")
300300

@@ -376,7 +376,7 @@ func TestSplit(t *testing.T) {
376376
}
377377

378378
func TestSplitP(t *testing.T) {
379-
os.Unsetenv("LS_COLORS")
379+
_ = os.Unsetenv("LS_COLORS")
380380
sandbox.Package(t, "github.com/carapace-sh/carapace/example")(func(s *sandbox.Sandbox) {
381381
s.Files("subdir/file1.txt", "")
382382

internal/common/message.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (m Messages) Integrate(values RawValues, prefix string) RawValues {
126126
}
127127

128128
func (m Messages) MarshalJSON() ([]byte, error) {
129-
var result []string = make([]string, 0, len(m.messages))
129+
var result = make([]string, 0, len(m.messages))
130130
for key := range m.messages {
131131
result = append(result, key)
132132
}

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func load(name string, c configMap) error {
9595
func GetStyleConfigs() []string { return config.Styles.Keys() }
9696
func GetStyleFields(name string) ([]Field, error) { return config.Styles.Fields(name) }
9797
func SetStyle(key, value string) error {
98-
return set("styles", key, strings.Replace(value, ",", " ", -1))
98+
return set("styles", key, strings.ReplaceAll(value, ",", " "))
9999
}
100100

101101
func set(name, key, value string) error {

0 commit comments

Comments
 (0)