From d31579e46fbd77fd8f61a17b7b4ffaf16897a527 Mon Sep 17 00:00:00 2001 From: Tronje Krop Date: Thu, 9 Nov 2023 10:03:50 +0100 Subject: [PATCH] feat: update deps and linter issues (#56) Signed-off-by: tkrop --- .golangci.yaml | 15 ++++++++++++--- README.md | 6 +++--- go.mod | 8 ++++---- go.sum | 20 ++++++++++---------- internal/mock/builder_test.go | 2 +- internal/mock/models.go | 1 + mock/mock.go | 1 + revive.toml | 9 +++++++++ 8 files changed, 41 insertions(+), 21 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index aefaf4c..fe2c6f6 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -3,7 +3,7 @@ run: # Default: 1m timeout: 3m -linters: +linters: {} # Placeholder for dynamically enabled linters. issues: @@ -35,7 +35,7 @@ issues: linters: [ errcheck ] # Exclude certain revive standards from being applied in tests. - path: "_test\\.go" - text: "^(max-public-structs|function-length|cognitive-complexity):" + text: "^(max-public-structs|function-length|cognitive-complexity|unchecked-type-assertion):" linters: [ revive ] # Exclude dots in unfinished thoughts. - source: "(noinspection|TODO)" @@ -96,7 +96,7 @@ linters-settings: # To specify a set of rules to explicitly exclude. # Available rules: https://github.com/securego/gosec#available-rules # Default: [] (issues are fixed) - excludes: [ G105, G307 ] + excludes: [ G307 ] gocritic: # Settings passed to gocritic. The settings key is the name of a supported @@ -142,9 +142,18 @@ linters-settings: # Reports on comments not matching the name as first word. - name: exported disabled: true + # Ident error flow is buggy and throws false alerts. + - name: indent-error-flow + disabled: true # No need to exclude import shadowing. - name: import-shadowing disabled: true + # Restricted alias naming conflicts with '.'-imports. + - name: import-alias-naming + disabled: true + # Exluding '.'-import makes test package separation unnecessary difficult. + - name: dot-imports + disabled: true # Fails to exclude nolint directives from reporting. - name: comment-spacings disabled: true diff --git a/README.md b/README.md index 643174a..a9a41c3 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,10 @@ [coveralls-link]: https://coveralls.io/github/tkrop/go-testing?branch=main [coverage-badge]: https://app.codacy.com/project/badge/Coverage/cc1c47ec5ce0493caf15c08fa72fc78c -[coverage-link]: https://www.codacy.com/gh/tkrop/go-testing/dashboard?utm_source=github.com&utm_medium=referral&utm_content=tkrop/go-testing&utm_campaign=Badge_Coverage +[coverage-link]: https://app.codacy.com/gh/tkrop/go-testing/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage [quality-badge]: https://app.codacy.com/project/badge/Grade/cc1c47ec5ce0493caf15c08fa72fc78c -[quality-link]: https://www.codacy.com/gh/tkrop/go-testing/dashboard?utm_source=github.com&utm_medium=referral&utm_content=tkrop/go-testing&utm_campaign=Badge_Grade +[quality-link]: https://app.codacy.com/gh/tkrop/go-testing/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade [report-badge]: https://goreportcard.com/badge/github.com/tkrop/go-testing [report-link]: https://goreportcard.com/report/github.com/tkrop/go-testing @@ -243,7 +243,7 @@ implementations for most common tasks. Read the [go-make manual][go-make-man] for more information about how to build, test, lint, etc. [go-make]: -[go-make-man]: +[go-make-man]: ## Contributing diff --git a/go.mod b/go.mod index 80c0b9f..ecabccd 100644 --- a/go.mod +++ b/go.mod @@ -9,9 +9,9 @@ require ( github.com/h2non/gock v1.2.0 github.com/huandu/go-clone v1.6.0 github.com/stretchr/testify v1.8.4 - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 + golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 golang.org/x/text v0.13.0 - golang.org/x/tools v0.13.0 + golang.org/x/tools v0.15.0 ) require ( @@ -19,8 +19,8 @@ require ( github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/mod v0.12.0 // indirect - golang.org/x/sys v0.12.0 // indirect + golang.org/x/mod v0.14.0 // indirect + golang.org/x/sys v0.14.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index bee3f0d..207ec5c 100644 --- a/go.sum +++ b/go.sum @@ -33,25 +33,25 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 h1:mchzmB1XO2pMaKFRqk/+MV3mgGG96aqaPXaMifQU47w= +golang.org/x/exp v0.0.0-20231108232855-2478ac86f678/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -60,8 +60,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= +golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/mock/builder_test.go b/internal/mock/builder_test.go index 9428b8e..9f17e3f 100644 --- a/internal/mock/builder_test.go +++ b/internal/mock/builder_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" . "github.com/tkrop/go-testing/internal/mock" - mock "github.com/tkrop/go-testing/mock" + "github.com/tkrop/go-testing/mock" "github.com/tkrop/go-testing/test" ) diff --git a/internal/mock/models.go b/internal/mock/models.go index 4d8f38e..45cadfd 100644 --- a/internal/mock/models.go +++ b/internal/mock/models.go @@ -195,6 +195,7 @@ func NewMethods(iface *types.Interface) []*Method { methods := make([]*Method, 0, iface.NumMethods()) for index := 0; index < iface.NumMethods(); index++ { method := iface.Method(index) + //revive:disable-next-line:unchecked-type-assertion // cannot happen sign := method.Type().Underlying().(*types.Signature) methods = append(methods, &Method{ Name: method.Name(), diff --git a/mock/mock.go b/mock/mock.go index 522f8ac..3f2d898 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -273,6 +273,7 @@ func (mocks *Mocks) notify( // Get resolves the actual mock from the mock handler by providing the // constructor function generated by `gomock` to create a new mock. func Get[T any](mocks *Mocks, creator func(*Controller) *T) *T { + //revive:disable-next-line:unchecked-type-assertion // cannot happen return mocks.Get(reflect.ValueOf(creator)).(*T) } diff --git a/revive.toml b/revive.toml index 4cb6f64..e47f887 100644 --- a/revive.toml +++ b/revive.toml @@ -35,6 +35,15 @@ enableAllRules = true [rule.import-shadowing] disabled = true +# Restricted alias naming conflicts with '.'-imports. +# Not supporte by current Codacy revive v1.2.3 +#[rule.import-alias-naming] +# disabled = true + +# Exluding '.'-import makes test package separation unnecessary difficult. +[rule.dot-imports] + disabled = true + # Fails to exclude nolint directives from reporting. # Not supporte by current Codacy revive v1.2.3 #[rule.comment-spacings]