Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc25a810

Browse files
authored
Make linter more strict (#201)
* Make linter more strict* travis: cache $GOCACHE
1 parente3c1add commitc25a810

File tree

21 files changed

+226
-198
lines changed

21 files changed

+226
-198
lines changed

‎.travis.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ go:
2020
-1.x
2121
-tip
2222
install:
23+
-export GOCACHE=$GOPATH/pkg/cache
2324
-make testdeps
2425
script:
26+
-export GOCACHE=$GOPATH/pkg/cache
2527
-make coverage
2628
-go build -o video-transcoding-api
2729
after_success:

‎Makefile‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,22 @@ all: test
88

99
testdeps:
1010
GO111MODULE=off go get github.com/go-swagger/go-swagger/cmd/swagger
11-
go get github.com/golangci/golangci-lint/cmd/golangci-lint@master
11+
GO111MODULE=offgo get github.com/golangci/golangci-lint/cmd/golangci-lint
1212
go mod download
1313

1414
lint: testdeps
15-
golangci-lint run --fast -D errcheck -E megacheck --deadline 5m ./...
15+
golangci-lint run\
16+
--enable-all\
17+
-D errcheck\
18+
-D lll\
19+
-D gochecknoglobals\
20+
-D goconst\
21+
-D gocyclo\
22+
-D dupl\
23+
-D gocritic\
24+
-D gochecknoinits\
25+
-D unparam\
26+
--deadline 5m ./...
1627

1728
gotest: testdeps
1829
gotest ./...

‎config/config.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package config
33
import (
44
"github.com/NYTimes/gizmo/server"
55
"github.com/NYTimes/video-transcoding-api/db/redis/storage"
6-
"github.com/fsouza/gizmo-stackdriver-logging"
6+
logging"github.com/fsouza/gizmo-stackdriver-logging"
77
"github.com/kelseyhightower/envconfig"
88
)
99

‎config/config_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/NYTimes/gizmo/server"
88
"github.com/NYTimes/video-transcoding-api/db/redis/storage"
9-
"github.com/fsouza/gizmo-stackdriver-logging"
9+
logging"github.com/fsouza/gizmo-stackdriver-logging"
1010
"github.com/google/go-cmp/cmp"
1111
"github.com/google/go-cmp/cmp/cmpopts"
1212
)

‎db/redis/job_test.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ func TestListJobs(t *testing.T) {
246246
}
247247
expectedJobs:=make([]db.Job,len(jobs))
248248
fori,job:=rangejobs {
249+
job:=job
249250
err=repo.CreateJob(&job)
250251
iferr!=nil {
251252
t.Fatal(err)
@@ -297,6 +298,7 @@ func TestListJobsLimit(t *testing.T) {
297298
limit:=2
298299
expectedJobs:=make([]db.Job,limit)
299300
fori,job:=rangejobs {
301+
job:=job
300302
err=repo.CreateJob(&job)
301303
iferr!=nil {
302304
t.Fatal(err)
@@ -352,6 +354,7 @@ func TestListJobsInconsistency(t *testing.T) {
352354
redisRepo.storage.RedisClient().ZAddNX("some-weird-id2", redis.Z{Member:jobs[1],Score:math.Inf(0)})
353355
expectedJobs:=make([]db.Job,len(jobs))
354356
fori,job:=rangejobs {
357+
job:=job
355358
err=repo.CreateJob(&job)
356359
iferr!=nil {
357360
t.Fatal(err)
@@ -409,6 +412,7 @@ func TestListJobsFiltering(t *testing.T) {
409412
since:=now.Add(-59*time.Minute)
410413
redisRepo:=repo.(*redisRepository)
411414
for_,job:=rangejobs {
415+
job:=job
412416
err=redisRepo.saveJob(&job)
413417
iferr!=nil {
414418
t.Fatal(err)
@@ -469,6 +473,7 @@ func TestListJobsFilteringAndLimit(t *testing.T) {
469473
since:=now.Add(-59*time.Minute)
470474
redisRepo:=repo.(*redisRepository)
471475
for_,job:=rangejobs {
476+
job:=job
472477
err=redisRepo.saveJob(&job)
473478
iferr!=nil {
474479
t.Fatal(err)

‎db/redis/storage/redis.go‎

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,22 @@ func (s *Storage) structToFieldList(value reflect.Value, prefixes ...string) (ma
160160
default:
161161
returnnil,errors.New("can only expand structs and maps")
162162
}
163-
}else {
164-
ifparts[0]!="" {
165-
key:=strings.Join(append(prefixes,parts[0]),"_")
166-
varstrValuestring
167-
iface:=fieldValue.Interface()
168-
switchv:=iface.(type) {
169-
case time.Time:
170-
strValue=v.Format(time.RFC3339Nano)
171-
case []string:
172-
strValue=strings.Join(v,"%%%")
173-
default:
174-
strValue=fmt.Sprintf("%v",v)
175-
}
176-
ifparts[len(parts)-1]=="omitempty"&&strValue=="" {
177-
continue
178-
}
179-
fields[key]=strValue
163+
}elseifparts[0]!="" {
164+
key:=strings.Join(append(prefixes,parts[0]),"_")
165+
varstrValuestring
166+
iface:=fieldValue.Interface()
167+
switchv:=iface.(type) {
168+
case time.Time:
169+
strValue=v.Format(time.RFC3339Nano)
170+
case []string:
171+
strValue=strings.Join(v,"%%%")
172+
default:
173+
strValue=fmt.Sprintf("%v",v)
174+
}
175+
ifparts[len(parts)-1]=="omitempty"&&strValue=="" {
176+
continue
180177
}
178+
fields[key]=strValue
181179
}
182180
}
183181
returnfields,nil

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp