Skip to content

Commit

Permalink
Run CI using golangci-lint, Go 1.13.10 (matrix-org#78)
Browse files Browse the repository at this point in the history
* Run CI using golangci-lint, Go 1.13.10

* Update pre-commit hook

* Fix lint issues
  • Loading branch information
neilalexander authored May 1, 2020
1 parent 408fff5 commit e5578b1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
21 changes: 21 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
language: go
go:
- 1.10.x
- 1.13.10
install:
- go get github.com/golang/lint/golint
- go get github.com/fzipp/gocyclo
- go get github.com/client9/misspell/...
- go get github.com/gordonklaus/ineffassign
- go get github.com/golangci/golangci-lint/cmd/[email protected]
- go build
script: ./hooks/pre-commit
5 changes: 1 addition & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ func (e HTTPError) Error() string {

// BuildURL builds a URL with the Client's homserver/prefix/access_token set already.
func (cli *Client) BuildURL(urlPath ...string) string {
ps := []string{cli.Prefix}
for _, p := range urlPath {
ps = append(ps, p)
}
ps := append([]string{cli.Prefix}, urlPath...)
return cli.BuildBaseURL(ps...)
}

Expand Down
2 changes: 1 addition & 1 deletion client_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Example_customInterfaces() {
cli.Client = http.DefaultClient

// 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() {
Expand Down
11 changes: 2 additions & 9 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

set -eu

golint
misspell --error .

# 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.
if gofmt -l -s . 2>&1 | read
Expand All @@ -18,9 +15,5 @@ then
exit 1
fi

ineffassign .

go fmt
go tool vet --all --shadow .
gocyclo -over 12 .
go test -timeout 5s -test.v
golangci-lint run
go test -timeout 5s . ./...
4 changes: 2 additions & 2 deletions room.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func (room Room) UpdateState(event *Event) {

// GetStateEvent returns the state event for the given type/state_key combo, or nil.
func (room Room) GetStateEvent(eventType string, stateKey string) *Event {
stateEventMap, _ := room.State[eventType]
event, _ := stateEventMap[stateKey]
stateEventMap := room.State[eventType]
event := stateEventMap[stateKey]
return event
}

Expand Down

0 comments on commit e5578b1

Please sign in to comment.