refactor(wip): fix deepsource analyze

This commit is contained in:
Cr 2021-09-06 16:48:22 +08:00
parent 915cdb94bc
commit 7abf5669e4
No known key found for this signature in database
GPG Key ID: E6C6812B87229952
2 changed files with 7 additions and 12 deletions

View File

@ -318,7 +318,7 @@ func (o *ormBase) LoadRelated(md interface{}, name string, args ...utils.KV) (in
return o.LoadRelatedWithCtx(context.Background(), md, name, args...)
}
func (o *ormBase) LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...utils.KV) (int64, error) {
func (o *ormBase) LoadRelatedWithCtx(_ context.Context, md interface{}, name string, args ...utils.KV) (int64, error) {
_, fi, ind, qs := o.queryRelated(md, name)
var relDepth int
@ -488,7 +488,7 @@ func (o *ormBase) Raw(query string, args ...interface{}) RawSeter {
return o.RawWithCtx(context.Background(), query, args...)
}
func (o *ormBase) RawWithCtx(ctx context.Context, query string, args ...interface{}) RawSeter {
func (o *ormBase) RawWithCtx(_ context.Context, query string, args ...interface{}) RawSeter {
return newRawSet(o, query, args)
}

View File

@ -144,7 +144,7 @@ func getCaller(skip int) string {
}
func formatLines(s string) string {
return strings.Replace(s, "\t", " ", -1)
return strings.ReplaceAll(s, "\t", " ")
}
// Deprecated: Using stretchr/testify/assert
@ -1725,7 +1725,7 @@ func TestQueryM2M(t *testing.T) {
throwFailNow(t, AssertIs(num, 1))
}
func TestQueryRelate(t *testing.T) {
func TestQueryRelate(_ *testing.T) {
// post := &Post{Id: 2}
// qs := dORM.QueryRelate(post, "Tags")
@ -2075,9 +2075,7 @@ func TestRawPrepare(t *testing.T) {
err error
pre RawPreparer
)
switch {
case IsMysql || IsSqlite:
if IsMysql || IsSqlite {
pre, err = dORM.Raw("INSERT INTO tag (name) VALUES (?)").Prepare()
assert.Nil(t, err)
if pre != nil {
@ -2112,9 +2110,7 @@ func TestRawPrepare(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, num, int64(3))
}
case IsPostgres:
} else if IsPostgres {
pre, err = dORM.Raw(`INSERT INTO "tag" ("name") VALUES (?) RETURNING "id"`).Prepare()
assert.Nil(t, err)
if pre != nil {
@ -2244,8 +2240,7 @@ func TestTransaction(t *testing.T) {
throwFail(t, err)
throwFail(t, AssertIs(num, 1))
switch {
case IsMysql || IsSqlite:
if IsMysql || IsSqlite {
res, err := to.Raw("INSERT INTO tag (name) VALUES (?)", names[2]).Exec()
throwFail(t, err)
if err == nil {