Skip to content

Commit 3492d7b

Browse files
Update golangci-lint rules (#166)
1 parent 0571080 commit 3492d7b

6 files changed

Lines changed: 81 additions & 17 deletions

File tree

.golangci.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ linters:
3939
- unparam # gopls is better and more subtle
4040
- varnamelen # Lots of false positives of things that are fine
4141
- wrapcheck # Not every error must be wrapped
42-
- wsl # Very aggressive, some of this I like but tend to do anyway
43-
- wsl_v5 # Very aggressive, some of this I like but tend to do anyway
42+
- wsl # Deprecated
4443

4544
exclusions:
4645
presets:
4746
# See https://golangci-lint.run/usage/false-positives/#exclusion-presets
48-
- comments # Revive in particular has lots of false positives
4947
- std-error-handling
5048
- common-false-positives
5149
rules:
@@ -155,10 +153,7 @@ linters:
155153
disabled: true # predeclared does this
156154

157155
- name: unhandled-error
158-
arguments:
159-
- fmt\.(Fp|P)rint(ln|f)?
160-
- strings.Builder.Write(String|Byte)?
161-
- bytes.Buffer.Write(String|Byte)?
156+
disabled: true # errcheck handles this
162157

163158
- name: flag-parameter
164159
disabled: true # As far as I can work out this just doesn't like bools

command.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ func New(name string, options ...Option) (*Command, error) {
6767
errs = errors.Join(errs, err) // nil errors are discarded in join
6868

6969
err = Flag(&cfg.versionCalled, "version", 'V', false, "Show version info for "+name).apply(&cfg)
70-
errs = errors.Join(errs, err)
7170

71+
errs = errors.Join(errs, err)
7272
if errs != nil {
7373
return nil, errs
7474
}
@@ -472,7 +472,9 @@ func stripFlags(cmd *Command, args []string) []string {
472472
if len(args) <= 1 {
473473
return argsWithoutFlags
474474
}
475+
475476
args = args[1:]
477+
476478
continue
477479

478480
case arg != "" && !strings.HasPrefix(arg, "-"):
@@ -669,6 +671,7 @@ func writeSubcommands(cmd *Command, s *strings.Builder) error {
669671
} else {
670672
s.WriteString("\n\n")
671673
}
674+
672675
s.WriteString(colour.Title("Commands"))
673676
s.WriteByte(':')
674677
s.WriteByte('\n')

command_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,7 @@ func TestCommandNoRunNoSub(t *testing.T) {
899899

900900
func TestExecuteNilCommand(t *testing.T) {
901901
var cmd *cli.Command
902+
902903
err := cmd.Execute()
903904
test.Err(t, err)
904905

internal/flag/flag.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ const (
6060
)
6161

6262
const (
63-
boolTrue = "true"
64-
boolFalse = "false"
63+
boolTrue = "true"
6564
)
6665

6766
// NoShortHand should be passed as the "short" argument to [New] if the desired flag
@@ -891,6 +890,7 @@ func formatStringSlice(slice []string) string {
891890
length := len(slice)
892891
s := &strings.Builder{}
893892
s.WriteByte('[')
893+
894894
for index, elem := range slice {
895895
s.WriteString(strconv.Quote(elem))
896896
// Write commas and a space on every element other than the last one
@@ -899,6 +899,7 @@ func formatStringSlice(slice []string) string {
899899
s.WriteByte(' ')
900900
}
901901
}
902+
902903
s.WriteByte(']')
903904

904905
return s.String()

0 commit comments

Comments
 (0)