Skip to content

Commit

Permalink
linter: enable revive for session (#43420)
Browse files Browse the repository at this point in the history
ref #40786
  • Loading branch information
hawkingrei authored Apr 26, 2023
1 parent a64b149 commit 7c5e7ea
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions build/nogo_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@
"dumpling/export": "dumpling/export code",
"lock/": "lock file",
"errno/": "errno code",
"session/": "session code",
"structure/": "structure code",
"telemetry/": "telemetry code",
"parser/": "parser code",
Expand Down
2 changes: 1 addition & 1 deletion session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@ func upgradeToVer136(s Session, ver int64) {
doReentrantDDL(s, fmt.Sprintf("ALTER TABLE mysql.%s ADD INDEX idx_task_key(task_key)", ddl.BackgroundSubtaskTable), dbterror.ErrDupKeyName)
}

func upgradeToVer137(s Session, ver int64) {
func upgradeToVer137(_ Session, _ int64) {
// NOOP, we don't depend on ddl to init the default group due to backward compatible issue.
}

Expand Down
17 changes: 9 additions & 8 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ func (c *cachedTableRenewLease) start(ctx context.Context) error {
return err
}

func (c *cachedTableRenewLease) stop(ctx context.Context) {
func (c *cachedTableRenewLease) stop(_ context.Context) {
close(c.exit)
}

Expand Down Expand Up @@ -1152,7 +1152,7 @@ func (s *session) isInternal() bool {
return s.sessionVars.InRestrictedSQL
}

func (s *session) isTxnRetryableError(err error) bool {
func (*session) isTxnRetryableError(err error) bool {
if atomic.LoadUint32(&SchemaChangedWithoutRetry) == 1 {
return kv.IsTxnRetryableError(err)
}
Expand Down Expand Up @@ -2395,7 +2395,7 @@ func runStmt(ctx context.Context, se *session, s sqlexec.Statement) (rs sqlexec.
type ExecStmtVarKeyType int

// String defines a Stringer function for debugging and pretty printing.
func (k ExecStmtVarKeyType) String() string {
func (ExecStmtVarKeyType) String() string {
return "exec_stmt_var_key"
}

Expand Down Expand Up @@ -2977,7 +2977,7 @@ func (s *session) AuthWithoutVerification(user *auth.UserIdentity) bool {
}

// RefreshVars implements the sessionctx.Context interface.
func (s *session) RefreshVars(ctx context.Context) error {
func (s *session) RefreshVars(_ context.Context) error {
pruneMode, err := s.GetSessionVars().GlobalVarsAccessor.GetGlobalSysVar(variable.TiDBPartitionPruneMode)
if err != nil {
return err
Expand Down Expand Up @@ -3800,8 +3800,7 @@ func (s *session) ShowProcess() *util.ProcessInfo {
}

// GetStartTSFromSession returns the startTS in the session `se`
func GetStartTSFromSession(se interface{}) (uint64, uint64) {
var startTS, processInfoID uint64
func GetStartTSFromSession(se interface{}) (startTS, processInfoID uint64) {
tmp, ok := se.(*session)
if !ok {
logutil.BgLogger().Error("GetStartTSFromSession failed, can't transform to session struct")
Expand Down Expand Up @@ -4174,7 +4173,8 @@ func (s *session) SetMemoryFootprintChangeHook() {
}

// EncodeSessionStates implements SessionStatesHandler.EncodeSessionStates interface.
func (s *session) EncodeSessionStates(ctx context.Context, sctx sessionctx.Context, sessionStates *sessionstates.SessionStates) error {
func (s *session) EncodeSessionStates(ctx context.Context,
_ sessionctx.Context, sessionStates *sessionstates.SessionStates) error {
// Transaction status is hard to encode, so we do not support it.
s.txn.mu.Lock()
valid := s.txn.Valid()
Expand Down Expand Up @@ -4242,7 +4242,8 @@ func (s *session) EncodeSessionStates(ctx context.Context, sctx sessionctx.Conte
}

// DecodeSessionStates implements SessionStatesHandler.DecodeSessionStates interface.
func (s *session) DecodeSessionStates(ctx context.Context, sctx sessionctx.Context, sessionStates *sessionstates.SessionStates) error {
func (s *session) DecodeSessionStates(ctx context.Context,
_ sessionctx.Context, sessionStates *sessionstates.SessionStates) error {
// Decode prepared statements and sql bindings.
for _, handler := range s.sessionStatesHandlers {
if err := handler.DecodeSessionStates(ctx, s, sessionStates); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion session/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func GetHistory(ctx sessionctx.Context) *StmtHistory {
}

// GetRows4Test gets all the rows from a RecordSet, only used for test.
func GetRows4Test(ctx context.Context, sctx sessionctx.Context, rs sqlexec.RecordSet) ([]chunk.Row, error) {
func GetRows4Test(ctx context.Context, _ sessionctx.Context, rs sqlexec.RecordSet) ([]chunk.Row, error) {
if rs == nil {
return nil, nil
}
Expand Down
3 changes: 1 addition & 2 deletions session/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ func (txn *LazyTxn) GoString() string {
// GetOption implements the GetOption
func (txn *LazyTxn) GetOption(opt int) interface{} {
if txn.Transaction == nil {
switch opt {
case kv.TxnScope:
if opt == kv.TxnScope {
return ""
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion session/txninfo/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ func (recorder *TrxHistoryRecorder) ResizeSummaries(capacity uint) {
}

// Recorder is the recorder instance.
var Recorder TrxHistoryRecorder = newTrxHistoryRecorder(0)
var Recorder = newTrxHistoryRecorder(0)

0 comments on commit 7c5e7ea

Please sign in to comment.