Skip to content

Commit

Permalink
chore: update linter and Go
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Sep 6, 2024
1 parent b49c602 commit 63ed800
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
env:
GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.57.2
GOLANGCI_LINT_VERSION: v1.60.3
CGO_ENABLED: 0

steps:
Expand Down
21 changes: 8 additions & 13 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,18 @@ linters-settings:
linters:
enable-all: true
disable:
- scopelint # deprecated
- interfacer # deprecated
- maligned # deprecated
- golint # deprecated
- exhaustivestruct # deprecated
- scopelint # deprecated
- varcheck # deprecated
- structcheck # deprecated
- nosnakecase # deprecated
- deadcode # deprecated
- ifshort # deprecated
- execinquery # deprecated
- exportloopref # deprecated
- gomnd # deprecated
- sqlclosecheck # not relevant (SQL)
- rowserrcheck # not relevant (SQL)
- cyclop # duplicate of gocyclo
- lll
- dupl
- wsl
- nlreturn
- gomnd
- goerr113
- mnd
- err113
- wrapcheck
- exhaustive
- exhaustruct
Expand All @@ -99,3 +91,6 @@ issues:
linters:
- funlen
- noctx

output:
show-stats: true
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/traefik/mocktail

go 1.21
go 1.22.0

require (
github.com/ettle/strcase v0.2.0
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.9.0
)

require (
Expand Down
11 changes: 2 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q=
github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions mocktail.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func walk(root, moduleName string) (map[string]PackageDesc, error) {
return fmt.Errorf("type %q in %q is not an interface", lookup.Type(), fp)
}

for i := 0; i < interfaceType.NumMethods(); i++ {
for i := range interfaceType.NumMethods() {
method := interfaceType.Method(i)

interfaceDesc.Methods = append(interfaceDesc.Methods, method)
Expand Down Expand Up @@ -197,7 +197,7 @@ func getTupleImports(tuples ...*types.Tuple) []string {
var imports []string

for _, tuple := range tuples {
for i := 0; i < tuple.Len(); i++ {
for i := range tuple.Len() {
imports = append(imports, getTypeImports(tuple.At(i).Type())...)
}
}
Expand Down
26 changes: 13 additions & 13 deletions syrup.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (s Syrup) mockedMethod(writer io.Writer) error {
params := s.Signature.Params()

var argNames []string
for i := 0; i < params.Len(); i++ {
for i := range params.Len() {
param := params.At(i)

if param.Type().String() == contextType {
Expand All @@ -147,7 +147,7 @@ func (s Syrup) mockedMethod(writer io.Writer) error {
w.Print("(")
}

for i := 0; i < results.Len(); i++ {
for i := range results.Len() {
w.Print(s.getTypeName(results.At(i).Type(), false))
if i+1 < results.Len() {
w.Print(", ")
Expand All @@ -168,7 +168,7 @@ func (s Syrup) mockedMethod(writer io.Writer) error {

s.writeReturnsFnCaller(w, argNames, params, results)

for i := 0; i < results.Len(); i++ {
for i := range results.Len() {
if i == 0 {
w.Println()
}
Expand All @@ -186,7 +186,7 @@ func (s Syrup) mockedMethod(writer io.Writer) error {
}
}

for i := 0; i < results.Len(); i++ {
for i := range results.Len() {
if i == 0 {
w.Println()
w.Print("\treturn ")
Expand Down Expand Up @@ -230,7 +230,7 @@ func (s Syrup) methodOn(writer io.Writer) error {
params := s.Signature.Params()

var argNames []string
for i := 0; i < params.Len(); i++ {
for i := range params.Len() {
param := params.At(i)

if param.Type().String() == contextType {
Expand Down Expand Up @@ -276,7 +276,7 @@ func (s Syrup) methodOnRaw(writer io.Writer) error {
params := s.Signature.Params()

var argNames []string
for i := 0; i < params.Len(); i++ {
for i := range params.Len() {
param := params.At(i)

if param.Type().String() == contextType {
Expand Down Expand Up @@ -374,7 +374,7 @@ func (s Syrup) typedReturns(writer io.Writer) error {
w.Printf("func (_c *%s%sCall) TypedReturns(", structBaseName, s.Method.Name())

var returnNames string
for i := 0; i < results.Len(); i++ {
for i := range results.Len() {
rName := string(rune(int('a') + i))

w.Printf("%s %s", rName, s.getTypeName(results.At(i).Type(), false))
Expand Down Expand Up @@ -408,7 +408,7 @@ func (s Syrup) typedRun(writer io.Writer) error {

var pos int
var paramNames []string
for i := 0; i < params.Len(); i++ {
for i := range params.Len() {
param := params.At(i)
pType := param.Type()

Expand Down Expand Up @@ -479,7 +479,7 @@ func (s Syrup) callMethodsOn(writer io.Writer, methods []*types.Func) error {
params := sign.Params()

var argNames []string
for i := 0; i < params.Len(); i++ {
for i := range params.Len() {
param := params.At(i)

if param.Type().String() == contextType {
Expand Down Expand Up @@ -525,7 +525,7 @@ func (s Syrup) callMethodOnRaw(writer io.Writer, methods []*types.Func) error {
params := sign.Params()

var argNames []string
for i := 0; i < params.Len(); i++ {
for i := range params.Len() {
param := params.At(i)

if param.Type().String() == contextType {
Expand Down Expand Up @@ -603,7 +603,7 @@ func (s Syrup) getTypeName(t types.Type, last bool) string {

func (s Syrup) getTupleTypes(t *types.Tuple) []string {
var tupleTypes []string
for i := 0; i < t.Len(); i++ {
for i := range t.Len() {
param := t.At(i)

tupleTypes = append(tupleTypes, s.getTypeName(param.Type(), false))
Expand Down Expand Up @@ -645,7 +645,7 @@ func (s Syrup) getChanTypeName(t *types.Chan) string {

func (s Syrup) createFuncSignature(params, results *types.Tuple) string {
fnSign := "func("
for i := 0; i < params.Len(); i++ {
for i := range params.Len() {
param := params.At(i)
if param.Type().String() == contextType {
continue
Expand All @@ -661,7 +661,7 @@ func (s Syrup) createFuncSignature(params, results *types.Tuple) string {

if results != nil {
fnSign += "("
for i := 0; i < results.Len(); i++ {
for i := range results.Len() {
rType := results.At(i).Type()
fnSign += s.getTypeName(rType, false)
if i+1 < results.Len() {
Expand Down

0 comments on commit 63ed800

Please sign in to comment.