Skip to content

Commit e4cc157

Browse files
committed
chore: relint & update
* updated go version requirement to go1.19 * updated dependencies, excepted: * yaml (upgrade to v3 deferred to another PR) * otel (upgrade is breaking: deferred to another PR) * ci: updated linting rules, in line with other go-openapi repos * exception: disabled the "nilerr" linter, which currently crashes for this repo * ci:updated github actions, in line with other go-openapi repos * doc: updated README links and badges * major relinting of all test code * relinting non-test code is deferred to another PR (hopefully with less changes) * changes to non-test code are limited to: * addition of (temporary) nolint directives * gofmt/typos in comments * unused params TODO in forthcoming PRs: * [ ] upgrade to yaml/v3 * [ ] upgrade OTEL packages * [ ] gradually remove most "nolint" directives in non-test code * [ ] complete test refactoring: some nolint directives have been added to skip more complex refacoring (e.g. duplicate code) Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent 1ade6d4 commit e4cc157

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2145
-1897
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/go-test.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: go test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
name: Lint
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-go@v4
12+
with:
13+
go-version: stable
14+
check-latest: true
15+
cache: true
16+
- name: golangci-lint
17+
uses: golangci/golangci-lint-action@v3
18+
with:
19+
version: latest
20+
only-new-issues: true
21+
22+
test:
23+
name: Unit tests
24+
runs-on: ${{ matrix.os }}
25+
26+
strategy:
27+
matrix:
28+
os: [ ubuntu-latest, macos-latest, windows-latest ]
29+
go_version: ['oldstable', 'stable' ]
30+
31+
steps:
32+
- name: Run unit tests
33+
uses: actions/setup-go@v4
34+
with:
35+
go-version: '${{ matrix.go_version }}'
36+
check-latest: true
37+
cache: true
38+
39+
- uses: actions/checkout@v3
40+
41+
- run: go test -v -race -coverprofile="coverage-${{ matrix.os }}.${{ matrix.go_version }}.out" -covermode=atomic ./...
42+
43+
- name: Upload coverage to codecov
44+
uses: codecov/codecov-action@v3
45+
with:
46+
files: './coverage-${{ matrix.os }}.${{ matrix.go_version }}.out'
47+
flags: '${{ matrix.go_version }}'
48+
os: '${{ matrix.os }}'
49+
fail_ci_if_error: false
50+
verbose: true

.github/workflows/lint.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.golangci.yml

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,62 @@
11
linters-settings:
22
govet:
3-
# Using err repeatedly considered as shadowing.
4-
check-shadowing: false
3+
check-shadowing: true
54
golint:
65
min-confidence: 0
76
gocyclo:
8-
min-complexity: 30
7+
min-complexity: 45
98
maligned:
109
suggest-new: true
1110
dupl:
12-
threshold: 100
11+
threshold: 200
1312
goconst:
1413
min-len: 2
15-
min-occurrences: 4
14+
min-occurrences: 3
15+
1616
linters:
17+
enable-all: true
1718
disable:
19+
- nilerr # nilerr crashes on this repo
1820
- maligned
21+
- unparam
1922
- lll
23+
- gochecknoinits
2024
- gochecknoglobals
25+
- funlen
2126
- godox
2227
- gocognit
2328
- whitespace
2429
- wsl
25-
- funlen
26-
- gochecknoglobals
27-
- gochecknoinits
28-
- scopelint
2930
- wrapcheck
30-
- exhaustivestruct
31-
- exhaustive
32-
- nlreturn
3331
- testpackage
34-
- gci
35-
- gofumpt
36-
- goerr113
32+
- nlreturn
3733
- gomnd
38-
- tparallel
34+
- exhaustivestruct
35+
- goerr113
36+
- errorlint
3937
- nestif
4038
- godot
41-
- errorlint
42-
- noctx
39+
- gofumpt
40+
- paralleltest
41+
- tparallel
42+
- thelper
43+
- ifshort
44+
- exhaustruct
45+
- varnamelen
46+
- gci
47+
- depguard
48+
- errchkjson
49+
- inamedparam
50+
- nonamedreturns
51+
- musttag
52+
- ireturn
53+
- forcetypeassert
54+
- cyclop
55+
# deprecated linters
56+
- deadcode
4357
- interfacer
44-
- nilerr
58+
- scopelint
59+
- varcheck
60+
- structcheck
61+
- golint
62+
- nosnakecase

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
# runtime [![Build Status](https://travis-ci.org/go-openapi/runtime.svg?branch=client-context)](https://travis-ci.org/go-openapi/runtime) [![codecov](https://codecov.io/gh/go-openapi/runtime/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/runtime) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io)
1+
# runtime [![Build Status](https://github.com/go-openapi/runtime/actions/workflows/go-test.yml/badge.svg)](https://github.com/go-openapi/runtime/actions?query=workflow%3A"go+test") [![codecov](https://codecov.io/gh/go-openapi/runtime/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/runtime)
22

3-
[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/runtime/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/runtime?status.svg)](http://godoc.org/github.com/go-openapi/runtime)
3+
[![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io)
4+
[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/runtime/master/LICENSE)
5+
[![Go Reference](https://pkg.go.dev/badge/github.com/go-openapi/runtime.svg)](https://pkg.go.dev/github.com/go-openapi/runtime)
6+
[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/runtime)](https://goreportcard.com/report/github.com/go-openapi/runtime)
47

5-
# golang Open-API toolkit - runtime
8+
# go OpenAPI toolkit runtime
69

7-
The runtime component for use in codegeneration or as untyped usage.
10+
The runtime component for use in code generation or as untyped usage.

authinfo_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ import (
1919

2020
"github.com/go-openapi/strfmt"
2121
"github.com/stretchr/testify/assert"
22+
"github.com/stretchr/testify/require"
2223
)
2324

2425
func TestAuthInfoWriter(t *testing.T) {
26+
const bearerToken = "Bearer the-token-goes-here"
27+
2528
hand := ClientAuthInfoWriterFunc(func(r ClientRequest, _ strfmt.Registry) error {
26-
return r.SetHeaderParam(HeaderAuthorization, "Bearer the-token-goes-here")
29+
return r.SetHeaderParam(HeaderAuthorization, bearerToken)
2730
})
2831

2932
tr := new(TestClientRequest)
30-
err := hand.AuthenticateRequest(tr, nil)
31-
assert.NoError(t, err)
32-
assert.Equal(t, "Bearer the-token-goes-here", tr.Headers.Get(HeaderAuthorization))
33+
require.NoError(t, hand.AuthenticateRequest(tr, nil))
34+
assert.Equal(t, bearerToken, tr.Headers.Get(HeaderAuthorization))
3335
}

bytestream.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ func ByteStreamConsumer(opts ...byteStreamOpt) Consumer {
5252
return errors.New("ByteStreamConsumer requires a reader") // early exit
5353
}
5454

55-
close := defaultCloser
55+
close := defaultCloser //nolint:revive,predeclared
5656
if vals.Close {
5757
if cl, ok := reader.(io.Closer); ok {
58-
close = cl.Close
58+
close = cl.Close //nolint:revive
5959
}
6060
}
6161
//nolint:errcheck // closing a reader wouldn't fail.
@@ -109,10 +109,10 @@ func ByteStreamProducer(opts ...byteStreamOpt) Producer {
109109
if writer == nil {
110110
return errors.New("ByteStreamProducer requires a writer") // early exit
111111
}
112-
close := defaultCloser
112+
close := defaultCloser //nolint:revive,predeclared
113113
if vals.Close {
114114
if cl, ok := writer.(io.Closer); ok {
115-
close = cl.Close
115+
close = cl.Close //nolint:revive
116116
}
117117
}
118118
//nolint:errcheck // TODO: closing a writer would fail.

0 commit comments

Comments
 (0)