Skip to content

Commit

Permalink
Updates to latest actions and fixes golangci-lint drift (#221)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
codefromthecrypt authored Apr 20, 2024
1 parent e84b2cf commit a074cdb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ on:

jobs:
"CI":
env:
GO111MODULE: on
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -25,17 +23,17 @@ jobs:
steps:
# Set fetch-depth: 0 to fetch commit history and tags for use in version calculation
- name: Check out code
uses: actions/checkout@v2.3.4
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup go
uses: actions/setup-go@v1
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Lint files
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v4
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: latest
Expand All @@ -46,7 +44,7 @@ jobs:
CGO_ENABLED: 1

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
Expand Down
11 changes: 7 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
run:
deadline: 5m
skip-dirs:
timeout: 5m

issues:
exclude-dirs:
- zipkin_proto3

linters:
Expand All @@ -16,6 +18,7 @@ linters:
- lll
- misspell
- nakedret
- revive
- unparam
- unused

Expand All @@ -26,5 +29,5 @@ linters-settings:
line-length: 170
gocyclo:
min-complexity: 20
golint:
min-confidence: 0.85
revive:
confidence: 0.85
8 changes: 4 additions & 4 deletions middleware/http/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
)

func httpHandler(code int, headers http.Header, body *bytes.Buffer) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(code)
for key, value := range headers {
w.Header().Add(key, value[0])
Expand Down Expand Up @@ -221,9 +221,9 @@ func TestHTTPRequestSampler(t *testing.T) {

samplers := []func(r *http.Request) *bool{
nil,
func(r *http.Request) *bool { return mw.Sample() },
func(r *http.Request) *bool { return mw.Discard() },
func(r *http.Request) *bool { return nil },
func(*http.Request) *bool { return mw.Sample() },
func(*http.Request) *bool { return mw.Discard() },
func(*http.Request) *bool { return nil },
}

for idx, sampler := range samplers {
Expand Down
14 changes: 7 additions & 7 deletions middleware/http/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestRoundTripErrHandlingForRoundTripError(t *testing.T) {
req, _ := http.NewRequest("GET", "localhost", nil)
tr, _ := NewTransport(
tracer,
TransportErrHandler(func(_ zipkin.Span, err error, statusCode int) {
TransportErrHandler(func(_ zipkin.Span, err error, _ int) {
if want, have := expectedErr, err; want != have {
t.Errorf("unexpected error, want %q, have %q", want, have)
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestRoundTripErrHandlingForStatusCode(t *testing.T) {
}

for _, tc := range tcs {
srv := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
srv := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
rw.WriteHeader(tc.actualStatusCode)
}))

Expand All @@ -92,7 +92,7 @@ func TestRoundTripErrHandlingForStatusCode(t *testing.T) {
req, _ := http.NewRequest("GET", srv.URL, nil)
tr, _ := NewTransport(
tracer,
TransportErrHandler(func(_ zipkin.Span, err error, statusCode int) {
TransportErrHandler(func(_ zipkin.Span, _ error, statusCode int) {
if want, have := tc.expectedError, statusCode; want != 0 && want != have {
t.Errorf("unexpected status code, want %d, have %d", want, have)
}
Expand Down Expand Up @@ -163,27 +163,27 @@ func TestTransportRequestSamplerOverridesSamplingFromContext(t *testing.T) {
// Test RequestSampler override sample -> no sample
{
Sampler: zipkin.AlwaysSample,
RequestSampler: func(_ *http.Request) *bool { return Discard() },
RequestSampler: func(*http.Request) *bool { return Discard() },
ExpectedSampling: "0",
},
// Test RequestSampler override no sample -> sample
{
Sampler: zipkin.NeverSample,
RequestSampler: func(_ *http.Request) *bool { return Sample() },
RequestSampler: func(*http.Request) *bool { return Sample() },
ExpectedSampling: "1",
},
// Test RequestSampler pass through of sampled decision
{
Sampler: zipkin.AlwaysSample,
RequestSampler: func(r *http.Request) *bool {
RequestSampler: func(*http.Request) *bool {
return nil
},
ExpectedSampling: "1",
},
// Test RequestSampler pass through of not sampled decision
{
Sampler: zipkin.NeverSample,
RequestSampler: func(r *http.Request) *bool {
RequestSampler: func(*http.Request) *bool {
return nil
},
ExpectedSampling: "0",
Expand Down
6 changes: 3 additions & 3 deletions reporter/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func generateSpans(n int) []*model.SpanModel {

func newTestServer(t *testing.T, spans []*model.SpanModel, serializer reporter.SpanSerializer, onReceive func(int)) *httptest.Server {
sofar := 0
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
return httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
t.Errorf("expected 'POST' request, got '%s'", r.Method)
}
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestSpanCustomHeaders(t *testing.T) {
},
}
var haveHeaders http.Header
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
haveHeaders = r.Header
}))
defer ts.Close()
Expand Down Expand Up @@ -207,7 +207,7 @@ func TestB3SamplingHeader(t *testing.T) {
serializer := reporter.JSONSerializer{}

var haveHeaders map[string][]string
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
haveHeaders = r.Header
}))
defer ts.Close()
Expand Down
10 changes: 5 additions & 5 deletions span_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type SpanOption func(t *Tracer, s *spanImpl)

// Kind sets the kind of the span being created.
func Kind(kind model.Kind) SpanOption {
return func(t *Tracer, s *spanImpl) {
return func(_ *Tracer, s *spanImpl) {
s.Kind = kind
}
}
Expand Down Expand Up @@ -54,22 +54,22 @@ func Parent(sc model.SpanContext) SpanOption {

// StartTime uses a given start time for the span being created.
func StartTime(start time.Time) SpanOption {
return func(t *Tracer, s *spanImpl) {
return func(_ *Tracer, s *spanImpl) {
s.Timestamp = start
}
}

// RemoteEndpoint sets the remote endpoint of the span being created.
func RemoteEndpoint(e *model.Endpoint) SpanOption {
return func(t *Tracer, s *spanImpl) {
return func(_ *Tracer, s *spanImpl) {
s.RemoteEndpoint = e
}
}

// Tags sets initial tags for the span being created. If default tracer tags
// are present they will be overwritten on key collisions.
func Tags(tags map[string]string) SpanOption {
return func(t *Tracer, s *spanImpl) {
return func(_ *Tracer, s *spanImpl) {
for k, v := range tags {
s.Tags[k] = v
}
Expand All @@ -82,7 +82,7 @@ func Tags(tags map[string]string) SpanOption {
// This is available if late tag data is expected to be only available after the
// required finish time of the Span.
func FlushOnFinish(b bool) SpanOption {
return func(t *Tracer, s *spanImpl) {
return func(_ *Tracer, s *spanImpl) {
s.flushOnFinish = b
}
}

0 comments on commit a074cdb

Please sign in to comment.