diff --git a/begin.go b/begin.go index bae05ee..e1eec74 100644 --- a/begin.go +++ b/begin.go @@ -16,8 +16,8 @@ type beginFuncMiddleware func(next beginFunc) beginFunc // beginFunc is a callback for beginFunc. type beginFunc func(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) -// noOpBegin pings nothing. -func noOpBegin(_ context.Context, _ driver.TxOptions) (driver.Tx, error) { +// nopBegin pings nothing. +func nopBegin(_ context.Context, _ driver.TxOptions) (driver.Tx, error) { return nil, nil } diff --git a/begin_internal_test.go b/begin_internal_test.go index 27f4795..a503848 100644 --- a/begin_internal_test.go +++ b/begin_internal_test.go @@ -30,17 +30,17 @@ func BenchmarkBeginStats(b *testing.B) { begin := chainBeginFuncMiddlewares([]beginFuncMiddleware{ beginStats(r), - }, noOpBegin) + }, nopBegin) for i := 0; i < b.N; i++ { _, _ = begin(context.Background(), driver.TxOptions{}) // nolint: errcheck } } -func TestNoOpBegin(t *testing.T) { +func TestNopBegin(t *testing.T) { t.Parallel() - result, err := noOpBegin(context.Background(), driver.TxOptions{}) + result, err := nopBegin(context.Background(), driver.TxOptions{}) assert.Nil(t, result) assert.NoError(t, err) @@ -84,7 +84,7 @@ func TestEnsureBegin(t *testing.T) { func TestChainBeginFuncMiddlewares_NoMiddleware(t *testing.T) { t.Parallel() - begin := chainBeginFuncMiddlewares(nil, noOpBegin) + begin := chainBeginFuncMiddlewares(nil, nopBegin) result, err := begin(context.Background(), driver.TxOptions{}) @@ -158,7 +158,7 @@ func TestBeginStats(t *testing.T) { }, { scenario: "no error", - begin: noOpBegin, + begin: nopBegin, expected: `[ { "Name": "db.sql.client.calls{service.name=otelsql,instrumentation.name=begin_test,db.instance=test,db.operation=go.sql.begin,db.sql.status=OK,db.system=other_sql}", diff --git a/conn.go b/conn.go index 21efe15..ae72310 100644 --- a/conn.go +++ b/conn.go @@ -102,7 +102,7 @@ func wrapConn(parent driver.Conn, opt connConfig) driver.Conn { func makeConn(parent driver.Conn, cfg connConfig) conn { c := conn{ - ping: noOpPing, + ping: nopPing, exec: skippedExecContext, query: skippedQueryContext, close: parent.Close, diff --git a/exec.go b/exec.go index f68aaaa..9ed76f6 100644 --- a/exec.go +++ b/exec.go @@ -14,8 +14,8 @@ type execContextFuncMiddleware func(next execContextFunc) execContextFunc type execContextFunc func(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) -// noOpExecContext executes nothing. -func noOpExecContext(_ context.Context, _ string, _ []driver.NamedValue) (driver.Result, error) { +// nopExecContext executes nothing. +func nopExecContext(_ context.Context, _ string, _ []driver.NamedValue) (driver.Result, error) { return nil, nil } diff --git a/exec_internal_test.go b/exec_internal_test.go index eb52528..0df1f29 100644 --- a/exec_internal_test.go +++ b/exec_internal_test.go @@ -30,17 +30,17 @@ func BenchmarkExecStats(b *testing.B) { exec := chainExecContextFuncMiddlewares([]execContextFuncMiddleware{ execStats(r, metricMethodExec), - }, noOpExecContext) + }, nopExecContext) for i := 0; i < b.N; i++ { _, _ = exec(context.Background(), "", nil) // nolint: errcheck } } -func TestNoOpExecContext(t *testing.T) { +func TestNopExecContext(t *testing.T) { t.Parallel() - result, err := noOpExecContext(context.Background(), "", nil) + result, err := nopExecContext(context.Background(), "", nil) assert.Nil(t, result) assert.NoError(t, err) @@ -58,7 +58,7 @@ func TestSkippedExecContext(t *testing.T) { func TestChainExecContextFuncMiddlewares_NoMiddleware(t *testing.T) { t.Parallel() - exec := chainExecContextFuncMiddlewares(nil, noOpExecContext) + exec := chainExecContextFuncMiddlewares(nil, nopExecContext) result, err := exec(context.Background(), "", nil) @@ -132,7 +132,7 @@ func TestExecStats(t *testing.T) { }, { scenario: "no error", - execer: noOpExecContext, + execer: nopExecContext, expected: `[ { "Name": "db.sql.client.calls{service.name=otelsql,instrumentation.name=exec_test,db.instance=test,db.operation=go.sql.exec,db.sql.status=OK,db.system=other_sql}", diff --git a/internal/test/assert/assert.go b/internal/test/assert/assert.go index 0e50c11..d38eb06 100644 --- a/internal/test/assert/assert.go +++ b/internal/test/assert/assert.go @@ -22,8 +22,8 @@ func EqualJSON(expect string) Func { } } -// NoOp creates a new Func that does not assert anything. -func NoOp() Func { +// Nop creates a new Func that does not assert anything. +func Nop() Func { return func(_ assert.TestingT, _ string, _ ...interface{}) bool { return true } diff --git a/ping.go b/ping.go index 2bcc917..a718860 100644 --- a/ping.go +++ b/ping.go @@ -15,8 +15,8 @@ type pingFuncMiddleware func(next pingFunc) pingFunc // pingFunc is a callback for pingFunc. type pingFunc func(ctx context.Context) error -// noOpPing pings nothing. -func noOpPing(_ context.Context) error { +// nopPing pings nothing. +func nopPing(_ context.Context) error { return nil } diff --git a/ping_internal_test.go b/ping_internal_test.go index 1d61467..55d6a71 100644 --- a/ping_internal_test.go +++ b/ping_internal_test.go @@ -29,17 +29,17 @@ func BenchmarkPingStats(b *testing.B) { ping := chainPingFuncMiddlewares([]pingFuncMiddleware{ pingStats(r), - }, noOpPing) + }, nopPing) for i := 0; i < b.N; i++ { _ = ping(context.Background()) // nolint: errcheck } } -func TestNoOpPing(t *testing.T) { +func TestNopPing(t *testing.T) { t.Parallel() - err := noOpPing(context.Background()) + err := nopPing(context.Background()) assert.NoError(t, err) } @@ -47,7 +47,7 @@ func TestNoOpPing(t *testing.T) { func TestChainPingFuncMiddlewares_NoMiddleware(t *testing.T) { t.Parallel() - f := chainPingFuncMiddlewares(nil, noOpPing) + f := chainPingFuncMiddlewares(nil, nopPing) err := f(context.Background()) @@ -119,7 +119,7 @@ func TestPingStats(t *testing.T) { }, { scenario: "no error", - ping: noOpPing, + ping: nopPing, expected: `[ { "Name": "db.sql.client.calls{service.name=otelsql,instrumentation.name=ping_test,db.instance=test,db.operation=go.sql.ping,db.sql.status=OK,db.system=other_sql}", diff --git a/prepare.go b/prepare.go index 216d4b1..893f99d 100644 --- a/prepare.go +++ b/prepare.go @@ -14,8 +14,8 @@ type prepareContextFuncMiddleware func(next prepareContextFunc) prepareContextFu type prepareContextFunc func(ctx context.Context, query string) (driver.Stmt, error) -// noOpPrepareContext prepares nothing. -func noOpPrepareContext(_ context.Context, _ string) (driver.Stmt, error) { +// nopPrepareContext prepares nothing. +func nopPrepareContext(_ context.Context, _ string) (driver.Stmt, error) { return nil, nil } diff --git a/prepare_internal_test.go b/prepare_internal_test.go index a552da3..e3aec55 100644 --- a/prepare_internal_test.go +++ b/prepare_internal_test.go @@ -30,17 +30,17 @@ func BenchmarkPrepareStats(b *testing.B) { prepare := chainPrepareContextFuncMiddlewares([]prepareContextFuncMiddleware{ prepareStats(r), - }, noOpPrepareContext) + }, nopPrepareContext) for i := 0; i < b.N; i++ { _, _ = prepare(context.Background(), "") // nolint: errcheck } } -func TestNoOpPrepareContext(t *testing.T) { +func TestNopPrepareContext(t *testing.T) { t.Parallel() - result, err := noOpPrepareContext(context.Background(), "") + result, err := nopPrepareContext(context.Background(), "") assert.Nil(t, result) assert.NoError(t, err) @@ -84,7 +84,7 @@ func TestEnsurePrepareContext(t *testing.T) { func TestChainPrepareContextFuncMiddlewares_NoMiddleware(t *testing.T) { t.Parallel() - prepare := chainPrepareContextFuncMiddlewares(nil, noOpPrepareContext) + prepare := chainPrepareContextFuncMiddlewares(nil, nopPrepareContext) result, err := prepare(context.Background(), "") @@ -158,7 +158,7 @@ func TestPrepareStats(t *testing.T) { }, { scenario: "no error", - prepare: noOpPrepareContext, + prepare: nopPrepareContext, expected: `[ { "Name": "db.sql.client.calls{service.name=otelsql,instrumentation.name=prepare_test,db.instance=test,db.operation=go.sql.prepare,db.sql.status=OK,db.system=other_sql}", diff --git a/query.go b/query.go index 92b6f72..22b8b12 100644 --- a/query.go +++ b/query.go @@ -14,8 +14,8 @@ type queryContextFuncMiddleware func(next queryContextFunc) queryContextFunc type queryContextFunc func(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) -// noOpQueryContext queries nothing. -func noOpQueryContext(_ context.Context, _ string, _ []driver.NamedValue) (driver.Rows, error) { +// nopQueryContext queries nothing. +func nopQueryContext(_ context.Context, _ string, _ []driver.NamedValue) (driver.Rows, error) { return nil, nil } diff --git a/query_internal_test.go b/query_internal_test.go index 44452f4..6cddd18 100644 --- a/query_internal_test.go +++ b/query_internal_test.go @@ -30,17 +30,17 @@ func BenchmarkQueryStats(b *testing.B) { query := chainQueryContextFuncMiddlewares([]queryContextFuncMiddleware{ queryStats(r, metricMethodQuery), - }, noOpQueryContext) + }, nopQueryContext) for i := 0; i < b.N; i++ { _, _ = query(context.Background(), "", nil) // nolint: errcheck } } -func TestNoOpQueryContext(t *testing.T) { +func TestNopQueryContext(t *testing.T) { t.Parallel() - result, err := noOpQueryContext(context.Background(), "", nil) + result, err := nopQueryContext(context.Background(), "", nil) assert.Nil(t, result) assert.NoError(t, err) @@ -58,7 +58,7 @@ func TestSkippedQueryContext(t *testing.T) { func TestChainQueryContextFuncMiddlewares_NoMiddleware(t *testing.T) { t.Parallel() - query := chainQueryContextFuncMiddlewares(nil, noOpQueryContext) + query := chainQueryContextFuncMiddlewares(nil, nopQueryContext) result, err := query(context.Background(), "", nil) @@ -132,7 +132,7 @@ func TestQueryStats(t *testing.T) { }, { scenario: "no error", - query: noOpQueryContext, + query: nopQueryContext, expected: `[ { "Name": "db.sql.client.calls{service.name=otelsql,instrumentation.name=query_test,db.instance=test,db.operation=go.sql.query,db.sql.status=OK,db.system=other_sql}", diff --git a/statement.go b/statement.go index 7ee3170..a0aadc7 100644 --- a/statement.go +++ b/statement.go @@ -211,7 +211,7 @@ func makeStmtExecFunc(parent driver.Stmt, execContextFuncMiddlewares []execConte func makeStmtExecContextFunc(parent driver.Stmt, execContextFuncMiddlewares []execContextFuncMiddleware) execContextFunc { execer, ok := parent.(driver.StmtExecContext) if !ok { - return noOpExecContext + return nopExecContext } return chainExecContextFuncMiddlewares(execContextFuncMiddlewares, func(ctx context.Context, _ string, args []driver.NamedValue) (driver.Result, error) { @@ -228,7 +228,7 @@ func makeStmtQueryFunc(parent driver.Stmt, queryContextFuncMiddlewares []queryCo func makeStmtQueryContextFunc(parent driver.Stmt, queryContextFuncMiddlewares []queryContextFuncMiddleware) queryContextFunc { queryer, ok := parent.(driver.StmtQueryContext) if !ok { - return noOpQueryContext + return nopQueryContext } return chainQueryContextFuncMiddlewares(queryContextFuncMiddlewares, func(ctx context.Context, _ string, args []driver.NamedValue) (driver.Rows, error) { diff --git a/transaction.go b/transaction.go index 6d7bb25..30e3b9b 100644 --- a/transaction.go +++ b/transaction.go @@ -42,7 +42,7 @@ func wrapTx(ctx context.Context, parent driver.Tx, r methodRecorder, t methodTra } } -func noOpTxFunc() error { +func nopTxFunc() error { return nil } diff --git a/transaction_internal_test.go b/transaction_internal_test.go index 7776ec8..f72a68e 100644 --- a/transaction_internal_test.go +++ b/transaction_internal_test.go @@ -15,7 +15,7 @@ import ( func TestChainTxFuncMiddlewares_NoMiddleware(t *testing.T) { t.Parallel() - f := chainTxFuncMiddlewares(nil, noOpTxFunc) + f := chainTxFuncMiddlewares(nil, nopTxFunc) err := f() @@ -87,7 +87,7 @@ func TestTxStats(t *testing.T) { }, { scenario: "no error", - beginner: noOpTxFunc, + beginner: nopTxFunc, expected: `[ { "Name": "db.sql.client.calls{service.name=otelsql,instrumentation.name=tx_test,db.instance=test,db.operation=go.sql.commit,db.sql.status=OK,db.system=other_sql}",