Skip to content

Commit a0aefd1

Browse files
golangci-lint: add mirror+nolintlint linters + fixes (#18863)
Signed-off-by: Tim Vaillancourt <[email protected]>
1 parent df20f01 commit a0aefd1

File tree

61 files changed

+86
-101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+86
-101
lines changed

.github/workflows/static_checks_etc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ jobs:
188188
189189
- name: Install golangci-lint
190190
if: steps.changes.outputs.go_files == 'true'
191-
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2
191+
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6
192192

193193
- name: Clean Env
194194
if: steps.changes.outputs.go_files == 'true'

.golangci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ linters:
1010
- errcheck
1111
- govet
1212
- ineffassign
13+
- mirror
14+
- nolintlint
1315
- perfsprint
1416
- sqlclosecheck
1517
- staticcheck
@@ -139,9 +141,6 @@ linters:
139141
- linters:
140142
- errcheck
141143
path: ^go/mysql/
142-
- linters:
143-
- revive
144-
path: ^go/mysql/collations
145144
- linters:
146145
- errcheck
147146
path: ^go/pools/.*_test.go

go/cmd/vtclient/cli/vtclient_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestVtclient(t *testing.T) {
7979
if err := cluster.Setup(); err != nil {
8080
t.Fatalf("InitSchemas failed: %v", err)
8181
}
82-
defer cluster.TearDown() // nolint:errcheck
82+
defer cluster.TearDown()
8383

8484
vtgateAddr := fmt.Sprintf("localhost:%v", cluster.Env.PortForProtocol("vtcombo", "grpc"))
8585
queries := []struct {

go/cmd/vtctl/vtctl_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
func logSyslog(msg string) {
2828
if syslogger, err := syslog.New(syslog.LOG_INFO, "vtctl "); err == nil {
29-
syslogger.Info(msg) // nolint:errcheck
29+
syslogger.Info(msg) //nolint:errcheck
3030
} else {
3131
log.Warningf("cannot connect to syslog: %v", err)
3232
}

go/cmd/vtctldclient/command/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func commandApplySchema(cmd *cobra.Command, args []string) error {
150150
var allSQL string
151151
if applySchemaOptions.SQLFile != "" {
152152
if len(applySchemaOptions.SQL) != 0 {
153-
return errors.New("Exactly one of --sql and --sql-file must be specified, not both.") // nolint
153+
return errors.New("Exactly one of --sql and --sql-file must be specified, not both.")
154154
}
155155

156156
data, err := os.ReadFile(applySchemaOptions.SQLFile)

go/cmd/vtctldclient/command/shards.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ func commandSourceShardAdd(cmd *cobra.Command, args []string) error {
547547

548548
uid, err := strconv.ParseInt(cmd.Flags().Arg(1), 10, 32)
549549
if err != nil {
550-
return fmt.Errorf("Failed to parse SourceShard uid: %w", err) // nolint
550+
return fmt.Errorf("Failed to parse SourceShard uid: %w", err)
551551
}
552552

553553
sks, sshard, err := topoproto.ParseKeyspaceShard(cmd.Flags().Arg(2))
@@ -601,7 +601,7 @@ func commandSourceShardDelete(cmd *cobra.Command, args []string) error {
601601

602602
uid, err := strconv.ParseInt(cmd.Flags().Arg(1), 10, 32)
603603
if err != nil {
604-
return fmt.Errorf("Failed to parse SourceShard uid: %w", err) // nolint
604+
return fmt.Errorf("Failed to parse SourceShard uid: %w", err)
605605
}
606606

607607
cli.FinishedParsing(cmd)

go/mysql/collations/tools/makecolldata/contractions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func printContraction1(g *codegen.Generator, wa *weightarray, incont []uca.Contr
6161
trie[r] = append(trie[r], cont)
6262
}
6363
if depth == len(cont.Path) {
64-
leaf = &cont // nolint:exportloopref
64+
leaf = &cont
6565
}
6666
}
6767

go/mysql/replication.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ func (c *Conn) WriteComBinlogDumpGTID(serverID uint32, binlogFilename string, bi
9393
4 + // data-size
9494
len(sidBlock) // data
9595
data, pos := c.startEphemeralPacketWithHeader(length)
96-
pos = writeByte(data, pos, ComBinlogDumpGTID) // nolint
97-
pos = writeUint16(data, pos, flags) // nolint
98-
pos = writeUint32(data, pos, serverID) // nolint
99-
pos = writeUint32(data, pos, uint32(len(binlogFilename))) // nolint
100-
pos = writeEOFString(data, pos, binlogFilename) // nolint
101-
pos = writeUint64(data, pos, binlogPos) // nolint
102-
pos = writeUint32(data, pos, uint32(len(sidBlock))) // nolint
103-
pos += copy(data[pos:], sidBlock) // nolint
96+
pos = writeByte(data, pos, ComBinlogDumpGTID)
97+
pos = writeUint16(data, pos, flags)
98+
pos = writeUint32(data, pos, serverID)
99+
pos = writeUint32(data, pos, uint32(len(binlogFilename)))
100+
pos = writeEOFString(data, pos, binlogFilename)
101+
pos = writeUint64(data, pos, binlogPos)
102+
pos = writeUint32(data, pos, uint32(len(sidBlock)))
103+
pos += copy(data[pos:], sidBlock) //nolint
104104
if err := c.writeEphemeralPacket(); err != nil {
105105
return sqlerror.NewSQLErrorf(sqlerror.CRServerGone, sqlerror.SSUnknownSQLState, "%v", err)
106106
}

go/mysql/sqlerror/sql_error.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,14 @@ func convertToMysqlError(err error) error {
367367
if !ok {
368368
return err
369369
}
370-
return NewSQLError(mysqlCode.num, mysqlCode.state, err.Error()) //nolint:govet
370+
return NewSQLError(mysqlCode.num, mysqlCode.state, err.Error())
371371
}
372372

373373
var isGRPCOverflowRE = regexp.MustCompile(`.*?grpc: (received|trying to send) message larger than max \(\d+ vs. \d+\)`)
374374

375375
func demuxResourceExhaustedErrors(msg string) ErrorCode {
376376
switch {
377-
case isGRPCOverflowRE.Match([]byte(msg)):
377+
case isGRPCOverflowRE.MatchString(msg):
378378
return ERNetPacketTooLarge
379379
case strings.Contains(msg, "Transaction throttled"):
380380
return EROutOfResources

go/sqltypes/value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ func encodeBinarySQLBytes2(val []byte, buf *bytes2.Buffer) {
831831
}
832832

833833
func encodeBinarySQLStringBuilder(val []byte, buf *strings.Builder) {
834-
buf.Write([]byte("_binary"))
834+
buf.WriteString("_binary")
835835
encodeBytesSQLStringBuilder(val, buf)
836836
}
837837

0 commit comments

Comments
 (0)