From 756da8a1348254f81ecaed9d956f1c729ec05912 Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Fri, 17 May 2019 08:35:37 +0300 Subject: [PATCH] Fix: tighten revive exit code & make it happy (#17127) * Revive should fail the build * Fix the associated errors --- pkg/services/sqlstore/transactions.go | 10 +++++----- scripts/go/configs/revive.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/services/sqlstore/transactions.go b/pkg/services/sqlstore/transactions.go index 0ecb0938d4f..a0f64804339 100644 --- a/pkg/services/sqlstore/transactions.go +++ b/pkg/services/sqlstore/transactions.go @@ -12,7 +12,7 @@ import ( // WithTransactionalDbSession calls the callback with an session within a transaction 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 { @@ -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 { - return inTransactionWithRetryCtx(ss.engine, ctx, func(sess *DBSession) error { + return inTransactionWithRetryCtx(ctx, ss.engine, func(sess *DBSession) error { withValue := context.WithValue(ctx, ContextSessionName, sess) return fn(withValue) }, retry) } 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) if err != nil { return err @@ -73,5 +73,5 @@ func inTransaction(callback dbTransactionFunc) error { } func inTransactionCtx(ctx context.Context, callback dbTransactionFunc) error { - return inTransactionWithRetryCtx(x, ctx, callback, 0) + return inTransactionWithRetryCtx(ctx, x, callback, 0) } diff --git a/scripts/go/configs/revive.toml b/scripts/go/configs/revive.toml index 2d4410ee548..a40486c3133 100644 --- a/scripts/go/configs/revive.toml +++ b/scripts/go/configs/revive.toml @@ -1,7 +1,7 @@ ignoreGeneratedHeader = false severity = "error" confidence = 0.8 -errorCode = 0 +errorCode = 1 [rule.context-as-argument] [rule.error-return]