Skip to content

Upgrade golangci-lint to 1.53.3 and adjust the linters used #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,51 @@ linters:
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- deadcode
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- forcetypeassert
- gocheckcompilerdirectives
- gocyclo
- godot
- gofmt
- gofumpt
- gosec
- gosimple
- gosmopolitan
- govet
- ifshort
- importas
- ineffassign
- makezero
- mirror
- misspell
- nilerr
- nilnil
- noctx
- nosprintfhostport
- predeclared
- reassign
- revive
- staticcheck
- tenv
- testableexamples
- typecheck
- unconvert
- unused
- varcheck
- usestdlibvars
- wastedassign
- whitespace
linters-settings:
misspell:
locale: US
usestdlibvars:
crypto-hash: true
http-method: false
os-dev-null: true
sql-isolation-level: true
time-layout: true
tls-signature-scheme: true
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ GOVVV = $(GOBIN)/govvv
MOCKGEN = $(GOBIN)/mockgen
PIGEON = $(GOBIN)/pigeon

GOLANGCI_LINT_VERSION := v1.43.0
GOLANGCI_LINT_INSTALLATION_SHA256 := 294771225087ee48c8e0a45a99ac82ed8f9c6e9d384e692ab201986479c8594f
GOLANGCI_LINT_BINARY_SHA256 := c6f662fd533a7bff89c2d554dbe0708b6d3925f4b305d3522591d6bca0b48469
GOLANGCI_LINT_VERSION := v1.53.3
GOLANGCI_LINT_INSTALLATION_SHA256 := 060f1f3deb31b3d3b9515d691d9a776354cd63c7fcb5e036f18f0444cf2c934b
GOLANGCI_LINT_BINARY_SHA256 := 09237052ea9582630019182e890288ec155567fc949e6f329e3beb2c6e76b1b5

.PHONY: all
all: test build start
Expand Down
2 changes: 1 addition & 1 deletion cmd/goer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion internal/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion internal/database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion internal/database/drivers/drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
8 changes: 3 additions & 5 deletions internal/database/drivers/mongodb/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -180,7 +180,6 @@ func (m *Database) GetEvents(ctx context.Context, request requests.MultipleEvent
SetSkip(int64((request.PageNo-1)*request.PageSize)).
SetLimit(int64(limit)),
)

if err != nil {
continue
}
Expand All @@ -201,7 +200,7 @@ func (m *Database) GetEvents(ctx context.Context, request requests.MultipleEvent
}

// UpstreamDownstreamSearch searches for events upstream and/or downstream of event by ID.
func (m *Database) UpstreamDownstreamSearch(ctx context.Context, id string) ([]drivers.EiffelEvent, error) {
func (m *Database) UpstreamDownstreamSearch(_ context.Context, _ string) ([]drivers.EiffelEvent, error) {
return nil, errors.New("not yet implemented")
}

Expand All @@ -220,9 +219,8 @@ func (m *Database) GetEventByID(ctx context.Context, id string) (drivers.EiffelE
err := singleResult.Decode(&event)
if err != nil {
continue
} else {
return drivers.EiffelEvent(event), nil
}
return drivers.EiffelEvent(event), nil
}
return nil, fmt.Errorf("%q not found in any collection", id)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
4 changes: 2 additions & 2 deletions internal/responses/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -22,7 +22,7 @@ import (

// RespondWithJSON writes a JSON response with a status code to the HTTP ResponseWriter.
func RespondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
response, _ := json.Marshal(payload)
response, _ := json.Marshal(payload) //nolint:errchkjson

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
Expand Down
6 changes: 3 additions & 3 deletions internal/responses/responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -27,14 +27,14 @@ func TestRespondWithJSON(t *testing.T) {
responseRecorder := httptest.NewRecorder()
RespondWithJSON(responseRecorder, 200, map[string]string{"hello": "world"})
assert.Equal(t, "application/json", responseRecorder.Header().Get("Content-Type"))
assert.Equal(t, 200, responseRecorder.Result().StatusCode)
assert.Equal(t, 200, responseRecorder.Result().StatusCode) //nolint:bodyclose
assert.JSONEq(t, `{"hello": "world"}`, responseRecorder.Body.String())
}

// Test that RespondWithError writes the correct HTTP code, message and adds a content type header.
func TestRespondWithError(t *testing.T) {
responseRecorder := httptest.NewRecorder()
RespondWithError(responseRecorder, 400, "Bad Request")
assert.Equal(t, 400, responseRecorder.Result().StatusCode)
assert.Equal(t, 400, responseRecorder.Result().StatusCode) //nolint:bodyclose
assert.Equal(t, "Bad Request", responseRecorder.Body.String())
}
2 changes: 1 addition & 1 deletion pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion pkg/application/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
7 changes: 5 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -19,6 +19,7 @@ import (
"errors"
"log"
"net/http"
"time"

"github.com/gorilla/mux"
)
Expand All @@ -44,7 +45,9 @@ type WebServer struct {
// Create a new WebServer.
func Get() Server {
return &WebServer{
server: &http.Server{},
server: &http.Server{
ReadTimeout: 10 * time.Second,
},
running: make(chan bool, 2), // Buffer up to two messages.
stopped: make(chan bool, 2), // Buffer up to two messages.
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/handlers/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/handlers/events/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
10 changes: 5 additions & 5 deletions pkg/v1/handlers/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -25,21 +25,21 @@ import (
"github.com/eiffel-community/eiffel-goer/internal/responses"
)

type SearchHandler struct {
type Handler struct {
Config config.Config
Database drivers.Database
Logger *log.Entry
}

// Get a new handler for the search endpoint.
func Get(cfg config.Config, db drivers.Database, logger *log.Entry) *SearchHandler {
return &SearchHandler{
func Get(cfg config.Config, db drivers.Database, logger *log.Entry) *Handler {
return &Handler{
cfg, db, logger,
}
}

// UpstreamDownstream handles POST requests against the /search/{id} endpoint.
// To get upstream/downstream events for an event based on the searchParameters passed.
func (h *SearchHandler) UpstreamDownstream(w http.ResponseWriter, r *http.Request) {
func (h *Handler) UpstreamDownstream(w http.ResponseWriter, _ *http.Request) {
responses.RespondWithError(w, http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
2 changes: 1 addition & 1 deletion pkg/v1/handlers/search/test_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down