Skip to content

Commit 10474e5

Browse files
committed
fix lint
Signed-off-by: a1012112796 <1012112796@qq.com>
1 parent 0727a65 commit 10474e5

File tree

3 files changed

+10
-24
lines changed

3 files changed

+10
-24
lines changed

contrib/dev/dev.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ package main
55

66
import (
77
"context"
8-
"fmt"
98
"io/fs"
109
"net/http"
1110
"os"
1211
"path"
1312
"path/filepath"
1413
"strings"
1514

16-
_ "code.gitea.io/gitea/models"
1715
"code.gitea.io/gitea/models/db"
1816
"code.gitea.io/gitea/models/unittest"
1917
"code.gitea.io/gitea/modules/graceful"
@@ -22,6 +20,9 @@ import (
2220
"code.gitea.io/gitea/modules/util"
2321
"code.gitea.io/gitea/routers"
2422
"code.gitea.io/gitea/routers/common"
23+
24+
_ "code.gitea.io/gitea/models"
25+
2526
"gopkg.in/yaml.v3"
2627
)
2728

@@ -70,21 +71,6 @@ func main() {
7071
log.GetManager().Close()
7172
}
7273

73-
func buildInterfacesSlice(records interface{}) ([]interface{}, error) {
74-
switch records := records.(type) {
75-
case []interface{}:
76-
return records, nil
77-
case map[string]interface{}:
78-
var result []interface{}
79-
for _, record := range records {
80-
result = append(result, record)
81-
}
82-
return result, nil
83-
}
84-
85-
return nil, fmt.Errorf("testfixtures: fixture is not a slice or map")
86-
}
87-
8874
func listSubDir(dirname string, onDir func(path, name string) error) error {
8975
fileInfos, err := os.ReadDir(dirname)
9076
if err != nil {

models/unittest/fixtures.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package unittest
66

77
import (
8-
"encoding/json"
98
"errors"
109
"fmt"
1110
"io"
@@ -17,6 +16,7 @@ import (
1716

1817
"code.gitea.io/gitea/models/db"
1918
"code.gitea.io/gitea/modules/auth/password/hash"
19+
"code.gitea.io/gitea/modules/json"
2020
"code.gitea.io/gitea/modules/setting"
2121
"code.gitea.io/gitea/modules/util"
2222

@@ -197,7 +197,7 @@ func defaultFixtureDumperVerbs(tableName string, actualValue reflect.Value, type
197197

198198
fieldValue := field.Interface()
199199
isText := xormTags.HasTag("TEXT")
200-
isJson := xormTags.HasTag("JSON")
200+
isJSON := xormTags.HasTag("JSON")
201201
conversion, hasconversion := fieldValue.(convert.Conversion)
202202
if (!hasconversion) && isFieldNil(field) {
203203
continue
@@ -231,7 +231,7 @@ func defaultFixtureDumperVerbs(tableName string, actualValue reflect.Value, type
231231

232232
int64Type := reflect.TypeOf(int64(0))
233233
isInt64 := field.Type().ConvertibleTo(int64Type)
234-
if fieldType.Type.Kind() == reflect.Struct && !isInt64 && !isText && !isJson {
234+
if fieldType.Type.Kind() == reflect.Struct && !isInt64 && !isText && !isJSON {
235235
return fmt.Errorf("%s: '%s' is a struct whcih can't be convert to a table field", tableName, xormTags.GetFieldName(fieldName))
236236
}
237237

@@ -240,7 +240,7 @@ func defaultFixtureDumperVerbs(tableName string, actualValue reflect.Value, type
240240
return err
241241
}
242242

243-
if isJson {
243+
if isJSON {
244244
result, err := json.Marshal(fieldValue)
245245
if err != nil {
246246
return err
@@ -363,7 +363,7 @@ func (l xormTagList) HasTag(name string) bool {
363363
}
364364

365365
func (l xormTagList) GetFieldName(defaultName string) string {
366-
var reservedNames = []string{
366+
reservedNames := []string{
367367
"TRUE",
368368
"FALSE",
369369
"BIT",

models/unittest/fixtures_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ func (t testSub2) String() string {
1717
return "unknow"
1818
}
1919

20-
type testSubConversion struct {
21-
}
20+
type testSubConversion struct{}
2221

2322
func (c *testSubConversion) FromDB([]byte) error {
2423
return nil
2524
}
25+
2626
func (c *testSubConversion) ToDB() ([]byte, error) {
2727
return []byte("testSubConversion"), nil
2828
}

0 commit comments

Comments
 (0)