Skip to content

Commit

Permalink
chore: make golangci-lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Feb 16, 2024
1 parent 2dd3b92 commit 38784ae
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func authorize(r *http.Request, jwtConfig *jwtConfig, publishOrigins []string, c

// validateJWT validates that the provided JWT token is a valid Mercure token.
func validateJWT(encodedToken string, jwtConfig *jwtConfig) (*claims, error) {
token, err := jwt.ParseWithClaims(encodedToken, &claims{}, func(token *jwt.Token) (interface{}, error) {
token, err := jwt.ParseWithClaims(encodedToken, &claims{}, func(_ *jwt.Token) (interface{}, error) {
switch jwtConfig.signingMethod.(type) {
case *jwt.SigningMethodHMAC:
return jwtConfig.key, nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ other HTTP clients in a convenient, fast, reliable and battery-efficient way.
The Mercure Hub is the reference implementation of the Mercure protocol.
Go to https://mercure.rocks for more information!`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
mercure.Start() //nolint:staticcheck
},
}
Expand Down
11 changes: 5 additions & 6 deletions common/version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package common

import (
"fmt"
"runtime"
"runtime/debug"
"strings"
Expand Down Expand Up @@ -31,24 +30,24 @@ func (v *AppVersionInfo) Shortline() string {
shortline := v.Version

if v.Commit != "" {
shortline += fmt.Sprintf(", commit %s", v.Commit)
shortline += ", commit " + v.Commit
}

if v.BuildDate != "" {
shortline += fmt.Sprintf(", built at %s", v.BuildDate)
shortline += ", built at " + v.BuildDate
}

return shortline
}

func (v *AppVersionInfo) ChangelogURL() string {
path := "https://github.com/dunglas/mercure"
const path = "https://github.com/dunglas/mercure"

if v.Version == "dev" {
return fmt.Sprintf("%s/releases/latest", path)
return path + "/releases/latest"
}

return fmt.Sprintf("%s/releases/tag/v%s", path, strings.TrimPrefix(v.Version, "v"))
return path + "/releases/tag/v" + strings.TrimPrefix(v.Version, "v")
}

func (v *AppVersionInfo) NewMetricsCollector() *prometheus.GaugeVec {
Expand Down
2 changes: 1 addition & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (h *Hub) metricsHandler() http.Handler {

// Deprecated: use the Caddy server module or the standalone library instead.
func registerHealthz(router *mux.Router) {
router.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
router.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprint(w, "ok")
}).Methods(http.MethodGet, http.MethodHead)
}
Expand Down
6 changes: 3 additions & 3 deletions publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestPublishOK(t *testing.T) {
defer w.Done()
u, ok := <-s.Receive()
assert.True(t, ok)
require.NotNil(t, u)
assert.NotNil(t, u)
assert.Equal(t, "id", u.ID)
assert.Equal(t, s.SubscribedTopics, u.Topics)
assert.Equal(t, "Hello!", u.Data)
Expand Down Expand Up @@ -248,10 +248,10 @@ func TestPublishGenerateUUID(t *testing.T) {
go func() {
defer wg.Done()
u := <-s.Receive()
require.NotNil(t, u)
assert.NotNil(t, u)

_, err := uuid.FromString(strings.TrimPrefix(u.ID, "urn:uuid:"))
require.NoError(t, err)
assert.NoError(t, err)
}()

form := url.Values{}
Expand Down
6 changes: 3 additions & 3 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestServe(t *testing.T) {
go func() {
defer wgTested.Done()
resp, err := client.Get(testURL + "?topic=http%3A%2F%2Fexample.com%2Ffoo%2F1")
require.NoError(t, err)
assert.NoError(t, err)
wgConnected.Done()

defer resp.Body.Close()
Expand All @@ -197,7 +197,7 @@ func TestServe(t *testing.T) {
go func() {
defer wgTested.Done()
resp, err := client.Get(testURL + "?topic=http%3A%2F%2Fexample.com%2Falt%2F1")
require.NoError(t, err)
assert.NoError(t, err)
wgConnected.Done()

defer resp.Body.Close()
Expand Down Expand Up @@ -335,7 +335,7 @@ func TestServeAcme(t *testing.T) {

go h.Serve()
client := &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
},
}
Expand Down

0 comments on commit 38784ae

Please sign in to comment.