Skip to content

Commit

Permalink
lint: update config of deprecated linter (#40763)
Browse files Browse the repository at this point in the history
ref #40786
  • Loading branch information
hawkingrei authored Jan 28, 2023
1 parent 1e0956d commit 76153ab
Show file tree
Hide file tree
Showing 39 changed files with 74 additions and 40 deletions.
2 changes: 1 addition & 1 deletion br/pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func BuildBackupRangeAndSchema(
continue
}

logger := log.With(
logger := log.L().With(
zap.String("db", dbInfo.Name.O),
zap.String("table", tableInfo.Name.O),
)
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/backup/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (ss *Schemas) BackupSchemas(
}
workerPool.ApplyOnErrorGroup(errg, func() error {
if schema.tableInfo != nil {
logger := log.With(
logger := log.L().With(
zap.String("db", schema.dbInfo.Name.O),
zap.String("table", schema.tableInfo.Name.O),
)
Expand Down
1 change: 1 addition & 0 deletions br/pkg/lightning/backend/local/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ go_library(
"@org_golang_google_grpc//backoff",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//credentials",
"@org_golang_google_grpc//credentials/insecure",
"@org_golang_google_grpc//keepalive",
"@org_golang_google_grpc//status",
"@org_golang_x_exp//slices",
Expand Down
3 changes: 2 additions & 1 deletion br/pkg/lightning/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import (
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/status"
)
Expand Down Expand Up @@ -148,7 +149,7 @@ func (f *importClientFactoryImpl) makeConn(ctx context.Context, storeID uint64)
if err != nil {
return nil, errors.Trace(err)
}
opt := grpc.WithInsecure()
opt := grpc.WithTransportCredentials(insecure.NewCredentials())
if f.tls.TLSConfig() != nil {
opt = grpc.WithTransportCredentials(credentials.NewTLS(f.tls.TLSConfig()))
}
Expand Down
1 change: 1 addition & 0 deletions br/pkg/lightning/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ go_library(
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//credentials",
"@org_golang_google_grpc//credentials/insecure",
"@org_golang_google_grpc//status",
"@org_golang_x_sys//unix",
"@org_uber_go_zap//:zap",
Expand Down
3 changes: 2 additions & 1 deletion br/pkg/lightning/common/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
pd "github.com/tikv/pd/client"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

type TLS struct {
Expand Down Expand Up @@ -104,7 +105,7 @@ func (tc *TLS) ToGRPCDialOption() grpc.DialOption {
if tc.inner != nil {
return grpc.WithTransportCredentials(credentials.NewTLS(tc.inner))
}
return grpc.WithInsecure()
return grpc.WithTransportCredentials(insecure.NewCredentials())
}

// WrapListener places a TLS layer on top of the existing listener.
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/logutil/rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ func (r *RateTracer) RateAt(instant time.Time) float64 {

// L make a logger with the current speed.
func (r *RateTracer) L() *zap.Logger {
return log.With(zap.String("speed", fmt.Sprintf("%.2f ops/s", r.Rate())))
return log.L().With(zap.String("speed", fmt.Sprintf("%.2f ops/s", r.Rate())))
}
1 change: 1 addition & 0 deletions br/pkg/restore/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ go_library(
"@org_golang_google_grpc//backoff",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//credentials",
"@org_golang_google_grpc//credentials/insecure",
"@org_golang_google_grpc//keepalive",
"@org_golang_google_grpc//status",
"@org_golang_x_exp//slices",
Expand Down
5 changes: 3 additions & 2 deletions br/pkg/restore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
)

Expand Down Expand Up @@ -1298,7 +1299,7 @@ func (rc *Client) switchTiKVMode(ctx context.Context, mode import_sstpb.SwitchMo
finalStore := store
rc.workerPool.ApplyOnErrorGroup(eg,
func() error {
opt := grpc.WithInsecure()
opt := grpc.WithTransportCredentials(insecure.NewCredentials())
if rc.tlsConf != nil {
opt = grpc.WithTransportCredentials(credentials.NewTLS(rc.tlsConf))
}
Expand Down Expand Up @@ -1410,7 +1411,7 @@ func (rc *Client) execChecksum(
concurrency uint,
loadStatCh chan<- *CreatedTable,
) error {
logger := log.With(
logger := log.L().With(
zap.String("db", tbl.OldTable.DB.Name.O),
zap.String("table", tbl.OldTable.Info.Name.O),
)
Expand Down
3 changes: 2 additions & 1 deletion br/pkg/restore/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/status"
)
Expand Down Expand Up @@ -197,7 +198,7 @@ func (ic *importClient) GetImportClient(
if err != nil {
return nil, errors.Trace(err)
}
opt := grpc.WithInsecure()
opt := grpc.WithTransportCredentials(insecure.NewCredentials())
if ic.tlsConf != nil {
opt = grpc.WithTransportCredentials(credentials.NewTLS(ic.tlsConf))
}
Expand Down
1 change: 1 addition & 0 deletions br/pkg/restore/split/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ go_library(
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//credentials",
"@org_golang_google_grpc//credentials/insecure",
"@org_golang_google_grpc//status",
"@org_uber_go_multierr//:multierr",
"@org_uber_go_zap//:zap",
Expand Down
5 changes: 3 additions & 2 deletions br/pkg/restore/split/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"
)

Expand Down Expand Up @@ -200,7 +201,7 @@ func (c *pdClient) SplitRegion(ctx context.Context, regionInfo *RegionInfo, key
if err != nil {
return nil, errors.Trace(err)
}
conn, err := grpc.Dial(store.GetAddress(), grpc.WithInsecure())
conn, err := grpc.Dial(store.GetAddress(), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, errors.Trace(err)
}
Expand Down Expand Up @@ -336,7 +337,7 @@ func sendSplitRegionRequest(ctx context.Context, c *pdClient, regionInfo *Region
if err != nil {
return false, nil, err
}
opt := grpc.WithInsecure()
opt := grpc.WithTransportCredentials(insecure.NewCredentials())
if c.tlsConf != nil {
opt = grpc.WithTransportCredentials(credentials.NewTLS(c.tlsConf))
}
Expand Down
1 change: 1 addition & 0 deletions br/pkg/utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ go_library(
"@org_golang_google_grpc//backoff",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//credentials",
"@org_golang_google_grpc//credentials/insecure",
"@org_golang_google_grpc//keepalive",
"@org_golang_google_grpc//status",
"@org_golang_x_net//http/httpproxy",
Expand Down
3 changes: 2 additions & 1 deletion br/pkg/utils/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/pingcap/tidb/parser/types"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

// IsTypeCompatible checks whether type target is compatible with type src
Expand Down Expand Up @@ -84,7 +85,7 @@ func IsTypeCompatible(src types.FieldType, target types.FieldType) bool {
}

func GRPCConn(ctx context.Context, storeAddr string, tlsConf *tls.Config, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
secureOpt := grpc.WithInsecure()
secureOpt := grpc.WithTransportCredentials(insecure.NewCredentials())
if tlsConf != nil {
secureOpt = grpc.WithTransportCredentials(credentials.NewTLS(tlsConf))
}
Expand Down
3 changes: 2 additions & 1 deletion br/pkg/utils/store_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
)

Expand Down Expand Up @@ -136,7 +137,7 @@ func (mgr *StoreManager) getGrpcConnLocked(ctx context.Context, storeID uint64)
if err != nil {
return nil, errors.Trace(err)
}
opt := grpc.WithInsecure()
opt := grpc.WithTransportCredentials(insecure.NewCredentials())
if mgr.tlsConf != nil {
opt = grpc.WithTransportCredentials(credentials.NewTLS(mgr.tlsConf))
}
Expand Down
19 changes: 10 additions & 9 deletions build/nogo_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -750,26 +750,27 @@
"/build/": "no need to linter code",
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code",
".*_test\\.go$": "ignore test code"
".*_test\\.go$": "ignore test code",
"br/pkg/restore/split/client.go": "github.com/golang/protobuf deprecated",
"br/pkg/streamhelper/advancer_cliext.go": "github.com/golang/protobuf deprecated",
"br/pkg/lightning/checkpoints/checkpoints.go": "cfg.TikvImporter.Addr is deprecated",
"br/pkg/lightning/checkpoints/glue_checkpoint.go": "cfg.TikvImporter.Addr is deprecated"
},
"only_files": {
"util/gctuner": "util/gctuner",
"util/cgroup": "util/cgroup code",
"util/watcher": "util/watcher",
"br/pkg/lightning/restore/": "br/pkg/lightning/restore/",
"br/pkg/lightning/mydump/": "br/pkg/lightning/mydump/",
"br/pkg/": "br/pkg",
"executor/aggregate.go": "executor/aggregate.go",
"types/json_binary_functions.go": "types/json_binary_functions.go",
"types/json_binary_test.go": "types/json_binary_test.go",
"types/": "types",
"ddl/": "enable to ddl",
"expression/builtin_cast.go": "enable expression/builtin_cast.go",
"planner/core/plan.go": "planner/core/plan.go",
"server/conn.go": "server/conn.go",
"server/conn_stmt.go": "server/conn_stmt.go",
"server/conn_test.go": "server/conn_test.go",
"extension/": "extension code",
"resourcemanager/": "resourcemanager code",
"keyspace/": "keyspace code"
"keyspace/": "keyspace code",
"server/": "server code",
"meta": "meta code"
}
},
"SA2000": {
Expand Down
1 change: 1 addition & 0 deletions executor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ go_library(
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//credentials",
"@org_golang_google_grpc//credentials/insecure",
"@org_golang_google_grpc//status",
"@org_golang_x_exp//slices",
"@org_golang_x_sync//errgroup",
Expand Down
4 changes: 2 additions & 2 deletions executor/load_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (k loadStatsVarKeyType) String() string {
const LoadStatsVarKey loadStatsVarKeyType = 0

// Next implements the Executor Next interface.
func (e *LoadStatsExec) Next(ctx context.Context, req *chunk.Chunk) error {
func (e *LoadStatsExec) Next(_ context.Context, req *chunk.Chunk) error {
req.GrowAndReset(e.maxChunkSize)
if len(e.info.Path) == 0 {
return errors.New("Load Stats: file path is empty")
Expand All @@ -72,7 +72,7 @@ func (e *LoadStatsExec) Close() error {
}

// Open implements the Executor Open interface.
func (e *LoadStatsExec) Open(ctx context.Context) error {
func (e *LoadStatsExec) Open(_ context.Context) error {
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions executor/lock_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (k lockStatsVarKeyType) String() string {
const LockStatsVarKey lockStatsVarKeyType = 0

// Next implements the Executor Next interface.
func (e *LockStatsExec) Next(ctx context.Context, req *chunk.Chunk) error {
func (e *LockStatsExec) Next(_ context.Context, _ *chunk.Chunk) error {
do := domain.GetDomain(e.ctx)
is := do.InfoSchema()
h := do.StatsHandle()
Expand Down Expand Up @@ -87,7 +87,7 @@ func (e *LockStatsExec) Close() error {
}

// Open implements the Executor Open interface.
func (e *LockStatsExec) Open(ctx context.Context) error {
func (e *LockStatsExec) Open(_ context.Context) error {
return nil
}

Expand All @@ -109,7 +109,7 @@ func (k unlockStatsVarKeyType) String() string {
const UnlockStatsVarKey unlockStatsVarKeyType = 0

// Next implements the Executor Next interface.
func (e *UnlockStatsExec) Next(ctx context.Context, req *chunk.Chunk) error {
func (e *UnlockStatsExec) Next(_ context.Context, _ *chunk.Chunk) error {
do := domain.GetDomain(e.ctx)
is := do.InfoSchema()
h := do.StatsHandle()
Expand Down Expand Up @@ -152,6 +152,6 @@ func (e *UnlockStatsExec) Close() error {
}

// Open implements the Executor Open interface.
func (e *UnlockStatsExec) Open(ctx context.Context) error {
func (e *UnlockStatsExec) Open(_ context.Context) error {
return nil
}
3 changes: 2 additions & 1 deletion executor/memtable_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"golang.org/x/exp/slices"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

const clusterLogBatchSize = 256
Expand Down Expand Up @@ -431,7 +432,7 @@ func (e *clusterLogRetriever) startRetrieving(
serversInfo []infoschema.ServerInfo,
req *diagnosticspb.SearchLogRequest) ([]chan logStreamResult, error) {
// gRPC options
opt := grpc.WithInsecure()
opt := grpc.WithTransportCredentials(insecure.NewCredentials())
security := config.GetGlobalConfig().Security
if len(security.ClusterSSLCA) != 0 {
clusterSecurity := security.ClusterSecurity()
Expand Down
1 change: 1 addition & 0 deletions infoschema/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ go_library(
"@com_github_tikv_client_go_v2//tikv",
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//credentials",
"@org_golang_google_grpc//credentials/insecure",
"@org_golang_x_exp//slices",
"@org_uber_go_zap//:zap",
],
Expand Down
3 changes: 2 additions & 1 deletion infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (
"golang.org/x/exp/slices"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

const (
Expand Down Expand Up @@ -2333,7 +2334,7 @@ func serverInfoItemToRows(items []*diagnosticspb.ServerInfoItem, tp, addr string
}

func getServerInfoByGRPC(ctx context.Context, address string, tp diagnosticspb.ServerInfoType) ([]*diagnosticspb.ServerInfoItem, error) {
opt := grpc.WithInsecure()
opt := grpc.WithTransportCredentials(insecure.NewCredentials())
security := config.GetGlobalConfig().Security
if len(security.ClusterSSLCA) != 0 {
clusterSecurity := security.ClusterSecurity()
Expand Down
1 change: 1 addition & 0 deletions meta/autoid/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ go_library(
"@io_etcd_go_etcd_client_v3//:client",
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//credentials",
"@org_golang_google_grpc//credentials/insecure",
"@org_uber_go_zap//:zap",
],
)
Expand Down
3 changes: 2 additions & 1 deletion meta/autoid/autoid_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

var _ Allocator = &singlePointAlloc{}
Expand Down Expand Up @@ -83,7 +84,7 @@ func (d *clientDiscover) GetClient(ctx context.Context) (autoid.AutoIDAllocClien
}

addr := string(resp.Kvs[0].Value)
opt := grpc.WithInsecure()
opt := grpc.WithTransportCredentials(insecure.NewCredentials())
security := config.GetGlobalConfig().Security
if len(security.ClusterSSLCA) != 0 {
clusterSecurity := security.ClusterSecurity()
Expand Down
2 changes: 1 addition & 1 deletion server/plan_replayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func loadSQLMetaFile(z *zip.Reader) (uint64, error) {
}
//nolint: errcheck,all_revive
defer v.Close()
_, err = toml.DecodeReader(v, &varMap)
_, err = toml.NewDecoder(v).Decode(&varMap)
if err != nil {
return 0, errors.AddStack(err)
}
Expand Down
1 change: 1 addition & 0 deletions sessionctx/binloginfo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ go_test(
"@com_github_pingcap_tipb//go-binlog",
"@com_github_stretchr_testify//require",
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//credentials/insecure",
"@org_uber_go_goleak//:goleak",
],
)
Loading

0 comments on commit 76153ab

Please sign in to comment.