Skip to content

Commit 5c30e1e

Browse files
committed
Fixed linter errors
1 parent af7aac5 commit 5c30e1e

File tree

8 files changed

+30
-9
lines changed

8 files changed

+30
-9
lines changed

pkg/database/postgres/pgx_sync_tx.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ func (tx *PgxSyncTx) Begin(ctx context.Context) (pgx.Tx, error) {
167167
}
168168

169169
// BeginTx is used to wrap [pgx.Tx.BeginTx] in a [database.SyncTx].
170-
func (tx *PgxSyncTx) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error) {
170+
func (tx *PgxSyncTx) BeginTx(
171+
ctx context.Context,
172+
txOptions pgx.TxOptions,
173+
) (pgx.Tx, error) {
171174
return database.WrapInSyncTx(
172175
ctx,
173176
tx.syncTx,

pkg/database/postgres/spandb.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ func (db *SpanDB) Begin(ctx context.Context) (pgx.Tx, error) {
7979

8080
// BeginTx doesn't wrap BeginTx in a [sentry.Span] as
8181
// this makes little sense for starting a transaction.
82-
func (db *SpanDB) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error) {
82+
func (db *SpanDB) BeginTx(
83+
ctx context.Context,
84+
txOptions pgx.TxOptions,
85+
) (pgx.Tx, error) {
8386
return db.DB.BeginTx(ctx, txOptions)
8487
}
8588

pkg/database/span.go

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/getsentry/sentry-go"
77
)
88

9+
// StartSpan is used to start a [sentry.Span].
910
func StartSpan(ctx context.Context, dbName string, sql string) *sentry.Span {
1011
span := sentry.StartSpan(ctx, "db.query", sentry.WithDescription(sql))
1112
span.SetData("db.system", dbName)

pkg/parse/parser_funcs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type ParserFunc[T any] func(paramType string, paramName string, value string) (T
1414

1515
// String is used to parse a parameter as string value.
1616
// As all parameters are string by default this returns the original value.
17-
func String(paramType string, paramName string, value string) (string, error) {
17+
func String(_ string, _ string, value string) (string, error) {
1818
return value, nil
1919
}
2020

pkg/time/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ func EndOfDay(dateTime time.Time) time.Time {
2929
return output
3030
}
3131

32-
// NowTimeZoneIndependent returns the provided time in the
32+
// LocationIndependentTime returns the provided time in the
3333
// provided time zone but forces the time zone to UTC.
34-
func TimeZoneIndependentTime(t time.Time, locationTimeZone string) time.Time {
34+
func LocationIndependentTime(t time.Time, locationTimeZone string) time.Time {
3535
timeZone, _ := time.LoadLocation(locationTimeZone)
3636
utcTimeZone, _ := time.LoadLocation("UTC")
3737
t = t.In(timeZone)

pkg/time/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ func TestEndOfDay(t *testing.T) {
3434
assert.Equal(t, endOfDay, timetools.EndOfDay(now))
3535
}
3636

37-
func TestTimeZoneIndependentTime(t *testing.T) {
37+
func TestLocationIndependentTime(t *testing.T) {
3838
now := time.Now()
3939

4040
utcTimeZone, _ := time.LoadLocation("UTC")
41-
result := timetools.TimeZoneIndependentTime(now, now.Location().String())
41+
result := timetools.LocationIndependentTime(now, now.Location().String())
4242

4343
expected := time.Date(
4444
now.Year(),

pkg/validate/main.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func (v *Validator) Valid() bool {
2323
return len(v.errors) == 0
2424
}
2525

26+
// Errors returns the [Validator] errors.
2627
func (v *Validator) Errors() map[string]string {
2728
return v.errors
2829
}
@@ -41,7 +42,14 @@ func Check[T any](v *Validator, key string, value T, validatorFunc ValidatorFunc
4142
}
4243
}
4344

44-
func CheckOptional[T any](v *Validator, key string, value *T, validatorFunc ValidatorFunc[T]) {
45+
// CheckOptional checks if value passes the validatorFunc, when the value is provided.
46+
// The provided key is used for creating the errors map of the [Validator].
47+
func CheckOptional[T any](
48+
v *Validator,
49+
key string,
50+
value *T,
51+
validatorFunc ValidatorFunc[T],
52+
) {
4553
if value == nil {
4654
return
4755
}

pkg/validate/validator_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//nolint:exhaustruct //on purpose
12
package validate_test
23

34
import (
@@ -42,7 +43,12 @@ func (ts *TestStruct) Validate() (bool, map[string]string) {
4243

4344
validate.Check(v, "tzVal", ts.TzVal, validate.IsValidTimeZone)
4445

45-
validate.CheckOptional(v, "optStrVal", ts.OptStrVal, validate.IsInSlice([]string{"allowed"}))
46+
validate.CheckOptional(
47+
v,
48+
"optStrVal",
49+
ts.OptStrVal,
50+
validate.IsInSlice([]string{"allowed"}),
51+
)
4652

4753
return v.Valid(), v.Errors()
4854
}

0 commit comments

Comments
 (0)