mirror of https://github.com/matrix-org/gomatrix
Run CI using golangci-lint, Go 1.13.10 (#78)
* Run CI using golangci-lint, Go 1.13.10 * Update pre-commit hook * Fix lint issues
This commit is contained in:
parent
408fff5e6a
commit
e5578b12c7
|
@ -0,0 +1,21 @@
|
||||||
|
run:
|
||||||
|
timeout: 5m
|
||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- vet
|
||||||
|
- vetshadow
|
||||||
|
- typecheck
|
||||||
|
- deadcode
|
||||||
|
- gocyclo
|
||||||
|
- golint
|
||||||
|
- varcheck
|
||||||
|
- structcheck
|
||||||
|
- maligned
|
||||||
|
- ineffassign
|
||||||
|
- misspell
|
||||||
|
- unparam
|
||||||
|
- goimports
|
||||||
|
- goconst
|
||||||
|
- unconvert
|
||||||
|
- errcheck
|
||||||
|
- interfacer
|
|
@ -1,9 +1,7 @@
|
||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
- 1.10.x
|
- 1.13.10
|
||||||
install:
|
install:
|
||||||
- go get github.com/golang/lint/golint
|
- go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.24.0
|
||||||
- go get github.com/fzipp/gocyclo
|
- go build
|
||||||
- go get github.com/client9/misspell/...
|
|
||||||
- go get github.com/gordonklaus/ineffassign
|
|
||||||
script: ./hooks/pre-commit
|
script: ./hooks/pre-commit
|
||||||
|
|
|
@ -55,10 +55,7 @@ func (e HTTPError) Error() string {
|
||||||
|
|
||||||
// BuildURL builds a URL with the Client's homserver/prefix/access_token set already.
|
// BuildURL builds a URL with the Client's homserver/prefix/access_token set already.
|
||||||
func (cli *Client) BuildURL(urlPath ...string) string {
|
func (cli *Client) BuildURL(urlPath ...string) string {
|
||||||
ps := []string{cli.Prefix}
|
ps := append([]string{cli.Prefix}, urlPath...)
|
||||||
for _, p := range urlPath {
|
|
||||||
ps = append(ps, p)
|
|
||||||
}
|
|
||||||
return cli.BuildBaseURL(ps...)
|
return cli.BuildBaseURL(ps...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ func Example_customInterfaces() {
|
||||||
cli.Client = http.DefaultClient
|
cli.Client = http.DefaultClient
|
||||||
|
|
||||||
// Once you call a function, you can't safely change the interfaces.
|
// Once you call a function, you can't safely change the interfaces.
|
||||||
cli.SendText("!foo:bar", "Down the rabbit hole")
|
_, _ = cli.SendText("!foo:bar", "Down the rabbit hole")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleClient_BuildURLWithQuery() {
|
func ExampleClient_BuildURLWithQuery() {
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
golint
|
|
||||||
misspell --error .
|
|
||||||
|
|
||||||
# gofmt doesn't exit with an error code if the files don't match the expected
|
# gofmt doesn't exit with an error code if the files don't match the expected
|
||||||
# format. So we have to run it and see if it outputs anything.
|
# format. So we have to run it and see if it outputs anything.
|
||||||
if gofmt -l -s . 2>&1 | read
|
if gofmt -l -s . 2>&1 | read
|
||||||
|
@ -18,9 +15,5 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ineffassign .
|
golangci-lint run
|
||||||
|
go test -timeout 5s . ./...
|
||||||
go fmt
|
|
||||||
go tool vet --all --shadow .
|
|
||||||
gocyclo -over 12 .
|
|
||||||
go test -timeout 5s -test.v
|
|
||||||
|
|
4
room.go
4
room.go
|
@ -31,8 +31,8 @@ func (room Room) UpdateState(event *Event) {
|
||||||
|
|
||||||
// GetStateEvent returns the state event for the given type/state_key combo, or nil.
|
// GetStateEvent returns the state event for the given type/state_key combo, or nil.
|
||||||
func (room Room) GetStateEvent(eventType string, stateKey string) *Event {
|
func (room Room) GetStateEvent(eventType string, stateKey string) *Event {
|
||||||
stateEventMap, _ := room.State[eventType]
|
stateEventMap := room.State[eventType]
|
||||||
event, _ := stateEventMap[stateKey]
|
event := stateEventMap[stateKey]
|
||||||
return event
|
return event
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue