From e82539b37180263326f023c416bc74e1813e4d9d Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Tue, 10 Aug 2021 13:48:21 +0200 Subject: [PATCH 1/4] Update golangci-lint --- build/scripts/find-lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/find-lint.sh b/build/scripts/find-lint.sh index 4ab5e4de1..af87e14d7 100755 --- a/build/scripts/find-lint.sh +++ b/build/scripts/find-lint.sh @@ -25,7 +25,7 @@ echo "Installing golangci-lint..." # Make a backup of go.{mod,sum} first cp go.mod go.mod.bak && cp go.sum go.sum.bak -go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1 +go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.41.1 # Run linting echo "Looking for lint..." From 04823e8da23973945f779f6b5d4a6b21ae4f9236 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Tue, 10 Aug 2021 13:49:24 +0200 Subject: [PATCH 2/4] Use unconditional strings.TrimSuffix --- clientapi/routing/routing.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index c6be8939d..d282306f2 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -291,10 +291,7 @@ func Setup( return util.ErrorResponse(err) } // If there's a trailing slash, remove it - eventType := vars["type"] - if strings.HasSuffix(eventType, "/") { - eventType = eventType[:len(eventType)-1] - } + eventType := strings.TrimSuffix(vars["type"], "/") eventFormat := req.URL.Query().Get("format") == "event" return OnIncomingStateTypeRequest(req.Context(), device, rsAPI, vars["roomID"], eventType, "", eventFormat) })).Methods(http.MethodGet, http.MethodOptions) @@ -315,11 +312,7 @@ func Setup( return util.ErrorResponse(err) } emptyString := "" - eventType := vars["eventType"] - // If there's a trailing slash, remove it - if strings.HasSuffix(eventType, "/") { - eventType = eventType[:len(eventType)-1] - } + eventType := strings.TrimSuffix(vars["eventType"], "/") return SendEvent(req, device, vars["roomID"], eventType, nil, &emptyString, cfg, rsAPI, nil) }), ).Methods(http.MethodPut, http.MethodOptions) From 47fbf69e985cedfed2a02edab6f5f536b13e2f24 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Tue, 10 Aug 2021 13:51:04 +0200 Subject: [PATCH 3/4] Add error checks Signed-off-by: Till Faelligen --- appservice/query/query.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/appservice/query/query.go b/appservice/query/query.go index 9f6c79a80..54867b87d 100644 --- a/appservice/query/query.go +++ b/appservice/query/query.go @@ -51,6 +51,9 @@ func (a *AppServiceQueryAPI) RoomAliasExists( if appservice.URL != "" && appservice.IsInterestedInRoomAlias(request.Alias) { // The full path to the rooms API, includes hs token URL, err := url.Parse(appservice.URL + roomAliasExistsPath) + if err != nil { + return err + } URL.Path += request.Alias apiURL := URL.String() + "?access_token=" + appservice.HSToken @@ -114,6 +117,9 @@ func (a *AppServiceQueryAPI) UserIDExists( if appservice.URL != "" && appservice.IsInterestedInUserID(request.UserID) { // The full path to the rooms API, includes hs token URL, err := url.Parse(appservice.URL + userIDExistsPath) + if err != nil { + return err + } URL.Path += request.UserID apiURL := URL.String() + "?access_token=" + appservice.HSToken From 3c76f219d3cb43e4ee9a9c319abd0b8879972cfc Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Tue, 10 Aug 2021 15:09:20 +0200 Subject: [PATCH 4/4] Disable lint typecheck --- cmd/dendrite-demo-yggdrasil/yggconn/node.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/dendrite-demo-yggdrasil/yggconn/node.go b/cmd/dendrite-demo-yggdrasil/yggconn/node.go index 002e8071f..8e3083ea4 100644 --- a/cmd/dendrite-demo-yggdrasil/yggconn/node.go +++ b/cmd/dendrite-demo-yggdrasil/yggconn/node.go @@ -26,7 +26,7 @@ import ( "os" "strings" - "github.com/lucas-clemente/quic-go" + "github.com/lucas-clemente/quic-go" //nolint: typecheck "github.com/matrix-org/gomatrixserverlib" "github.com/neilalexander/utp" @@ -44,7 +44,7 @@ type Node struct { config *yggdrasilconfig.NodeConfig multicast *yggdrasilmulticast.Multicast log *gologme.Logger - listener quic.Listener + listener quic.Listener //nolint: typecheck utpSocket *utp.Socket incoming chan net.Conn }