Removed dead code and added new travis tool

This commit is contained in:
Eduard Urbach 2018-11-08 20:30:36 +09:00
parent 9da70decfe
commit fb881eed81
3 changed files with 14 additions and 28 deletions

View File

@ -28,18 +28,20 @@ before_script:
- go get golang.org/x/lint/golint # Linter - go get golang.org/x/lint/golint # Linter
- go get honnef.co/go/tools/cmd/megacheck # Badass static analyzer/linter - go get honnef.co/go/tools/cmd/megacheck # Badass static analyzer/linter
- go get github.com/fzipp/gocyclo # Cyclomatic complexity - go get github.com/fzipp/gocyclo # Cyclomatic complexity
- go get github.com/3rf/codecoroner # Dead code analysis
- npm install -g typescript # TypeScript - npm install -g typescript # TypeScript
- git clone --depth=1 https://github.com/animenotifier/database ~/.aero/db/arn # Database - git clone --depth=1 https://github.com/animenotifier/database ~/.aero/db/arn # Database
# script always run to completion (set +e). All of these code checks are must haves # script always run to completion (set +e). All of these code checks are must haves
# in a modern Go project. # in a modern Go project.
script: script:
- make deps # Get dependencies. Allow this to fail because components cannot be found. - make deps # Get dependencies. Allow this to fail because components cannot be found.
- make all # Build - make all # Build
# - test -z $(gofmt -s -l $GO_FILES) # Fail if a .go file hasn't been formatted with gofmt # - test -z $(gofmt -s -l $GO_FILES) # Fail if a .go file hasn't been formatted with gofmt
- go test -v . # Run all the tests - go test -v . # Run all the tests
# - go test -v -race ./... # Run all the tests with the race detector enabled # - go test -v -race ./... # Run all the tests with the race detector enabled
- go vet ./... # go vet is the official Go static analyzer - go vet ./... # go vet is the official Go static analyzer
- megacheck ./... # "go vet on steroids" + linter - megacheck ./... # "go vet on steroids" + linter
- gocyclo -over 19 $GO_FILES # forbid code with huge functions - gocyclo -over 19 $GO_FILES # forbid code with huge functions
- golint -set_exit_status $(go list ./...) # one last linter - golint -set_exit_status $(go list ./...) # one last linter
- codecoroner -ignore components funcs ./... # dead code analysis

View File

@ -32,12 +32,7 @@ func Get(ctx *aero.Context) string {
} }
_, isPostable := obj.(arn.Postable) _, isPostable := obj.(arn.Postable)
return isPostable
if !isPostable {
return false
}
return true
}) })
arn.SortEditLogEntriesLatestFirst(entries) arn.SortEditLogEntriesLatestFirst(entries)

View File

@ -14,7 +14,6 @@ import (
var ( var (
scriptsETag = aero.ETagString(js.Bundle()) scriptsETag = aero.ETagString(js.Bundle())
stylesETag = aero.ETagString(css.Bundle()) stylesETag = aero.ETagString(css.Bundle())
streams = map[string][]*aero.EventStream{}
) )
// Events streams server events to the client. // Events streams server events to the client.
@ -31,6 +30,7 @@ func Events(ctx *aero.Context) string {
go func() { go func() {
defer fmt.Println(user.Nick, "disconnected, stop sending events") defer fmt.Println(user.Nick, "disconnected, stop sending events")
defer user.RemoveEventStream(stream)
stream.Events <- &aero.Event{ stream.Events <- &aero.Event{
Name: "etag", Name: "etag",
@ -54,18 +54,7 @@ func Events(ctx *aero.Context) string {
}, },
} }
for { <-stream.Closed
select {
case <-stream.Closed:
user.RemoveEventStream(stream)
return
// case <-time.After(10 * time.Second):
// stream.Events <- &aero.Event{
// Name: "ping",
// }
}
}
}() }()
return ctx.EventStream(stream) return ctx.EventStream(stream)