ci: enable go vet check (#5981)

* ci: enable go vet check

* Improve .travis.yml
pull/5982/head
ᴜɴᴋɴᴡᴏɴ 2020-03-11 00:30:51 +08:00 committed by GitHub
parent 880d0ec19f
commit 047bf94908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 18 deletions

View File

@ -1,20 +1,18 @@
os: linux
language: go language: go
os: linux
dist: xenial
go: go:
- 1.13.x - 1.13.x
- 1.14.x - 1.14.x
go_import_path: gogs.io/gogs go_import_path: gogs.io/gogs
env: env:
- GO111MODULE=on - GO111MODULE=on
before_install: before_install:
- sudo apt-get update -qq - sudo apt-get update -qq
- sudo apt-get install -y libpam-dev - sudo apt-get install -y libpam-dev
script: script:
- go vet ./...
- go build -v -tags "pam" - go build -v -tags "pam"
- go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... - go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
after_success: after_success:
- bash <(curl -s https://codecov.io/bash) - bash <(curl -s https://codecov.io/bash)

View File

@ -31,10 +31,6 @@ dist: release
web: build web: build
./gogs web ./gogs web
govet:
$(GOVET) gogs.go
$(GOVET) models pkg routes
build: $(GENERATED) build: $(GENERATED)
go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)' -trimpath -o gogs go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)' -trimpath -o gogs

View File

@ -695,7 +695,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC
tperr, ok := err.(*textproto.Error) tperr, ok := err.(*textproto.Error)
if (ok && tperr.Code == 535) || if (ok && tperr.Code == 535) ||
strings.Contains(err.Error(), "Username and Password not accepted") { strings.Contains(err.Error(), "Username and Password not accepted") {
return nil, errors.UserNotExist{0, login} return nil, errors.UserNotExist{Name: login}
} }
return nil, err return nil, err
} }
@ -735,7 +735,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC
func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMConfig, autoRegister bool) (*User, error) { func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMConfig, autoRegister bool) (*User, error) {
if err := pam.PAMAuth(cfg.ServiceName, login, password); err != nil { if err := pam.PAMAuth(cfg.ServiceName, login, password); err != nil {
if strings.Contains(err.Error(), "Authentication failure") { if strings.Contains(err.Error(), "Authentication failure") {
return nil, errors.UserNotExist{0, login} return nil, errors.UserNotExist{Name: login}
} }
return nil, err return nil, err
} }
@ -768,7 +768,7 @@ func LoginViaGitHub(user *User, login, password string, sourceID int64, cfg *Git
fullname, email, url, location, err := github.Authenticate(cfg.APIEndpoint, login, password) fullname, email, url, location, err := github.Authenticate(cfg.APIEndpoint, login, password)
if err != nil { if err != nil {
if strings.Contains(err.Error(), "401") { if strings.Contains(err.Error(), "401") {
return nil, errors.UserNotExist{0, login} return nil, errors.UserNotExist{Name: login}
} }
return nil, err return nil, err
} }
@ -840,7 +840,7 @@ func UserLogin(username, password string, loginSourceID int64) (*User, error) {
return user, nil return user, nil
} }
return nil, errors.UserNotExist{user.ID, user.Name} return nil, errors.UserNotExist{UserID: user.ID, Name: user.Name}
} }
// Remote login to the login source the user is associated with // Remote login to the login source the user is associated with
@ -854,7 +854,7 @@ func UserLogin(username, password string, loginSourceID int64) (*User, error) {
// Non-local login source is always greater than 0 // Non-local login source is always greater than 0
if loginSourceID <= 0 { if loginSourceID <= 0 {
return nil, errors.UserNotExist{-1, username} return nil, errors.UserNotExist{UserID: -1, Name: username}
} }
source, err := GetLoginSourceByID(loginSourceID) source, err := GetLoginSourceByID(loginSourceID)

View File

@ -39,7 +39,7 @@ type Mirror struct {
NextSync time.Time `xorm:"-" json:"-"` NextSync time.Time `xorm:"-" json:"-"`
NextSyncUnix int64 `xorm:"next_update_unix"` NextSyncUnix int64 `xorm:"next_update_unix"`
address string `xorm:"-" json:"-"` address string `xorm:"-"`
} }
func (m *Mirror) BeforeInsert() { func (m *Mirror) BeforeInsert() {

View File

@ -437,10 +437,10 @@ type HookTask struct {
func (t *HookTask) BeforeUpdate() { func (t *HookTask) BeforeUpdate() {
if t.RequestInfo != nil { if t.RequestInfo != nil {
t.RequestContent = t.MarshalJSON(t.RequestInfo) t.RequestContent = t.ToJSON(t.RequestInfo)
} }
if t.ResponseInfo != nil { if t.ResponseInfo != nil {
t.ResponseContent = t.MarshalJSON(t.ResponseInfo) t.ResponseContent = t.ToJSON(t.ResponseInfo)
} }
} }
@ -472,7 +472,7 @@ func (t *HookTask) AfterSet(colName string, _ xorm.Cell) {
} }
} }
func (t *HookTask) MarshalJSON(v interface{}) string { func (t *HookTask) ToJSON(v interface{}) string {
p, err := jsoniter.Marshal(v) p, err := jsoniter.Marshal(v)
if err != nil { if err != nil {
log.Error("Marshal [%d]: %v", t.ID, err) log.Error("Marshal [%d]: %v", t.ID, err)