Commit 756da8a1 by Oleg Gaidarenko Committed by GitHub

Fix: tighten revive exit code & make it happy (#17127)

* Revive should fail the build

* Fix the associated errors
parent 0a9863a8
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
// WithTransactionalDbSession calls the callback with an session within a transaction // WithTransactionalDbSession calls the callback with an session within a transaction
func (ss *SqlStore) WithTransactionalDbSession(ctx context.Context, callback dbTransactionFunc) error { func (ss *SqlStore) WithTransactionalDbSession(ctx context.Context, callback dbTransactionFunc) error {
return inTransactionWithRetryCtx(ss.engine, ctx, callback, 0) return inTransactionWithRetryCtx(ctx, ss.engine, callback, 0)
} }
func (ss *SqlStore) InTransaction(ctx context.Context, fn func(ctx context.Context) error) error { func (ss *SqlStore) InTransaction(ctx context.Context, fn func(ctx context.Context) error) error {
...@@ -20,17 +20,17 @@ func (ss *SqlStore) InTransaction(ctx context.Context, fn func(ctx context.Conte ...@@ -20,17 +20,17 @@ func (ss *SqlStore) InTransaction(ctx context.Context, fn func(ctx context.Conte
} }
func (ss *SqlStore) inTransactionWithRetry(ctx context.Context, fn func(ctx context.Context) error, retry int) error { func (ss *SqlStore) inTransactionWithRetry(ctx context.Context, fn func(ctx context.Context) error, retry int) error {
return inTransactionWithRetryCtx(ss.engine, ctx, func(sess *DBSession) error { return inTransactionWithRetryCtx(ctx, ss.engine, func(sess *DBSession) error {
withValue := context.WithValue(ctx, ContextSessionName, sess) withValue := context.WithValue(ctx, ContextSessionName, sess)
return fn(withValue) return fn(withValue)
}, retry) }, retry)
} }
func inTransactionWithRetry(callback dbTransactionFunc, retry int) error { func inTransactionWithRetry(callback dbTransactionFunc, retry int) error {
return inTransactionWithRetryCtx(x, context.Background(), callback, retry) return inTransactionWithRetryCtx(context.Background(), x, callback, retry)
} }
func inTransactionWithRetryCtx(engine *xorm.Engine, ctx context.Context, callback dbTransactionFunc, retry int) error { func inTransactionWithRetryCtx(ctx context.Context, engine *xorm.Engine, callback dbTransactionFunc, retry int) error {
sess, err := startSession(ctx, engine, true) sess, err := startSession(ctx, engine, true)
if err != nil { if err != nil {
return err return err
...@@ -73,5 +73,5 @@ func inTransaction(callback dbTransactionFunc) error { ...@@ -73,5 +73,5 @@ func inTransaction(callback dbTransactionFunc) error {
} }
func inTransactionCtx(ctx context.Context, callback dbTransactionFunc) error { func inTransactionCtx(ctx context.Context, callback dbTransactionFunc) error {
return inTransactionWithRetryCtx(x, ctx, callback, 0) return inTransactionWithRetryCtx(ctx, x, callback, 0)
} }
ignoreGeneratedHeader = false ignoreGeneratedHeader = false
severity = "error" severity = "error"
confidence = 0.8 confidence = 0.8
errorCode = 0 errorCode = 1
[rule.context-as-argument] [rule.context-as-argument]
[rule.error-return] [rule.error-return]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment