Skip to content

Commit

Permalink
Merge pull request #269 from fredbi/chore/update-linting
Browse files Browse the repository at this point in the history
chore: relint & update
  • Loading branch information
casualjim committed Dec 8, 2023
2 parents 1ade6d4 + e4cc157 commit 381952b
Show file tree
Hide file tree
Showing 72 changed files with 2,145 additions and 1,897 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/ci.yaml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/go-test.yml
@@ -0,0 +1,50 @@
name: go test

on: [push, pull_request]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: stable
check-latest: true
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
only-new-issues: true

test:
name: Unit tests
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
go_version: ['oldstable', 'stable' ]

steps:
- name: Run unit tests
uses: actions/setup-go@v4
with:
go-version: '${{ matrix.go_version }}'
check-latest: true
cache: true

- uses: actions/checkout@v3

- run: go test -v -race -coverprofile="coverage-${{ matrix.os }}.${{ matrix.go_version }}.out" -covermode=atomic ./...

- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
files: './coverage-${{ matrix.os }}.${{ matrix.go_version }}.out'
flags: '${{ matrix.go_version }}'
os: '${{ matrix.os }}'
fail_ci_if_error: false
verbose: true
12 changes: 0 additions & 12 deletions .github/workflows/lint.yaml

This file was deleted.

56 changes: 37 additions & 19 deletions .golangci.yml
@@ -1,44 +1,62 @@
linters-settings:
govet:
# Using err repeatedly considered as shadowing.
check-shadowing: false
check-shadowing: true
golint:
min-confidence: 0
gocyclo:
min-complexity: 30
min-complexity: 45
maligned:
suggest-new: true
dupl:
threshold: 100
threshold: 200
goconst:
min-len: 2
min-occurrences: 4
min-occurrences: 3

linters:
enable-all: true
disable:
- nilerr # nilerr crashes on this repo
- maligned
- unparam
- lll
- gochecknoinits
- gochecknoglobals
- funlen
- godox
- gocognit
- whitespace
- wsl
- funlen
- gochecknoglobals
- gochecknoinits
- scopelint
- wrapcheck
- exhaustivestruct
- exhaustive
- nlreturn
- testpackage
- gci
- gofumpt
- goerr113
- nlreturn
- gomnd
- tparallel
- exhaustivestruct
- goerr113
- errorlint
- nestif
- godot
- errorlint
- noctx
- gofumpt
- paralleltest
- tparallel
- thelper
- ifshort
- exhaustruct
- varnamelen
- gci
- depguard
- errchkjson
- inamedparam
- nonamedreturns
- musttag
- ireturn
- forcetypeassert
- cyclop
# deprecated linters
- deadcode
- interfacer
- nilerr
- scopelint
- varcheck
- structcheck
- golint
- nosnakecase
11 changes: 7 additions & 4 deletions README.md
@@ -1,7 +1,10 @@
# 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)
# 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)

[![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)
[![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io)
[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/runtime/master/LICENSE)
[![Go Reference](https://pkg.go.dev/badge/github.com/go-openapi/runtime.svg)](https://pkg.go.dev/github.com/go-openapi/runtime)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/runtime)](https://goreportcard.com/report/github.com/go-openapi/runtime)

# golang Open-API toolkit - runtime
# go OpenAPI toolkit runtime

The runtime component for use in codegeneration or as untyped usage.
The runtime component for use in code generation or as untyped usage.
10 changes: 6 additions & 4 deletions authinfo_test.go
Expand Up @@ -19,15 +19,17 @@ import (

"github.com/go-openapi/strfmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestAuthInfoWriter(t *testing.T) {
const bearerToken = "Bearer the-token-goes-here"

hand := ClientAuthInfoWriterFunc(func(r ClientRequest, _ strfmt.Registry) error {
return r.SetHeaderParam(HeaderAuthorization, "Bearer the-token-goes-here")
return r.SetHeaderParam(HeaderAuthorization, bearerToken)
})

tr := new(TestClientRequest)
err := hand.AuthenticateRequest(tr, nil)
assert.NoError(t, err)
assert.Equal(t, "Bearer the-token-goes-here", tr.Headers.Get(HeaderAuthorization))
require.NoError(t, hand.AuthenticateRequest(tr, nil))
assert.Equal(t, bearerToken, tr.Headers.Get(HeaderAuthorization))
}
8 changes: 4 additions & 4 deletions bytestream.go
Expand Up @@ -52,10 +52,10 @@ func ByteStreamConsumer(opts ...byteStreamOpt) Consumer {
return errors.New("ByteStreamConsumer requires a reader") // early exit
}

close := defaultCloser
close := defaultCloser //nolint:revive,predeclared
if vals.Close {
if cl, ok := reader.(io.Closer); ok {
close = cl.Close
close = cl.Close //nolint:revive
}
}
//nolint:errcheck // closing a reader wouldn't fail.
Expand Down Expand Up @@ -109,10 +109,10 @@ func ByteStreamProducer(opts ...byteStreamOpt) Producer {
if writer == nil {
return errors.New("ByteStreamProducer requires a writer") // early exit
}
close := defaultCloser
close := defaultCloser //nolint:revive,predeclared
if vals.Close {
if cl, ok := writer.(io.Closer); ok {
close = cl.Close
close = cl.Close //nolint:revive
}
}
//nolint:errcheck // TODO: closing a writer would fail.
Expand Down

0 comments on commit 381952b

Please sign in to comment.