From 8a4b90b7dd3b5e2b25dc79679f2ef7c10485ebb0 Mon Sep 17 00:00:00 2001 From: S7evinK Date: Tue, 17 Aug 2021 11:39:09 +0200 Subject: [PATCH] Update golangci-lint (#1978) * Update golangci-lint * Use unconditional strings.TrimSuffix * Add error checks Signed-off-by: Till Faelligen * Disable lint typecheck * Fix ineffectual error assignment (#1976) Was working on another PR and noticed that golangci-lint was failing locally on `ineffassign` Signed-off-by: Devon Mizelle * Revert "Disable lint typecheck" This reverts commit 3c76f219d3cb43e4ee9a9c319abd0b8879972cfc. Co-authored-by: Devon Mizelle --- build/scripts/find-lint.sh | 2 +- clientapi/routing/routing.go | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/build/scripts/find-lint.sh b/build/scripts/find-lint.sh index 4ab5e4de..af87e14d 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..." diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index c6be8939..d282306f 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)