diff --git a/tools/go.mod b/tools/go.mod index 932ef26cd3..bf057e95f1 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -4,7 +4,7 @@ go 1.22.1 require ( github.com/cfergeau/gomod2rpmdeps v0.0.0-20210223144124-2042c4850ca8 - github.com/golangci/golangci-lint v1.62.0 + github.com/golangci/golangci-lint v1.62.2 github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 golang.org/x/tools v0.27.0 ) @@ -16,9 +16,9 @@ require ( github.com/Abirdcfly/dupword v0.1.3 // indirect github.com/Antonboom/errname v1.0.0 // indirect github.com/Antonboom/nilnil v1.0.0 // indirect - github.com/Antonboom/testifylint v1.5.0 // indirect + github.com/Antonboom/testifylint v1.5.2 // indirect github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect - github.com/Crocmagnon/fatcontext v0.5.2 // indirect + github.com/Crocmagnon/fatcontext v0.5.3 // indirect github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 // indirect github.com/Masterminds/semver/v3 v3.3.0 // indirect @@ -108,19 +108,19 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mgechev/revive v1.5.0 // indirect + github.com/mgechev/revive v1.5.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moricho/tparallel v0.3.2 // indirect github.com/nakabonne/nestif v0.3.1 // indirect github.com/nishanths/exhaustive v0.12.0 // indirect github.com/nishanths/predeclared v0.2.2 // indirect - github.com/nunnatsa/ginkgolinter v0.18.0 // indirect + github.com/nunnatsa/ginkgolinter v0.18.3 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/polyfloyd/go-errorlint v1.6.0 // indirect + github.com/polyfloyd/go-errorlint v1.7.0 // indirect github.com/prometheus/client_golang v1.12.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect @@ -155,7 +155,7 @@ require ( github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect github.com/stretchr/objx v0.5.2 // indirect - github.com/stretchr/testify v1.9.0 // indirect + github.com/stretchr/testify v1.10.0 // indirect github.com/subosito/gotenv v1.4.1 // indirect github.com/tdakkota/asciicheck v0.2.0 // indirect github.com/tetafro/godot v1.4.18 // indirect @@ -166,7 +166,7 @@ require ( github.com/ultraware/funlen v0.1.0 // indirect github.com/ultraware/whitespace v0.1.1 // indirect github.com/uudashr/gocognit v1.1.3 // indirect - github.com/uudashr/iface v1.2.0 // indirect + github.com/uudashr/iface v1.2.1 // indirect github.com/xen0n/gosmopolitan v1.2.2 // indirect github.com/yagipy/maintidx v1.0.0 // indirect github.com/yeya24/promlinter v0.3.0 // indirect @@ -179,7 +179,7 @@ require ( go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect - golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0 // indirect + golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect golang.org/x/mod v0.22.0 // indirect golang.org/x/sync v0.9.0 // indirect golang.org/x/sys v0.27.0 // indirect diff --git a/tools/go.sum b/tools/go.sum index 4da01c2894..2461cddec7 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -43,14 +43,14 @@ github.com/Antonboom/errname v1.0.0 h1:oJOOWR07vS1kRusl6YRSlat7HFnb3mSfMl6sDMRoT github.com/Antonboom/errname v1.0.0/go.mod h1:gMOBFzK/vrTiXN9Oh+HFs+e6Ndl0eTFbtsRTSRdXyGI= github.com/Antonboom/nilnil v1.0.0 h1:n+v+B12dsE5tbAqRODXmEKfZv9j2KcTBrp+LkoM4HZk= github.com/Antonboom/nilnil v1.0.0/go.mod h1:fDJ1FSFoLN6yoG65ANb1WihItf6qt9PJVTn/s2IrcII= -github.com/Antonboom/testifylint v1.5.0 h1:dlUIsDMtCrZWUnvkaCz3quJCoIjaGi41GzjPBGkkJ8A= -github.com/Antonboom/testifylint v1.5.0/go.mod h1:wqaJbu0Blb5Wag2wv7Z5xt+CIV+eVLxtGZrlK13z3AE= +github.com/Antonboom/testifylint v1.5.2 h1:4s3Xhuv5AvdIgbd8wOOEeo0uZG7PbDKQyKY5lGoQazk= +github.com/Antonboom/testifylint v1.5.2/go.mod h1:vxy8VJ0bc6NavlYqjZfmp6EfqXMtBgQ4+mhCojwC1P8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/Crocmagnon/fatcontext v0.5.2 h1:vhSEg8Gqng8awhPju2w7MKHqMlg4/NI+gSDHtR3xgwA= -github.com/Crocmagnon/fatcontext v0.5.2/go.mod h1:87XhRMaInHP44Q7Tlc7jkgKKB7kZAOPiDkFMdKCC+74= +github.com/Crocmagnon/fatcontext v0.5.3 h1:zCh/wjc9oyeF+Gmp+V60wetm8ph2tlsxocgg/J0hOps= +github.com/Crocmagnon/fatcontext v0.5.3/go.mod h1:XoCQYY1J+XTfyv74qLXvNw4xFunr3L1wkopIIKG7wGM= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 h1:/fTUt5vmbkAcMBt4YQiuC23cV0kEsN1MVMNqeOW43cU= @@ -232,8 +232,8 @@ github.com/golangci/go-printf-func-name v0.1.0 h1:dVokQP+NMTO7jwO4bwsRwLWeudOVUP github.com/golangci/go-printf-func-name v0.1.0/go.mod h1:wqhWFH5mUdJQhweRnldEywnR5021wTdZSNgwYceV14s= github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9 h1:/1322Qns6BtQxUZDTAT4SdcoxknUki7IAoK4SAXr8ME= github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9/go.mod h1:Oesb/0uFAyWoaw1U1qS5zyjCg5NP9C9iwjnI4tIsXEE= -github.com/golangci/golangci-lint v1.62.0 h1:/G0g+bi1BhmGJqLdNQkKBWjcim8HjOPc4tsKuHDOhcI= -github.com/golangci/golangci-lint v1.62.0/go.mod h1:jtoOhQcKTz8B6dGNFyfQV3WZkQk+YvBDewDtNpiAJts= +github.com/golangci/golangci-lint v1.62.2 h1:b8K5K9PN+rZN1+mKLtsZHz2XXS9aYKzQ9i25x3Qnxxw= +github.com/golangci/golangci-lint v1.62.2/go.mod h1:ILWWyeFUrctpHVGMa1dg2xZPKoMUTc5OIMgW7HZr34g= github.com/golangci/misspell v0.6.0 h1:JCle2HUTNWirNlDIAUO44hUsKhOFqGPoC4LZxlaSXDs= github.com/golangci/misspell v0.6.0/go.mod h1:keMNyY6R9isGaSAu+4Q8NMBwMPkh15Gtc8UCVoDtAWo= github.com/golangci/modinfo v0.3.4 h1:oU5huX3fbxqQXdfspamej74DFX0kyGLkw1ppvXoJ8GA= @@ -371,8 +371,8 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6T github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mgechev/revive v1.5.0 h1:oaSmjA7rP8+HyoRuCgC531VHwnLH1AlJdjj+1AnQceQ= -github.com/mgechev/revive v1.5.0/go.mod h1:L6T3H8EoerRO86c7WuGpvohIUmiploGiyoYbtIWFmV8= +github.com/mgechev/revive v1.5.1 h1:hE+QPeq0/wIzJwOphdVyUJ82njdd8Khp4fUIHGZHW3M= +github.com/mgechev/revive v1.5.1/go.mod h1:lC9AhkJIBs5zwx8wkudyHrU+IJkrEKmpCmGMnIJPk4o= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= @@ -392,8 +392,8 @@ github.com/nishanths/exhaustive v0.12.0 h1:vIY9sALmw6T/yxiASewa4TQcFsVYZQQRUQJhK github.com/nishanths/exhaustive v0.12.0/go.mod h1:mEZ95wPIZW+x8kC4TgC+9YCUgiST7ecevsVDTgc2obs= github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= -github.com/nunnatsa/ginkgolinter v0.18.0 h1:ZXO1wKhPg3A6LpbN5dMuqwhfOjN5c3ous8YdKOuqk9k= -github.com/nunnatsa/ginkgolinter v0.18.0/go.mod h1:vPrWafSULmjMGCMsfGA908if95VnHQNAahvSBOjTuWs= +github.com/nunnatsa/ginkgolinter v0.18.3 h1:WgS7X3zzmni3vwHSBhvSgqrRgUecN6PQUcfB0j1noDw= +github.com/nunnatsa/ginkgolinter v0.18.3/go.mod h1:BE1xyB/PNtXXG1azrvrqJW5eFH0hSRylNzFy8QHPwzs= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= @@ -417,8 +417,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/polyfloyd/go-errorlint v1.6.0 h1:tftWV9DE7txiFzPpztTAwyoRLKNj9gpVm2cg8/OwcYY= -github.com/polyfloyd/go-errorlint v1.6.0/go.mod h1:HR7u8wuP1kb1NeN1zqTd1ZMlqUKPPHF+Id4vIPvDqVw= +github.com/polyfloyd/go-errorlint v1.7.0 h1:Zp6lzCK4hpBDj8y8a237YK4EPrMXQWvOe3nGoH4pFrU= +github.com/polyfloyd/go-errorlint v1.7.0/go.mod h1:dGWKu85mGHnegQ2SWpEybFityCg3j7ZbwsVUxAOk9gY= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -525,8 +525,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ 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.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -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= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/tdakkota/asciicheck v0.2.0 h1:o8jvnUANo0qXtnslk2d3nMKTFNlOnJjRrNcj0j9qkHM= @@ -551,8 +551,8 @@ github.com/ultraware/whitespace v0.1.1 h1:bTPOGejYFulW3PkcrqkeQwOd6NKOOXvmGD9bo/ github.com/ultraware/whitespace v0.1.1/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= github.com/uudashr/gocognit v1.1.3 h1:l+a111VcDbKfynh+airAy/DJQKaXh2m9vkoysMPSZyM= github.com/uudashr/gocognit v1.1.3/go.mod h1:aKH8/e8xbTRBwjbCkwZ8qt4l2EpKXl31KMHgSS+lZ2U= -github.com/uudashr/iface v1.2.0 h1:ECJjh5q/1Zmnv/2yFpWV6H3oMg5+Mo+vL0aqw9Gjazo= -github.com/uudashr/iface v1.2.0/go.mod h1:Ux/7d/rAF3owK4m53cTVXL4YoVHKNqnoOeQHn2xrlp0= +github.com/uudashr/iface v1.2.1 h1:vHHyzAUmWZ64Olq6NZT3vg/z1Ws56kyPdBOd5kTXDF8= +github.com/uudashr/iface v1.2.1/go.mod h1:4QvspiRd3JLPAEXBQ9AiZpLbJlrWWgRChOKDJEuQTdg= github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU= github.com/xen0n/gosmopolitan v1.2.2/go.mod h1:7XX7Mj61uLYrj0qmeN0zi7XDon9JRAEhYQqAPLVNTeg= github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM= @@ -613,8 +613,8 @@ golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWB golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0 h1:bVwtbF629Xlyxk6xLQq2TDYmqP0uiWaet5LwRebuY0k= -golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= +golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f h1:WTyX8eCCyfdqiPYkRGm0MqElSfYFH3yR1+rl/mct9sA= +golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/encoded_compare.go b/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/encoded_compare.go index 53c74ac453..1464fd640b 100644 --- a/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/encoded_compare.go +++ b/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/encoded_compare.go @@ -48,7 +48,7 @@ func (checker EncodedCompare) Check(pass *analysis.Pass, call *CallMeta) *analys switch { case aIsExplicitJSON, bIsExplicitJSON, isJSONStyleExpr(pass, a), isJSONStyleExpr(pass, b): proposed = "JSONEq" - case isYAMLStyleExpr(a), isYAMLStyleExpr(b): + case isYAMLStyleExpr(pass, a), isYAMLStyleExpr(pass, b): proposed = "YAMLEq" } diff --git a/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/formatter.go b/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/formatter.go index 896b6bf5fa..7ff4de470a 100644 --- a/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/formatter.go +++ b/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/formatter.go @@ -115,7 +115,11 @@ func (checker Formatter) checkFmtAssertion(pass *analysis.Pass, call *CallMeta) func isPrintfLikeCall(pass *analysis.Pass, call *CallMeta) (int, bool) { msgAndArgsPos := getMsgAndArgsPosition(call.Fn.Signature) - if msgAndArgsPos < 0 { + if msgAndArgsPos <= 0 { + return -1, false + } + + if !(len(call.ArgsRaw) > msgAndArgsPos && hasStringType(pass, call.ArgsRaw[msgAndArgsPos])) { return -1, false } @@ -123,7 +127,7 @@ func isPrintfLikeCall(pass *analysis.Pass, call *CallMeta) (int, bool) { return -1, false } - return msgAndArgsPos, len(call.ArgsRaw) > msgAndArgsPos + return msgAndArgsPos, true } func assertHasFormattedAnalogue(pass *analysis.Pass, call *CallMeta) bool { diff --git a/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_basic_type.go b/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_basic_type.go index 9b43e914cc..b4bb563219 100644 --- a/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_basic_type.go +++ b/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_basic_type.go @@ -166,6 +166,12 @@ func hasBytesType(pass *analysis.Pass, e ast.Expr) bool { return ok && el.Kind() == types.Uint8 } +// hasStringType returns true if the expression is of `string` type. +func hasStringType(pass *analysis.Pass, e ast.Expr) bool { + basicType, ok := pass.TypesInfo.TypeOf(e).(*types.Basic) + return ok && basicType.Kind() == types.String +} + // untype returns v from type(v) expression or v itself if there is no type conversion. func untype(e ast.Expr) ast.Expr { ce, ok := e.(*ast.CallExpr) diff --git a/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_encoded.go b/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_encoded.go index 35a497a724..c366f85635 100644 --- a/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_encoded.go +++ b/tools/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_encoded.go @@ -11,13 +11,15 @@ import ( ) var ( + wordsRe = regexp.MustCompile(`[A-Z]+(?:[a-z]*|$)|[a-z]+`) // NOTE(a.telyshev): ChatGPT. + jsonIdentRe = regexp.MustCompile(`json|JSON|Json`) - yamlIdentRe = regexp.MustCompile(`yaml|YAML|Yaml|yml|YML|Yml`) + yamlWordRe = regexp.MustCompile(`yaml|YAML|Yaml|^(yml|YML|Yml)$`) ) func isJSONStyleExpr(pass *analysis.Pass, e ast.Expr) bool { if isIdentNamedAfterPattern(jsonIdentRe, e) { - return true + return hasBytesType(pass, e) || hasStringType(pass, e) } if t, ok := pass.TypesInfo.Types[e]; ok && t.Value != nil { @@ -35,6 +37,20 @@ func isJSONStyleExpr(pass *analysis.Pass, e ast.Expr) bool { return false } -func isYAMLStyleExpr(e ast.Expr) bool { - return isIdentNamedAfterPattern(yamlIdentRe, e) +func isYAMLStyleExpr(pass *analysis.Pass, e ast.Expr) bool { + id, ok := e.(*ast.Ident) + return ok && (hasBytesType(pass, e) || hasStringType(pass, e)) && hasWordAfterPattern(id.Name, yamlWordRe) +} + +func hasWordAfterPattern(s string, re *regexp.Regexp) bool { + for _, w := range splitIntoWords(s) { + if re.MatchString(w) { + return true + } + } + return false +} + +func splitIntoWords(s string) []string { + return wordsRe.FindAllString(s, -1) } diff --git a/tools/vendor/github.com/Antonboom/testifylint/internal/config/config.go b/tools/vendor/github.com/Antonboom/testifylint/internal/config/config.go index a8812e6d01..23b673428e 100644 --- a/tools/vendor/github.com/Antonboom/testifylint/internal/config/config.go +++ b/tools/vendor/github.com/Antonboom/testifylint/internal/config/config.go @@ -133,7 +133,7 @@ func BindToFlags(cfg *Config, fs *flag.FlagSet) { "to enable go vet's printf checks") fs.BoolVar(&cfg.Formatter.RequireFFuncs, "formatter.require-f-funcs", false, - "to require f-assertions if format string is used") + "to require f-assertions (e.g. assert.Equalf) if format string is used, even if there are no variable-length variables.") fs.BoolVar(&cfg.GoRequire.IgnoreHTTPHandlers, "go-require.ignore-http-handlers", false, diff --git a/tools/vendor/github.com/Crocmagnon/fatcontext/pkg/analyzer/analyzer.go b/tools/vendor/github.com/Crocmagnon/fatcontext/pkg/analyzer/analyzer.go index a65efbba89..7b88bf56e9 100644 --- a/tools/vendor/github.com/Crocmagnon/fatcontext/pkg/analyzer/analyzer.go +++ b/tools/vendor/github.com/Crocmagnon/fatcontext/pkg/analyzer/analyzer.go @@ -59,7 +59,7 @@ func run(pass *analysis.Pass) (interface{}, error) { { Pos: assignStmt.Pos(), End: assignStmt.End(), - NewText: []byte(suggested), + NewText: suggested, }, }, }) @@ -215,10 +215,10 @@ func getRootIdent(pass *analysis.Pass, node ast.Node) *ast.Ident { } // render returns the pretty-print of the given node -func render(fset *token.FileSet, x interface{}) (string, error) { +func render(fset *token.FileSet, x interface{}) ([]byte, error) { var buf bytes.Buffer if err := printer.Fprint(&buf, fset, x); err != nil { - return "", fmt.Errorf("printing node: %w", err) + return nil, fmt.Errorf("printing node: %w", err) } - return buf.String(), nil + return buf.Bytes(), nil } diff --git a/tools/vendor/github.com/golangci/golangci-lint/internal/go/cache/cache.go b/tools/vendor/github.com/golangci/golangci-lint/internal/go/cache/cache.go index 7bf4f1d660..85899ebc92 100644 --- a/tools/vendor/github.com/golangci/golangci-lint/internal/go/cache/cache.go +++ b/tools/vendor/github.com/golangci/golangci-lint/internal/go/cache/cache.go @@ -293,7 +293,7 @@ func GetBytes(c Cache, id ActionID) ([]byte, Entry, error) { } data, err := robustio.ReadFile(c.OutputFile(entry.OutputID)) if err != nil { - return nil, entry, err + return nil, entry, &entryNotFoundError{Err: err} } if sha256.Sum256(data) != entry.OutputID { return nil, entry, &entryNotFoundError{Err: errors.New("bad checksum")} diff --git a/tools/vendor/github.com/golangci/golangci-lint/pkg/result/processors/sort_results.go b/tools/vendor/github.com/golangci/golangci-lint/pkg/result/processors/sort_results.go index 4da73c72ea..7eebea6315 100644 --- a/tools/vendor/github.com/golangci/golangci-lint/pkg/result/processors/sort_results.go +++ b/tools/vendor/github.com/golangci/golangci-lint/pkg/result/processors/sort_results.go @@ -1,10 +1,9 @@ package processors import ( - "errors" + "cmp" "fmt" "slices" - "sort" "strings" "github.com/golangci/golangci-lint/pkg/config" @@ -22,24 +21,32 @@ const ( orderNameSeverity = "severity" ) +const ( + less = iota - 1 + equal + greater +) + var _ Processor = (*SortResults)(nil) +type issueComparator func(a, b *result.Issue) int + type SortResults struct { - cmps map[string]*comparator + cmps map[string][]issueComparator cfg *config.Output } func NewSortResults(cfg *config.Config) *SortResults { return &SortResults{ - cmps: map[string]*comparator{ + cmps: map[string][]issueComparator{ // For sorting we are comparing (in next order): // file names, line numbers, position, and finally - giving up. - orderNameFile: byFileName().SetNext(byLine().SetNext(byColumn())), + orderNameFile: {byFileName, byLine, byColumn}, // For sorting we are comparing: linter name - orderNameLinter: byLinter(), + orderNameLinter: {byLinter}, // For sorting we are comparing: severity - orderNameSeverity: bySeverity(), + orderNameSeverity: {bySeverity}, }, cfg: &cfg.Output, } @@ -57,23 +64,21 @@ func (p SortResults) Process(issues []result.Issue) ([]result.Issue, error) { p.cfg.SortOrder = []string{orderNameFile} } - var cmps []*comparator + var cmps []issueComparator + for _, name := range p.cfg.SortOrder { c, ok := p.cmps[name] if !ok { return nil, fmt.Errorf("unsupported sort-order name %q", name) } - cmps = append(cmps, c) + cmps = append(cmps, c...) } - cmp, err := mergeComparators(cmps) - if err != nil { - return nil, err - } + comp := mergeComparators(cmps...) - sort.Slice(issues, func(i, j int) bool { - return cmp.Compare(&issues[i], &issues[j]) == less + slices.SortFunc(issues, func(a, b result.Issue) int { + return comp(&a, &b) }) return issues, nil @@ -81,147 +86,32 @@ func (p SortResults) Process(issues []result.Issue) ([]result.Issue, error) { func (SortResults) Finish() {} -type compareResult int - -const ( - less compareResult = iota - 1 - equal - greater - none -) - -func (c compareResult) isNeutral() bool { - // return true if compare result is incomparable or equal. - return c == none || c == equal -} - -func (c compareResult) String() string { - switch c { - case less: - return "less" - case equal: - return "equal" - case greater: - return "greater" - default: - return "none" - } -} - -// comparator describes how to implement compare for two "issues". -type comparator struct { - name string - compare func(a, b *result.Issue) compareResult - next *comparator -} - -func (cmp *comparator) Next() *comparator { return cmp.next } - -func (cmp *comparator) SetNext(c *comparator) *comparator { - cmp.next = c - return cmp +func byFileName(a, b *result.Issue) int { + return strings.Compare(a.FilePath(), b.FilePath()) } -func (cmp *comparator) String() string { - s := cmp.name - if cmp.Next() != nil { - s += " > " + cmp.Next().String() - } - - return s +func byLine(a, b *result.Issue) int { + return numericCompare(a.Line(), b.Line()) } -func (cmp *comparator) Compare(a, b *result.Issue) compareResult { - res := cmp.compare(a, b) - if !res.isNeutral() { - return res - } - - if next := cmp.Next(); next != nil { - return next.Compare(a, b) - } - - return res +func byColumn(a, b *result.Issue) int { + return numericCompare(a.Column(), b.Column()) } -func byFileName() *comparator { - return &comparator{ - name: "byFileName", - compare: func(a, b *result.Issue) compareResult { - return compareResult(strings.Compare(a.FilePath(), b.FilePath())) - }, - } +func byLinter(a, b *result.Issue) int { + return strings.Compare(a.FromLinter, b.FromLinter) } -func byLine() *comparator { - return &comparator{ - name: "byLine", - compare: func(a, b *result.Issue) compareResult { - return numericCompare(a.Line(), b.Line()) - }, - } +func bySeverity(a, b *result.Issue) int { + return severityCompare(a.Severity, b.Severity) } -func byColumn() *comparator { - return &comparator{ - name: "byColumn", - compare: func(a, b *result.Issue) compareResult { - return numericCompare(a.Column(), b.Column()) - }, - } -} - -func byLinter() *comparator { - return &comparator{ - name: "byLinter", - compare: func(a, b *result.Issue) compareResult { - return compareResult(strings.Compare(a.FromLinter, b.FromLinter)) - }, - } -} - -func bySeverity() *comparator { - return &comparator{ - name: "bySeverity", - compare: func(a, b *result.Issue) compareResult { - return severityCompare(a.Severity, b.Severity) - }, - } -} - -func mergeComparators(cmps []*comparator) (*comparator, error) { - if len(cmps) == 0 { - return nil, errors.New("no comparator") - } - - for i := range len(cmps) - 1 { - findComparatorTip(cmps[i]).SetNext(cmps[i+1]) - } - - return cmps[0], nil -} - -func findComparatorTip(cmp *comparator) *comparator { - if cmp.Next() != nil { - return findComparatorTip(cmp.Next()) - } - - return cmp -} - -func severityCompare(a, b string) compareResult { +func severityCompare(a, b string) int { // The position inside the slice define the importance (lower to higher). classic := []string{"low", "medium", "high", "warning", "error"} if slices.Contains(classic, a) && slices.Contains(classic, b) { - switch { - case slices.Index(classic, a) > slices.Index(classic, b): - return greater - case slices.Index(classic, a) < slices.Index(classic, b): - return less - default: - return equal - } + return cmp.Compare(slices.Index(classic, a), slices.Index(classic, b)) } if slices.Contains(classic, a) { @@ -232,28 +122,27 @@ func severityCompare(a, b string) compareResult { return less } - return compareResult(strings.Compare(a, b)) + return strings.Compare(a, b) } -func numericCompare(a, b int) compareResult { - var ( - isValuesInvalid = a < 0 || b < 0 - isZeroValuesBoth = a == 0 && b == 0 - isEqual = a == b - isZeroValueInA = b > 0 && a == 0 - isZeroValueInB = a > 0 && b == 0 - ) - - switch { - case isZeroValuesBoth || isEqual: +func numericCompare(a, b int) int { + // Negative values and zeros are skipped (equal) because they either invalid or "neutral" (default int value). + if a <= 0 || b <= 0 { return equal - case isValuesInvalid || isZeroValueInA || isZeroValueInB: - return none - case a > b: - return greater - case a < b: - return less } - return equal + return cmp.Compare(a, b) +} + +func mergeComparators(comps ...issueComparator) issueComparator { + return func(a, b *result.Issue) int { + for _, comp := range comps { + i := comp(a, b) + if i != equal { + return i + } + } + + return equal + } } diff --git a/tools/vendor/github.com/mgechev/revive/lint/linter.go b/tools/vendor/github.com/mgechev/revive/lint/linter.go index 56036e83d8..b777f9251d 100644 --- a/tools/vendor/github.com/mgechev/revive/lint/linter.go +++ b/tools/vendor/github.com/mgechev/revive/lint/linter.go @@ -109,7 +109,7 @@ func (l *Linter) Lint(packages [][]string, ruleSet []Rule, config Config) (<-cha fmt.Fprintln(os.Stderr, err) os.Exit(1) } - defer wg.Done() + wg.Done() }(packages[n], perPkgVersions[n]) } @@ -173,6 +173,10 @@ func detectGoMod(dir string) (rootDir string, ver *goversion.Version, err error) return "", nil, fmt.Errorf("failed to parse %q, got %v", modFileName, err) } + if modAst.Go == nil { + return "", nil, fmt.Errorf("%q does not specify a Go version", modFileName) + } + ver, err = goversion.NewVersion(modAst.Go.Version) return filepath.Dir(modFileName), ver, err } @@ -180,7 +184,9 @@ func detectGoMod(dir string) (rootDir string, ver *goversion.Version, err error) func retrieveModFile(dir string) (string, error) { const lookingForFile = "go.mod" for { - if dir == "." || dir == "/" { + // filepath.Dir returns 'C:\' on Windows, and '/' on Unix + isRootDir := (dir == filepath.VolumeName(dir)+string(filepath.Separator)) + if dir == "." || isRootDir { return "", fmt.Errorf("did not found %q file", lookingForFile) } diff --git a/tools/vendor/github.com/mgechev/revive/lint/package.go b/tools/vendor/github.com/mgechev/revive/lint/package.go index 2ab035f169..4a633f35ab 100644 --- a/tools/vendor/github.com/mgechev/revive/lint/package.go +++ b/tools/vendor/github.com/mgechev/revive/lint/package.go @@ -189,7 +189,7 @@ func (p *Package) lint(rules []Rule, config Config, failures chan Failure) { wg.Add(1) go (func(file *File) { file.lint(rules, config, failures) - defer wg.Done() + wg.Done() })(file) } wg.Wait() diff --git a/tools/vendor/github.com/mgechev/revive/rule/add-constant.go b/tools/vendor/github.com/mgechev/revive/rule/add_constant.go similarity index 98% rename from tools/vendor/github.com/mgechev/revive/rule/add-constant.go rename to tools/vendor/github.com/mgechev/revive/rule/add_constant.go index 233f1d8489..399382c8bc 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/add-constant.go +++ b/tools/vendor/github.com/mgechev/revive/rule/add_constant.go @@ -36,12 +36,13 @@ type AddConstantRule struct { allowList allowList ignoreFunctions []*regexp.Regexp strLitLimit int - sync.Mutex + + configureOnce sync.Once } // Apply applies the rule to given file. func (r *AddConstantRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure @@ -201,9 +202,6 @@ func (w *lintAddConstantRule) isStructTag(n *ast.BasicLit) bool { } func (r *AddConstantRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.allowList == nil { r.strLitLimit = defaultStrLitLimit r.allowList = newAllowList() diff --git a/tools/vendor/github.com/mgechev/revive/rule/argument-limit.go b/tools/vendor/github.com/mgechev/revive/rule/argument_limit.go similarity index 94% rename from tools/vendor/github.com/mgechev/revive/rule/argument-limit.go rename to tools/vendor/github.com/mgechev/revive/rule/argument_limit.go index b6ce0e81a7..b4d56de0ee 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/argument-limit.go +++ b/tools/vendor/github.com/mgechev/revive/rule/argument_limit.go @@ -11,18 +11,13 @@ import ( // ArgumentsLimitRule lints given else constructs. type ArgumentsLimitRule struct { max int - sync.Mutex + + configureOnce sync.Once } const defaultArgumentsLimit = 8 func (r *ArgumentsLimitRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.max != 0 { - return - } - if len(arguments) < 1 { r.max = defaultArgumentsLimit return @@ -37,7 +32,7 @@ func (r *ArgumentsLimitRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *ArgumentsLimitRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure onFailure := func(failure lint.Failure) { diff --git a/tools/vendor/github.com/mgechev/revive/rule/banned-characters.go b/tools/vendor/github.com/mgechev/revive/rule/banned_characters.go similarity index 94% rename from tools/vendor/github.com/mgechev/revive/rule/banned-characters.go rename to tools/vendor/github.com/mgechev/revive/rule/banned_characters.go index 12997bae11..926b32c214 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/banned-characters.go +++ b/tools/vendor/github.com/mgechev/revive/rule/banned_characters.go @@ -12,15 +12,14 @@ import ( // BannedCharsRule checks if a file contains banned characters. type BannedCharsRule struct { bannedCharList []string - sync.Mutex + + configureOnce sync.Once } const bannedCharsRuleName = "banned-characters" func (r *BannedCharsRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.bannedCharList == nil && len(arguments) > 0 { + if len(arguments) > 0 { checkNumberOfArguments(1, arguments, bannedCharsRuleName) r.bannedCharList = r.getBannedCharsList(arguments) } @@ -28,7 +27,7 @@ func (r *BannedCharsRule) configure(arguments lint.Arguments) { // Apply applied the rule to the given file. func (r *BannedCharsRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure onFailure := func(failure lint.Failure) { diff --git a/tools/vendor/github.com/mgechev/revive/rule/bare-return.go b/tools/vendor/github.com/mgechev/revive/rule/bare_return.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/bare-return.go rename to tools/vendor/github.com/mgechev/revive/rule/bare_return.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/blank-imports.go b/tools/vendor/github.com/mgechev/revive/rule/blank_imports.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/blank-imports.go rename to tools/vendor/github.com/mgechev/revive/rule/blank_imports.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/bool-literal-in-expr.go b/tools/vendor/github.com/mgechev/revive/rule/bool_literal_in_expr.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/bool-literal-in-expr.go rename to tools/vendor/github.com/mgechev/revive/rule/bool_literal_in_expr.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/call-to-gc.go b/tools/vendor/github.com/mgechev/revive/rule/call_to_gc.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/call-to-gc.go rename to tools/vendor/github.com/mgechev/revive/rule/call_to_gc.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/cognitive-complexity.go b/tools/vendor/github.com/mgechev/revive/rule/cognitive_complexity.go similarity index 97% rename from tools/vendor/github.com/mgechev/revive/rule/cognitive-complexity.go rename to tools/vendor/github.com/mgechev/revive/rule/cognitive_complexity.go index 83640fd3d1..ecde3882e1 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/cognitive-complexity.go +++ b/tools/vendor/github.com/mgechev/revive/rule/cognitive_complexity.go @@ -13,18 +13,13 @@ import ( // CognitiveComplexityRule lints given else constructs. type CognitiveComplexityRule struct { maxComplexity int - sync.Mutex + + configureOnce sync.Once } const defaultMaxCognitiveComplexity = 7 func (r *CognitiveComplexityRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.maxComplexity != 0 { - return // already configured - } - if len(arguments) < 1 { r.maxComplexity = defaultMaxCognitiveComplexity return @@ -40,7 +35,7 @@ func (r *CognitiveComplexityRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *CognitiveComplexityRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure diff --git a/tools/vendor/github.com/mgechev/revive/rule/comment-spacings.go b/tools/vendor/github.com/mgechev/revive/rule/comment_spacings.go similarity index 93% rename from tools/vendor/github.com/mgechev/revive/rule/comment-spacings.go rename to tools/vendor/github.com/mgechev/revive/rule/comment_spacings.go index f721513017..7bdc0e71d0 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/comment-spacings.go +++ b/tools/vendor/github.com/mgechev/revive/rule/comment_spacings.go @@ -12,16 +12,11 @@ import ( // the comment symbol( // ) and the start of the comment text type CommentSpacingsRule struct { allowList []string - sync.Mutex + + configureOnce sync.Once } func (r *CommentSpacingsRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.allowList != nil { - return // already configured - } - r.allowList = []string{} for _, arg := range arguments { allow, ok := arg.(string) // Alt. non panicking version @@ -34,7 +29,7 @@ func (r *CommentSpacingsRule) configure(arguments lint.Arguments) { // Apply the rule. func (r *CommentSpacingsRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure { - r.configure(args) + r.configureOnce.Do(func() { r.configure(args) }) var failures []lint.Failure diff --git a/tools/vendor/github.com/mgechev/revive/rule/comments-density.go b/tools/vendor/github.com/mgechev/revive/rule/comments_density.go similarity index 93% rename from tools/vendor/github.com/mgechev/revive/rule/comments-density.go rename to tools/vendor/github.com/mgechev/revive/rule/comments_density.go index c5298ea07d..f2382b1f02 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/comments-density.go +++ b/tools/vendor/github.com/mgechev/revive/rule/comments_density.go @@ -12,22 +12,13 @@ import ( // CommentsDensityRule lints given else constructs. type CommentsDensityRule struct { minimumCommentsDensity int64 - configured bool - sync.Mutex + + configureOnce sync.Once } const defaultMinimumCommentsPercentage = 0 func (r *CommentsDensityRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.configured { - return - } - - r.configured = true - if len(arguments) < 1 { r.minimumCommentsDensity = defaultMinimumCommentsPercentage return @@ -42,7 +33,7 @@ func (r *CommentsDensityRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *CommentsDensityRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) commentsLines := countDocLines(file.AST.Comments) statementsCount := countStatements(file.AST) diff --git a/tools/vendor/github.com/mgechev/revive/rule/confusing-naming.go b/tools/vendor/github.com/mgechev/revive/rule/confusing_naming.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/confusing-naming.go rename to tools/vendor/github.com/mgechev/revive/rule/confusing_naming.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/confusing-results.go b/tools/vendor/github.com/mgechev/revive/rule/confusing_results.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/confusing-results.go rename to tools/vendor/github.com/mgechev/revive/rule/confusing_results.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/constant-logical-expr.go b/tools/vendor/github.com/mgechev/revive/rule/constant_logical_expr.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/constant-logical-expr.go rename to tools/vendor/github.com/mgechev/revive/rule/constant_logical_expr.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/context-as-argument.go b/tools/vendor/github.com/mgechev/revive/rule/context_as_argument.go similarity index 92% rename from tools/vendor/github.com/mgechev/revive/rule/context-as-argument.go rename to tools/vendor/github.com/mgechev/revive/rule/context_as_argument.go index e0c8cfa5e9..8bc5f8b614 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/context-as-argument.go +++ b/tools/vendor/github.com/mgechev/revive/rule/context_as_argument.go @@ -12,32 +12,31 @@ import ( // ContextAsArgumentRule lints given else constructs. type ContextAsArgumentRule struct { allowTypesLUT map[string]struct{} - sync.Mutex + + configureOnce sync.Once } // Apply applies the rule to given file. func (r *ContextAsArgumentRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure { - r.Lock() - if r.allowTypesLUT == nil { - r.allowTypesLUT = getAllowTypesFromArguments(args) - } - r.Unlock() + r.configureOnce.Do(func() { r.configure(args) }) var failures []lint.Failure - r.Lock() walker := lintContextArguments{ allowTypesLUT: r.allowTypesLUT, onFailure: func(failure lint.Failure) { failures = append(failures, failure) }, } - r.Unlock() ast.Walk(walker, file.AST) return failures } +func (r *ContextAsArgumentRule) configure(arguments lint.Arguments) { + r.allowTypesLUT = getAllowTypesFromArguments(arguments) +} + // Name returns the rule name. func (*ContextAsArgumentRule) Name() string { return "context-as-argument" diff --git a/tools/vendor/github.com/mgechev/revive/rule/context-keys-type.go b/tools/vendor/github.com/mgechev/revive/rule/context_keys_type.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/context-keys-type.go rename to tools/vendor/github.com/mgechev/revive/rule/context_keys_type.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/cyclomatic.go b/tools/vendor/github.com/mgechev/revive/rule/cyclomatic.go index 10413de24c..c1a2de97ac 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/cyclomatic.go +++ b/tools/vendor/github.com/mgechev/revive/rule/cyclomatic.go @@ -14,18 +14,13 @@ import ( // CyclomaticRule lints given else constructs. type CyclomaticRule struct { maxComplexity int - sync.Mutex + + configureOnce sync.Once } const defaultMaxCyclomaticComplexity = 10 func (r *CyclomaticRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.maxComplexity != 0 { - return // already configured - } - if len(arguments) < 1 { r.maxComplexity = defaultMaxCyclomaticComplexity return @@ -40,7 +35,7 @@ func (r *CyclomaticRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *CyclomaticRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure fileAst := file.AST diff --git a/tools/vendor/github.com/mgechev/revive/rule/deep-exit.go b/tools/vendor/github.com/mgechev/revive/rule/deep_exit.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/deep-exit.go rename to tools/vendor/github.com/mgechev/revive/rule/deep_exit.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/defer.go b/tools/vendor/github.com/mgechev/revive/rule/defer.go index 3c31d507bf..f7c716eb69 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/defer.go +++ b/tools/vendor/github.com/mgechev/revive/rule/defer.go @@ -11,22 +11,17 @@ import ( // DeferRule lints unused params in functions. type DeferRule struct { allow map[string]bool - sync.Mutex + + configureOnce sync.Once } func (r *DeferRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.allow != nil { - return // already configured - } - r.allow = r.allowFromArgs(arguments) } // Apply applies the rule to given file. func (r *DeferRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure onFailure := func(failure lint.Failure) { diff --git a/tools/vendor/github.com/mgechev/revive/rule/dot-imports.go b/tools/vendor/github.com/mgechev/revive/rule/dot_imports.go similarity index 95% rename from tools/vendor/github.com/mgechev/revive/rule/dot-imports.go rename to tools/vendor/github.com/mgechev/revive/rule/dot_imports.go index df0b2a7f4f..f6c7fbcfba 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/dot-imports.go +++ b/tools/vendor/github.com/mgechev/revive/rule/dot_imports.go @@ -10,13 +10,14 @@ import ( // DotImportsRule lints given else constructs. type DotImportsRule struct { - sync.Mutex allowedPackages allowPackages + + configureOnce sync.Once } // Apply applies the rule to given file. func (r *DotImportsRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure @@ -41,13 +42,6 @@ func (*DotImportsRule) Name() string { } func (r *DotImportsRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.allowedPackages != nil { - return - } - r.allowedPackages = make(allowPackages) if len(arguments) == 0 { return diff --git a/tools/vendor/github.com/mgechev/revive/rule/duplicated-imports.go b/tools/vendor/github.com/mgechev/revive/rule/duplicated_imports.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/duplicated-imports.go rename to tools/vendor/github.com/mgechev/revive/rule/duplicated_imports.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/early-return.go b/tools/vendor/github.com/mgechev/revive/rule/early_return.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/early-return.go rename to tools/vendor/github.com/mgechev/revive/rule/early_return.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/empty-block.go b/tools/vendor/github.com/mgechev/revive/rule/empty_block.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/empty-block.go rename to tools/vendor/github.com/mgechev/revive/rule/empty_block.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/empty-lines.go b/tools/vendor/github.com/mgechev/revive/rule/empty_lines.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/empty-lines.go rename to tools/vendor/github.com/mgechev/revive/rule/empty_lines.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/enforce-map-style.go b/tools/vendor/github.com/mgechev/revive/rule/enforce_map_style.go similarity index 96% rename from tools/vendor/github.com/mgechev/revive/rule/enforce-map-style.go rename to tools/vendor/github.com/mgechev/revive/rule/enforce_map_style.go index c698c40ed8..7ddf31e35d 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/enforce-map-style.go +++ b/tools/vendor/github.com/mgechev/revive/rule/enforce_map_style.go @@ -39,20 +39,12 @@ func mapStyleFromString(s string) (enforceMapStyleType, error) { // EnforceMapStyleRule implements a rule to enforce `make(map[type]type)` over `map[type]type{}`. type EnforceMapStyleRule struct { - configured bool enforceMapStyle enforceMapStyleType - sync.Mutex + + configureOnce sync.Once } func (r *EnforceMapStyleRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.configured { - return - } - r.configured = true - if len(arguments) < 1 { r.enforceMapStyle = enforceMapStyleTypeAny return @@ -72,7 +64,7 @@ func (r *EnforceMapStyleRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *EnforceMapStyleRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) if r.enforceMapStyle == enforceMapStyleTypeAny { // this linter is not configured diff --git a/tools/vendor/github.com/mgechev/revive/rule/enforce-repeated-arg-type-style.go b/tools/vendor/github.com/mgechev/revive/rule/enforce_repeated_arg_type_style.go similarity index 97% rename from tools/vendor/github.com/mgechev/revive/rule/enforce-repeated-arg-type-style.go rename to tools/vendor/github.com/mgechev/revive/rule/enforce_repeated_arg_type_style.go index a435ee186c..3f9712aef0 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/enforce-repeated-arg-type-style.go +++ b/tools/vendor/github.com/mgechev/revive/rule/enforce_repeated_arg_type_style.go @@ -41,22 +41,13 @@ func repeatedArgTypeStyleFromString(s string) enforceRepeatedArgTypeStyleType { // EnforceRepeatedArgTypeStyleRule implements a rule to enforce repeated argument type style. type EnforceRepeatedArgTypeStyleRule struct { - configured bool funcArgStyle enforceRepeatedArgTypeStyleType funcRetValStyle enforceRepeatedArgTypeStyleType - sync.Mutex + configureOnce sync.Once } func (r *EnforceRepeatedArgTypeStyleRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.configured { - return - } - r.configured = true - r.funcArgStyle = enforceRepeatedArgTypeStyleTypeAny r.funcRetValStyle = enforceRepeatedArgTypeStyleTypeAny @@ -94,7 +85,7 @@ func (r *EnforceRepeatedArgTypeStyleRule) configure(arguments lint.Arguments) { // Apply applies the rule to a given file. func (r *EnforceRepeatedArgTypeStyleRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) if r.funcArgStyle == enforceRepeatedArgTypeStyleTypeAny && r.funcRetValStyle == enforceRepeatedArgTypeStyleTypeAny { // This linter is not configured, return no failures. diff --git a/tools/vendor/github.com/mgechev/revive/rule/enforce-slice-style.go b/tools/vendor/github.com/mgechev/revive/rule/enforce_slice_style.go similarity index 97% rename from tools/vendor/github.com/mgechev/revive/rule/enforce-slice-style.go rename to tools/vendor/github.com/mgechev/revive/rule/enforce_slice_style.go index 14be258935..7170379d93 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/enforce-slice-style.go +++ b/tools/vendor/github.com/mgechev/revive/rule/enforce_slice_style.go @@ -43,20 +43,12 @@ func sliceStyleFromString(s string) (enforceSliceStyleType, error) { // EnforceSliceStyleRule implements a rule to enforce `make([]type)` over `[]type{}`. type EnforceSliceStyleRule struct { - configured bool enforceSliceStyle enforceSliceStyleType - sync.Mutex + + configureOnce sync.Once } func (r *EnforceSliceStyleRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.configured { - return - } - r.configured = true - if len(arguments) < 1 { r.enforceSliceStyle = enforceSliceStyleTypeAny return @@ -76,7 +68,7 @@ func (r *EnforceSliceStyleRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *EnforceSliceStyleRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) if r.enforceSliceStyle == enforceSliceStyleTypeAny { // this linter is not configured diff --git a/tools/vendor/github.com/mgechev/revive/rule/error-naming.go b/tools/vendor/github.com/mgechev/revive/rule/error_naming.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/error-naming.go rename to tools/vendor/github.com/mgechev/revive/rule/error_naming.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/error-return.go b/tools/vendor/github.com/mgechev/revive/rule/error_return.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/error-return.go rename to tools/vendor/github.com/mgechev/revive/rule/error_return.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/error-strings.go b/tools/vendor/github.com/mgechev/revive/rule/error_strings.go similarity index 97% rename from tools/vendor/github.com/mgechev/revive/rule/error-strings.go rename to tools/vendor/github.com/mgechev/revive/rule/error_strings.go index 81ebda5401..97a0f4d065 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/error-strings.go +++ b/tools/vendor/github.com/mgechev/revive/rule/error_strings.go @@ -15,17 +15,11 @@ import ( // ErrorStringsRule lints given else constructs. type ErrorStringsRule struct { errorFunctions map[string]map[string]struct{} - sync.Mutex + + configureOnce sync.Once } func (r *ErrorStringsRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.errorFunctions != nil { - return - } - r.errorFunctions = map[string]map[string]struct{}{ "fmt": { "Errorf": {}, @@ -60,7 +54,7 @@ func (r *ErrorStringsRule) configure(arguments lint.Arguments) { func (r *ErrorStringsRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { var failures []lint.Failure - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) fileAst := file.AST walker := lintErrorStrings{ diff --git a/tools/vendor/github.com/mgechev/revive/rule/exported.go b/tools/vendor/github.com/mgechev/revive/rule/exported.go index e3972d40e5..7ee27b309f 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/exported.go +++ b/tools/vendor/github.com/mgechev/revive/rule/exported.go @@ -55,20 +55,13 @@ func (dc *disabledChecks) isDisabled(checkName string) bool { // ExportedRule lints given else constructs. type ExportedRule struct { - configured bool stuttersMsg string disabledChecks disabledChecks - sync.Mutex + + configureOnce sync.Once } func (r *ExportedRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.configured { - return - } - r.configured = true - r.disabledChecks = disabledChecks{PrivateReceivers: true, PublicInterfaces: true} r.stuttersMsg = "stutters" for _, flag := range arguments { @@ -104,7 +97,7 @@ func (r *ExportedRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *ExportedRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure { - r.configure(args) + r.configureOnce.Do(func() { r.configure(args) }) var failures []lint.Failure if file.IsTest() { diff --git a/tools/vendor/github.com/mgechev/revive/rule/file-header.go b/tools/vendor/github.com/mgechev/revive/rule/file_header.go similarity index 92% rename from tools/vendor/github.com/mgechev/revive/rule/file-header.go rename to tools/vendor/github.com/mgechev/revive/rule/file_header.go index 0dcb57746e..52513d8e8d 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/file-header.go +++ b/tools/vendor/github.com/mgechev/revive/rule/file_header.go @@ -11,7 +11,8 @@ import ( // FileHeaderRule lints given else constructs. type FileHeaderRule struct { header string - sync.Mutex + + configureOnce sync.Once } var ( @@ -20,12 +21,6 @@ var ( ) func (r *FileHeaderRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.header != "" { - return // already configured - } - if len(arguments) < 1 { return } @@ -39,7 +34,7 @@ func (r *FileHeaderRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *FileHeaderRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) if r.header == "" { return nil diff --git a/tools/vendor/github.com/mgechev/revive/rule/file-length-limit.go b/tools/vendor/github.com/mgechev/revive/rule/file_length_limit.go similarity index 96% rename from tools/vendor/github.com/mgechev/revive/rule/file-length-limit.go rename to tools/vendor/github.com/mgechev/revive/rule/file_length_limit.go index c5a5641f41..0fe075c56e 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/file-length-limit.go +++ b/tools/vendor/github.com/mgechev/revive/rule/file_length_limit.go @@ -20,12 +20,13 @@ type FileLengthLimitRule struct { skipComments bool // skipBlankLines indicates whether to skip blank lines when counting lines. skipBlankLines bool - sync.Mutex + + configureOnce sync.Once } // Apply applies the rule to given file. func (r *FileLengthLimitRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) if r.max <= 0 { // when max is negative or 0 the rule is disabled @@ -75,13 +76,6 @@ func (r *FileLengthLimitRule) Apply(file *lint.File, arguments lint.Arguments) [ } func (r *FileLengthLimitRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.max != 0 { - return // already configured - } - if len(arguments) < 1 { return // use default } diff --git a/tools/vendor/github.com/mgechev/revive/rule/filename-format.go b/tools/vendor/github.com/mgechev/revive/rule/filename_format.go similarity index 94% rename from tools/vendor/github.com/mgechev/revive/rule/filename-format.go rename to tools/vendor/github.com/mgechev/revive/rule/filename_format.go index 49fdf9c3e8..9d8047829e 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/filename-format.go +++ b/tools/vendor/github.com/mgechev/revive/rule/filename_format.go @@ -13,12 +13,13 @@ import ( // FilenameFormatRule lints source filenames according to a set of regular expressions given as arguments type FilenameFormatRule struct { format *regexp.Regexp - sync.Mutex + + configureOnce sync.Once } // Apply applies the rule to the given file. func (r *FilenameFormatRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) filename := filepath.Base(file.Name) if r.format.MatchString(filename) { @@ -55,13 +56,6 @@ func (*FilenameFormatRule) Name() string { var defaultFormat = regexp.MustCompile("^[_A-Za-z0-9][_A-Za-z0-9-]*.go$") func (r *FilenameFormatRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.format != nil { - return - } - argsCount := len(arguments) if argsCount == 0 { r.format = defaultFormat diff --git a/tools/vendor/github.com/mgechev/revive/rule/flag-param.go b/tools/vendor/github.com/mgechev/revive/rule/flag_param.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/flag-param.go rename to tools/vendor/github.com/mgechev/revive/rule/flag_param.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/function-length.go b/tools/vendor/github.com/mgechev/revive/rule/function_length.go similarity index 96% rename from tools/vendor/github.com/mgechev/revive/rule/function-length.go rename to tools/vendor/github.com/mgechev/revive/rule/function_length.go index 30402313d1..c58cd4c0f4 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/function-length.go +++ b/tools/vendor/github.com/mgechev/revive/rule/function_length.go @@ -11,20 +11,13 @@ import ( // FunctionLength lint. type FunctionLength struct { - maxStmt int - maxLines int - configured bool - sync.Mutex + maxStmt int + maxLines int + + configureOnce sync.Once } func (r *FunctionLength) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.configured { - return - } - - r.configured = true maxStmt, maxLines := r.parseArguments(arguments) r.maxStmt = int(maxStmt) r.maxLines = int(maxLines) @@ -32,7 +25,7 @@ func (r *FunctionLength) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *FunctionLength) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure diff --git a/tools/vendor/github.com/mgechev/revive/rule/function-result-limit.go b/tools/vendor/github.com/mgechev/revive/rule/function_result_limit.go similarity index 94% rename from tools/vendor/github.com/mgechev/revive/rule/function-result-limit.go rename to tools/vendor/github.com/mgechev/revive/rule/function_result_limit.go index 23474b5ee4..5b72f01ab8 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/function-result-limit.go +++ b/tools/vendor/github.com/mgechev/revive/rule/function_result_limit.go @@ -11,18 +11,13 @@ import ( // FunctionResultsLimitRule lints given else constructs. type FunctionResultsLimitRule struct { max int - sync.Mutex + + configureOnce sync.Once } const defaultResultsLimit = 3 func (r *FunctionResultsLimitRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.max != 0 { - return // already configured - } - if len(arguments) < 1 { r.max = defaultResultsLimit return @@ -41,7 +36,7 @@ func (r *FunctionResultsLimitRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *FunctionResultsLimitRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure diff --git a/tools/vendor/github.com/mgechev/revive/rule/get-return.go b/tools/vendor/github.com/mgechev/revive/rule/get_return.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/get-return.go rename to tools/vendor/github.com/mgechev/revive/rule/get_return.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/identical-branches.go b/tools/vendor/github.com/mgechev/revive/rule/identical_branches.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/identical-branches.go rename to tools/vendor/github.com/mgechev/revive/rule/identical_branches.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/if-return.go b/tools/vendor/github.com/mgechev/revive/rule/if_return.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/if-return.go rename to tools/vendor/github.com/mgechev/revive/rule/if_return.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/import-alias-naming.go b/tools/vendor/github.com/mgechev/revive/rule/import_alias_naming.go similarity index 96% rename from tools/vendor/github.com/mgechev/revive/rule/import-alias-naming.go rename to tools/vendor/github.com/mgechev/revive/rule/import_alias_naming.go index 48d22566a1..043bf0d76e 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/import-alias-naming.go +++ b/tools/vendor/github.com/mgechev/revive/rule/import_alias_naming.go @@ -10,10 +10,10 @@ import ( // ImportAliasNamingRule lints import alias naming. type ImportAliasNamingRule struct { - configured bool allowRegexp *regexp.Regexp denyRegexp *regexp.Regexp - sync.Mutex + + configureOnce sync.Once } const defaultImportAliasNamingAllowRule = "^[a-z][a-z0-9]{0,}$" @@ -21,12 +21,6 @@ const defaultImportAliasNamingAllowRule = "^[a-z][a-z0-9]{0,}$" var defaultImportAliasNamingAllowRegexp = regexp.MustCompile(defaultImportAliasNamingAllowRule) func (r *ImportAliasNamingRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.configured { - return - } - if len(arguments) == 0 { r.allowRegexp = defaultImportAliasNamingAllowRegexp return @@ -57,7 +51,7 @@ func (r *ImportAliasNamingRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *ImportAliasNamingRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure diff --git a/tools/vendor/github.com/mgechev/revive/rule/import-shadowing.go b/tools/vendor/github.com/mgechev/revive/rule/import_shadowing.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/import-shadowing.go rename to tools/vendor/github.com/mgechev/revive/rule/import_shadowing.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/imports-blocklist.go b/tools/vendor/github.com/mgechev/revive/rule/imports_blocklist.go similarity index 63% rename from tools/vendor/github.com/mgechev/revive/rule/imports-blocklist.go rename to tools/vendor/github.com/mgechev/revive/rule/imports_blocklist.go index 431066403a..18d77ca1c5 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/imports-blocklist.go +++ b/tools/vendor/github.com/mgechev/revive/rule/imports_blocklist.go @@ -11,29 +11,24 @@ import ( // ImportsBlocklistRule lints given else constructs. type ImportsBlocklistRule struct { blocklist []*regexp.Regexp - sync.Mutex + + configureOnce sync.Once } var replaceImportRegexp = regexp.MustCompile(`/?\*\*/?`) func (r *ImportsBlocklistRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.blocklist == nil { - r.blocklist = make([]*regexp.Regexp, 0) - - for _, arg := range arguments { - argStr, ok := arg.(string) - if !ok { - panic(fmt.Sprintf("Invalid argument to the imports-blocklist rule. Expecting a string, got %T", arg)) - } - regStr, err := regexp.Compile(fmt.Sprintf(`(?m)"%s"$`, replaceImportRegexp.ReplaceAllString(argStr, `(\W|\w)*`))) - if err != nil { - panic(fmt.Sprintf("Invalid argument to the imports-blocklist rule. Expecting %q to be a valid regular expression, got: %v", argStr, err)) - } - r.blocklist = append(r.blocklist, regStr) + r.blocklist = []*regexp.Regexp{} + for _, arg := range arguments { + argStr, ok := arg.(string) + if !ok { + panic(fmt.Sprintf("Invalid argument to the imports-blocklist rule. Expecting a string, got %T", arg)) + } + regStr, err := regexp.Compile(fmt.Sprintf(`(?m)"%s"$`, replaceImportRegexp.ReplaceAllString(argStr, `(\W|\w)*`))) + if err != nil { + panic(fmt.Sprintf("Invalid argument to the imports-blocklist rule. Expecting %q to be a valid regular expression, got: %v", argStr, err)) } + r.blocklist = append(r.blocklist, regStr) } } @@ -48,7 +43,7 @@ func (r *ImportsBlocklistRule) isBlocklisted(path string) bool { // Apply applies the rule to given file. func (r *ImportsBlocklistRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure diff --git a/tools/vendor/github.com/mgechev/revive/rule/increment-decrement.go b/tools/vendor/github.com/mgechev/revive/rule/increment_decrement.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/increment-decrement.go rename to tools/vendor/github.com/mgechev/revive/rule/increment_decrement.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/indent-error-flow.go b/tools/vendor/github.com/mgechev/revive/rule/indent_error_flow.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/indent-error-flow.go rename to tools/vendor/github.com/mgechev/revive/rule/indent_error_flow.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/line-length-limit.go b/tools/vendor/github.com/mgechev/revive/rule/line_length_limit.go similarity index 94% rename from tools/vendor/github.com/mgechev/revive/rule/line-length-limit.go rename to tools/vendor/github.com/mgechev/revive/rule/line_length_limit.go index a154b7aece..415761e1e9 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/line-length-limit.go +++ b/tools/vendor/github.com/mgechev/revive/rule/line_length_limit.go @@ -15,18 +15,13 @@ import ( // LineLengthLimitRule lints given else constructs. type LineLengthLimitRule struct { max int - sync.Mutex + + configureOnce sync.Once } const defaultLineLengthLimit = 80 func (r *LineLengthLimitRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.max != 0 { - return // already configured - } - if len(arguments) < 1 { r.max = defaultLineLengthLimit return @@ -42,7 +37,7 @@ func (r *LineLengthLimitRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *LineLengthLimitRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure diff --git a/tools/vendor/github.com/mgechev/revive/rule/max-control-nesting.go b/tools/vendor/github.com/mgechev/revive/rule/max_control_nesting.go similarity index 96% rename from tools/vendor/github.com/mgechev/revive/rule/max-control-nesting.go rename to tools/vendor/github.com/mgechev/revive/rule/max_control_nesting.go index 5dbb1eefa4..b2c5af70e6 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/max-control-nesting.go +++ b/tools/vendor/github.com/mgechev/revive/rule/max_control_nesting.go @@ -11,14 +11,15 @@ import ( // MaxControlNestingRule lints given else constructs. type MaxControlNestingRule struct { max int64 - sync.Mutex + + configureOnce sync.Once } const defaultMaxControlNesting = 5 // Apply applies the rule to given file. func (r *MaxControlNestingRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure @@ -107,12 +108,6 @@ func (w *lintMaxControlNesting) walkControlledBlock(b ast.Node) { } func (r *MaxControlNestingRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if !(r.max < 1) { - return // max already configured - } - if len(arguments) < 1 { r.max = defaultMaxControlNesting return diff --git a/tools/vendor/github.com/mgechev/revive/rule/max-public-structs.go b/tools/vendor/github.com/mgechev/revive/rule/max_public_structs.go similarity index 87% rename from tools/vendor/github.com/mgechev/revive/rule/max-public-structs.go rename to tools/vendor/github.com/mgechev/revive/rule/max_public_structs.go index 70840e734e..d6f91e3752 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/max-public-structs.go +++ b/tools/vendor/github.com/mgechev/revive/rule/max_public_structs.go @@ -1,6 +1,7 @@ package rule import ( + "fmt" "go/ast" "strings" "sync" @@ -11,18 +12,13 @@ import ( // MaxPublicStructsRule lints given else constructs. type MaxPublicStructsRule struct { max int64 - sync.Mutex + + configureOnce sync.Once } const defaultMaxPublicStructs = 5 func (r *MaxPublicStructsRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.max == 0 { - return // already configured - } - if len(arguments) < 1 { r.max = defaultMaxPublicStructs return @@ -39,10 +35,14 @@ func (r *MaxPublicStructsRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *MaxPublicStructsRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure + if r.max < 1 { + return failures + } + fileAst := file.AST walker := &lintMaxPublicStructs{ @@ -56,7 +56,7 @@ func (r *MaxPublicStructsRule) Apply(file *lint.File, arguments lint.Arguments) if walker.current > r.max { walker.onFailure(lint.Failure{ - Failure: "you have exceeded the maximum number of public struct declarations", + Failure: fmt.Sprintf("you have exceeded the maximum number (%d) of public struct declarations", r.max), Confidence: 1, Node: fileAst, Category: "style", diff --git a/tools/vendor/github.com/mgechev/revive/rule/modifies-param.go b/tools/vendor/github.com/mgechev/revive/rule/modifies_param.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/modifies-param.go rename to tools/vendor/github.com/mgechev/revive/rule/modifies_param.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/modifies-value-receiver.go b/tools/vendor/github.com/mgechev/revive/rule/modifies_value_receiver.go similarity index 65% rename from tools/vendor/github.com/mgechev/revive/rule/modifies-value-receiver.go rename to tools/vendor/github.com/mgechev/revive/rule/modifies_value_receiver.go index e9e64b9a6a..2f92991f53 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/modifies-value-receiver.go +++ b/tools/vendor/github.com/mgechev/revive/rule/modifies_value_receiver.go @@ -2,6 +2,7 @@ package rule import ( "go/ast" + "go/token" "strings" "github.com/mgechev/revive/lint" @@ -60,14 +61,14 @@ func (w lintModifiesValRecRule) Visit(node ast.Node) ast.Visitor { return nil // skip, anonymous receiver } - fselect := func(n ast.Node) bool { + receiverAssignmentFinder := func(n ast.Node) bool { // look for assignments with the receiver in the right hand - asgmt, ok := n.(*ast.AssignStmt) + assignment, ok := n.(*ast.AssignStmt) if !ok { return false } - for _, exp := range asgmt.Lhs { + for _, exp := range assignment.Lhs { switch e := exp.(type) { case *ast.IndexExpr: // receiver...[] = ... continue @@ -92,7 +93,15 @@ func (w lintModifiesValRecRule) Visit(node ast.Node) ast.Visitor { return false } - assignmentsToReceiver := pick(n.Body, fselect) + assignmentsToReceiver := pick(n.Body, receiverAssignmentFinder) + if len(assignmentsToReceiver) == 0 { + return nil // receiver is not modified + } + + methodReturnsReceiver := len(w.findReturnReceiverStatements(receiverName, n.Body)) > 0 + if methodReturnsReceiver { + return nil // modification seems legit (see issue #1066) + } for _, assignment := range assignmentsToReceiver { w.onFailure(lint.Failure{ @@ -127,3 +136,44 @@ func (lintModifiesValRecRule) getNameFromExpr(ie ast.Expr) string { return ident.Name } + +func (w lintModifiesValRecRule) findReturnReceiverStatements(receiverName string, target ast.Node) []ast.Node { + finder := func(n ast.Node) bool { + // look for returns with the receiver as value + returnStatement, ok := n.(*ast.ReturnStmt) + if !ok { + return false + } + + for _, exp := range returnStatement.Results { + switch e := exp.(type) { + case *ast.SelectorExpr: // receiver.field = ... + name := w.getNameFromExpr(e.X) + if name == "" || name != receiverName { + continue + } + case *ast.Ident: // receiver := ... + if e.Name != receiverName { + continue + } + case *ast.UnaryExpr: + if e.Op != token.AND { + continue + } + name := w.getNameFromExpr(e.X) + if name == "" || name != receiverName { + continue + } + + default: + continue + } + + return true + } + + return false + } + + return pick(target, finder) +} diff --git a/tools/vendor/github.com/mgechev/revive/rule/nested-structs.go b/tools/vendor/github.com/mgechev/revive/rule/nested_structs.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/nested-structs.go rename to tools/vendor/github.com/mgechev/revive/rule/nested_structs.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/optimize-operands-order.go b/tools/vendor/github.com/mgechev/revive/rule/optimize_operands_order.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/optimize-operands-order.go rename to tools/vendor/github.com/mgechev/revive/rule/optimize_operands_order.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/package-comments.go b/tools/vendor/github.com/mgechev/revive/rule/package_comments.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/package-comments.go rename to tools/vendor/github.com/mgechev/revive/rule/package_comments.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/range-val-address.go b/tools/vendor/github.com/mgechev/revive/rule/range_val_address.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/range-val-address.go rename to tools/vendor/github.com/mgechev/revive/rule/range_val_address.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/range-val-in-closure.go b/tools/vendor/github.com/mgechev/revive/rule/range_val_in_closure.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/range-val-in-closure.go rename to tools/vendor/github.com/mgechev/revive/rule/range_val_in_closure.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/receiver-naming.go b/tools/vendor/github.com/mgechev/revive/rule/receiver_naming.go similarity index 96% rename from tools/vendor/github.com/mgechev/revive/rule/receiver-naming.go rename to tools/vendor/github.com/mgechev/revive/rule/receiver_naming.go index afcd99b8fd..c83bacc2fb 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/receiver-naming.go +++ b/tools/vendor/github.com/mgechev/revive/rule/receiver_naming.go @@ -12,18 +12,13 @@ import ( // ReceiverNamingRule lints given else constructs. type ReceiverNamingRule struct { receiverNameMaxLength int - sync.Mutex + + configureOnce sync.Once } const defaultReceiverNameMaxLength = -1 // thus will not check func (r *ReceiverNamingRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.receiverNameMaxLength != 0 { - return - } - r.receiverNameMaxLength = defaultReceiverNameMaxLength if len(arguments) < 1 { return @@ -50,7 +45,7 @@ func (r *ReceiverNamingRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *ReceiverNamingRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure { - r.configure(args) + r.configureOnce.Do(func() { r.configure(args) }) var failures []lint.Failure diff --git a/tools/vendor/github.com/mgechev/revive/rule/redefines-builtin-id.go b/tools/vendor/github.com/mgechev/revive/rule/redefines_builtin_id.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/redefines-builtin-id.go rename to tools/vendor/github.com/mgechev/revive/rule/redefines_builtin_id.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/redundant-import-alias.go b/tools/vendor/github.com/mgechev/revive/rule/redundant_import_alias.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/redundant-import-alias.go rename to tools/vendor/github.com/mgechev/revive/rule/redundant_import_alias.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/string-format.go b/tools/vendor/github.com/mgechev/revive/rule/string_format.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/string-format.go rename to tools/vendor/github.com/mgechev/revive/rule/string_format.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/string-of-int.go b/tools/vendor/github.com/mgechev/revive/rule/string_of_int.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/string-of-int.go rename to tools/vendor/github.com/mgechev/revive/rule/string_of_int.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/struct-tag.go b/tools/vendor/github.com/mgechev/revive/rule/struct_tag.go similarity index 98% rename from tools/vendor/github.com/mgechev/revive/rule/struct-tag.go rename to tools/vendor/github.com/mgechev/revive/rule/struct_tag.go index ec3f0c7cf3..4dd9278277 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/struct-tag.go +++ b/tools/vendor/github.com/mgechev/revive/rule/struct_tag.go @@ -14,15 +14,12 @@ import ( // StructTagRule lints struct tags. type StructTagRule struct { userDefined map[string][]string // map: key -> []option - sync.Mutex + + configureOnce sync.Once } func (r *StructTagRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - - mustConfigure := r.userDefined == nil && len(arguments) > 0 - if !mustConfigure { + if len(arguments) == 0 { return } @@ -47,7 +44,7 @@ func (r *StructTagRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *StructTagRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure { - r.configure(args) + r.configureOnce.Do(func() { r.configure(args) }) var failures []lint.Failure onFailure := func(failure lint.Failure) { diff --git a/tools/vendor/github.com/mgechev/revive/rule/superfluous-else.go b/tools/vendor/github.com/mgechev/revive/rule/superfluous_else.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/superfluous-else.go rename to tools/vendor/github.com/mgechev/revive/rule/superfluous_else.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/time-equal.go b/tools/vendor/github.com/mgechev/revive/rule/time_equal.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/time-equal.go rename to tools/vendor/github.com/mgechev/revive/rule/time_equal.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/time-naming.go b/tools/vendor/github.com/mgechev/revive/rule/time_naming.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/time-naming.go rename to tools/vendor/github.com/mgechev/revive/rule/time_naming.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/unchecked-type-assertion.go b/tools/vendor/github.com/mgechev/revive/rule/unchecked_type_assertion.go similarity index 91% rename from tools/vendor/github.com/mgechev/revive/rule/unchecked-type-assertion.go rename to tools/vendor/github.com/mgechev/revive/rule/unchecked_type_assertion.go index eea344060a..34d854e8f5 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/unchecked-type-assertion.go +++ b/tools/vendor/github.com/mgechev/revive/rule/unchecked_type_assertion.go @@ -15,21 +15,16 @@ const ( // UncheckedTypeAssertionRule lints missing or ignored `ok`-value in dynamic type casts. type UncheckedTypeAssertionRule struct { - sync.Mutex acceptIgnoredAssertionResult bool - configured bool -} -func (u *UncheckedTypeAssertionRule) configure(arguments lint.Arguments) { - u.Lock() - defer u.Unlock() + configureOnce sync.Once +} - if len(arguments) == 0 || u.configured { +func (r *UncheckedTypeAssertionRule) configure(arguments lint.Arguments) { + if len(arguments) == 0 { return } - u.configured = true - args, ok := arguments[0].(map[string]any) if !ok { panic("Unable to get arguments. Expected object of key-value-pairs.") @@ -38,7 +33,7 @@ func (u *UncheckedTypeAssertionRule) configure(arguments lint.Arguments) { for k, v := range args { switch k { case "acceptIgnoredAssertionResult": - u.acceptIgnoredAssertionResult, ok = v.(bool) + r.acceptIgnoredAssertionResult, ok = v.(bool) if !ok { panic(fmt.Sprintf("Unable to parse argument '%s'. Expected boolean.", k)) } @@ -49,8 +44,8 @@ func (u *UncheckedTypeAssertionRule) configure(arguments lint.Arguments) { } // Apply applies the rule to given file. -func (u *UncheckedTypeAssertionRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure { - u.configure(args) +func (r *UncheckedTypeAssertionRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure { + r.configureOnce.Do(func() { r.configure(args) }) var failures []lint.Failure @@ -58,7 +53,7 @@ func (u *UncheckedTypeAssertionRule) Apply(file *lint.File, args lint.Arguments) onFailure: func(failure lint.Failure) { failures = append(failures, failure) }, - acceptIgnoredTypeAssertionResult: u.acceptIgnoredAssertionResult, + acceptIgnoredTypeAssertionResult: r.acceptIgnoredAssertionResult, } ast.Walk(walker, file.AST) diff --git a/tools/vendor/github.com/mgechev/revive/rule/unconditional-recursion.go b/tools/vendor/github.com/mgechev/revive/rule/unconditional_recursion.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/unconditional-recursion.go rename to tools/vendor/github.com/mgechev/revive/rule/unconditional_recursion.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/unexported-naming.go b/tools/vendor/github.com/mgechev/revive/rule/unexported_naming.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/unexported-naming.go rename to tools/vendor/github.com/mgechev/revive/rule/unexported_naming.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/unexported-return.go b/tools/vendor/github.com/mgechev/revive/rule/unexported_return.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/unexported-return.go rename to tools/vendor/github.com/mgechev/revive/rule/unexported_return.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/unhandled-error.go b/tools/vendor/github.com/mgechev/revive/rule/unhandled_error.go similarity index 96% rename from tools/vendor/github.com/mgechev/revive/rule/unhandled-error.go rename to tools/vendor/github.com/mgechev/revive/rule/unhandled_error.go index 95ba56180e..4fad8ccfcc 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/unhandled-error.go +++ b/tools/vendor/github.com/mgechev/revive/rule/unhandled_error.go @@ -14,17 +14,11 @@ import ( // UnhandledErrorRule lints given else constructs. type UnhandledErrorRule struct { ignoreList []*regexp.Regexp - sync.Mutex + + configureOnce sync.Once } func (r *UnhandledErrorRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.ignoreList != nil { - return // already configured - } - for _, arg := range arguments { argStr, ok := arg.(string) if !ok { @@ -47,7 +41,7 @@ func (r *UnhandledErrorRule) configure(arguments lint.Arguments) { // Apply applies the rule to given file. func (r *UnhandledErrorRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure { - r.configure(args) + r.configureOnce.Do(func() { r.configure(args) }) var failures []lint.Failure diff --git a/tools/vendor/github.com/mgechev/revive/rule/unnecessary-stmt.go b/tools/vendor/github.com/mgechev/revive/rule/unnecessary_stmt.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/unnecessary-stmt.go rename to tools/vendor/github.com/mgechev/revive/rule/unnecessary_stmt.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/unreachable-code.go b/tools/vendor/github.com/mgechev/revive/rule/unreachable_code.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/unreachable-code.go rename to tools/vendor/github.com/mgechev/revive/rule/unreachable_code.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/unused-param.go b/tools/vendor/github.com/mgechev/revive/rule/unused_param.go similarity index 96% rename from tools/vendor/github.com/mgechev/revive/rule/unused-param.go rename to tools/vendor/github.com/mgechev/revive/rule/unused_param.go index 4b04ee916b..a8514ac2df 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/unused-param.go +++ b/tools/vendor/github.com/mgechev/revive/rule/unused_param.go @@ -11,22 +11,14 @@ import ( // UnusedParamRule lints unused params in functions. type UnusedParamRule struct { - configured bool // regex to check if some name is valid for unused parameter, "^_$" by default allowRegex *regexp.Regexp failureMsg string - sync.Mutex + + configureOnce sync.Once } func (r *UnusedParamRule) configure(args lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.configured { - return - } - r.configured = true - // while by default args is an array, i think it's good to provide structures inside it by default, not arrays or primitives // it's more compatible to JSON nature of configurations var allowedRegexStr string @@ -58,7 +50,7 @@ func (r *UnusedParamRule) configure(args lint.Arguments) { // Apply applies the rule to given file. func (r *UnusedParamRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure { - r.configure(args) + r.configureOnce.Do(func() { r.configure(args) }) var failures []lint.Failure onFailure := func(failure lint.Failure) { diff --git a/tools/vendor/github.com/mgechev/revive/rule/unused-receiver.go b/tools/vendor/github.com/mgechev/revive/rule/unused_receiver.go similarity index 96% rename from tools/vendor/github.com/mgechev/revive/rule/unused-receiver.go rename to tools/vendor/github.com/mgechev/revive/rule/unused_receiver.go index 715dba3383..131aae5fb7 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/unused-receiver.go +++ b/tools/vendor/github.com/mgechev/revive/rule/unused_receiver.go @@ -11,22 +11,14 @@ import ( // UnusedReceiverRule lints unused params in functions. type UnusedReceiverRule struct { - configured bool // regex to check if some name is valid for unused parameter, "^_$" by default allowRegex *regexp.Regexp failureMsg string - sync.Mutex + + configureOnce sync.Once } func (r *UnusedReceiverRule) configure(args lint.Arguments) { - r.Lock() - defer r.Unlock() - - if r.configured { - return - } - r.configured = true - // while by default args is an array, i think it's good to provide structures inside it by default, not arrays or primitives // it's more compatible to JSON nature of configurations var allowedRegexStr string @@ -57,7 +49,7 @@ func (r *UnusedReceiverRule) configure(args lint.Arguments) { // Apply applies the rule to given file. func (r *UnusedReceiverRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure { - r.configure(args) + r.configureOnce.Do(func() { r.configure(args) }) var failures []lint.Failure onFailure := func(failure lint.Failure) { diff --git a/tools/vendor/github.com/mgechev/revive/rule/use-any.go b/tools/vendor/github.com/mgechev/revive/rule/use_any.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/use-any.go rename to tools/vendor/github.com/mgechev/revive/rule/use_any.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/useless-break.go b/tools/vendor/github.com/mgechev/revive/rule/useless_break.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/useless-break.go rename to tools/vendor/github.com/mgechev/revive/rule/useless_break.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/var-declarations.go b/tools/vendor/github.com/mgechev/revive/rule/var_declarations.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/var-declarations.go rename to tools/vendor/github.com/mgechev/revive/rule/var_declarations.go diff --git a/tools/vendor/github.com/mgechev/revive/rule/var-naming.go b/tools/vendor/github.com/mgechev/revive/rule/var_naming.go similarity index 98% rename from tools/vendor/github.com/mgechev/revive/rule/var-naming.go rename to tools/vendor/github.com/mgechev/revive/rule/var_naming.go index 5a4d0dc24b..2c2198dbda 100644 --- a/tools/vendor/github.com/mgechev/revive/rule/var-naming.go +++ b/tools/vendor/github.com/mgechev/revive/rule/var_naming.go @@ -18,22 +18,15 @@ var upperCaseConstRE = regexp.MustCompile(`^_?[A-Z][A-Z\d]*(_[A-Z\d]+)*$`) // VarNamingRule lints given else constructs. type VarNamingRule struct { - configured bool allowList []string blockList []string allowUpperCaseConst bool // if true - allows to use UPPER_SOME_NAMES for constants skipPackageNameChecks bool - sync.Mutex + + configureOnce sync.Once } func (r *VarNamingRule) configure(arguments lint.Arguments) { - r.Lock() - defer r.Unlock() - if r.configured { - return - } - - r.configured = true if len(arguments) >= 1 { r.allowList = getList(arguments[0], "allowlist") } @@ -83,7 +76,7 @@ func (r *VarNamingRule) applyPackageCheckRules(walker *lintNames) { // Apply applies the rule to given file. func (r *VarNamingRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { - r.configure(arguments) + r.configureOnce.Do(func() { r.configure(arguments) }) var failures []lint.Failure diff --git a/tools/vendor/github.com/mgechev/revive/rule/waitgroup-by-value.go b/tools/vendor/github.com/mgechev/revive/rule/waitgroup_by_value.go similarity index 100% rename from tools/vendor/github.com/mgechev/revive/rule/waitgroup-by-value.go rename to tools/vendor/github.com/mgechev/revive/rule/waitgroup_by_value.go diff --git a/tools/vendor/github.com/nunnatsa/ginkgolinter/README.md b/tools/vendor/github.com/nunnatsa/ginkgolinter/README.md index 536a65e7be..012628ed76 100644 --- a/tools/vendor/github.com/nunnatsa/ginkgolinter/README.md +++ b/tools/vendor/github.com/nunnatsa/ginkgolinter/README.md @@ -249,7 +249,7 @@ This will probably happen when using the old format: Eventually(aFunc, 500 * time.Millisecond /*timeout*/, 10 * time.Second /*polling*/).Should(Succeed()) ``` -### Correct usage of the `Succeed()` matcher [Bug] +### Prevent Wrong Actual Values with the Succeed() matcher [Bug] The `Succeed()` matcher only accepts a single error value. this rule validates that. For example: @@ -271,6 +271,8 @@ a Gomega object as their first parameter, and returns nothing, e.g. this is a va }).WithTimeout(10 * time.Millisecond).WithPolling(time.Millisecond).Should(Succeed()) ``` +***Note***: This rule **does not** support auto-fix. + ### Avoid Spec Pollution: Don't Initialize Variables in Container Nodes [BUG/STYLE]: ***Note***: Only applied when the `--forbid-spec-pollution=true` flag is set (disabled by default). @@ -522,6 +524,8 @@ will trigger a warning with a suggestion to replace the mather to ``` ***This rule is disabled by default***. Use the `--force-succeed=true` command line flag to enable it. +***Note***: This rule **does** support auto-fix, when the `--fix` command line parameter is used. + ## Suppress the linter ### Suppress warning from command line * Use the `--suppress-len-assertion=true` flag to suppress the wrong length and cap assertions warning diff --git a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actual.go b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actual.go index 8e3df5d3fb..c289b24def 100644 --- a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actual.go +++ b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actual.go @@ -21,13 +21,13 @@ type Actual struct { actualOffset int } -func New(origExpr, cloneExpr *ast.CallExpr, orig *ast.CallExpr, clone *ast.CallExpr, pass *analysis.Pass, handler gomegahandler.Handler, timePkg string) (*Actual, bool) { +func New(origExpr, cloneExpr *ast.CallExpr, orig *ast.CallExpr, clone *ast.CallExpr, pass *analysis.Pass, handler gomegahandler.Handler, timePkg string, errMethodExists bool) (*Actual, bool) { funcName, ok := handler.GetActualFuncName(orig) if !ok { return nil, false } - arg, actualOffset := getActualArgPayload(orig, clone, pass, funcName) + arg, actualOffset := getActualArgPayload(orig, clone, pass, funcName, errMethodExists) if arg == nil { return nil, false } diff --git a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actualarg.go b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actualarg.go index 9d251c4680..541a22330d 100644 --- a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actualarg.go +++ b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actualarg.go @@ -28,6 +28,7 @@ const ( ErrFuncActualArgType GomegaParamArgType MultiRetsArgType + ErrorMethodArgType ErrorTypeArgType @@ -39,7 +40,7 @@ func (a ArgType) Is(val ArgType) bool { return a&val != 0 } -func getActualArgPayload(origActualExpr, actualExprClone *ast.CallExpr, pass *analysis.Pass, actualMethodName string) (ArgPayload, int) { +func getActualArgPayload(origActualExpr, actualExprClone *ast.CallExpr, pass *analysis.Pass, actualMethodName string, errMethodExists bool) (ArgPayload, int) { origArgExpr, argExprClone, actualOffset, isGomegaExpr := getActualArg(origActualExpr, actualExprClone, actualMethodName, pass) if !isGomegaExpr { return nil, 0 @@ -47,7 +48,9 @@ func getActualArgPayload(origActualExpr, actualExprClone *ast.CallExpr, pass *an var arg ArgPayload - if value.IsExprError(pass, origArgExpr) { + if errMethodExists { + arg = &ErrorMethodPayload{} + } else if value.IsExprError(pass, origArgExpr) { arg = newErrPayload(origArgExpr, argExprClone, pass) } else { switch expr := origArgExpr.(type) { @@ -56,12 +59,6 @@ func getActualArgPayload(origActualExpr, actualExprClone *ast.CallExpr, pass *an case *ast.BinaryExpr: arg = parseBinaryExpr(expr, argExprClone.(*ast.BinaryExpr), pass) - - default: - t := pass.TypesInfo.TypeOf(origArgExpr) - if sig, ok := t.(*gotypes.Signature); ok { - arg = getAsyncFuncArg(sig) - } } } @@ -70,6 +67,14 @@ func getActualArgPayload(origActualExpr, actualExprClone *ast.CallExpr, pass *an return arg, actualOffset } + t := pass.TypesInfo.TypeOf(origArgExpr) + if sig, ok := t.(*gotypes.Signature); ok { + arg = getAsyncFuncArg(sig) + if arg != nil { + return arg, actualOffset + } + } + return newRegularArgPayload(origArgExpr, argExprClone, pass), actualOffset } @@ -181,6 +186,12 @@ func (*ErrPayload) ArgType() ArgType { return ErrActualArgType | ErrorTypeArgType } +type ErrorMethodPayload struct{} + +func (ErrorMethodPayload) ArgType() ArgType { + return ErrorMethodArgType | ErrorTypeArgType +} + func parseBinaryExpr(origActualExpr, argExprClone *ast.BinaryExpr, pass *analysis.Pass) ArgPayload { left, right, op := origActualExpr.X, origActualExpr.Y, origActualExpr.Op replace := false diff --git a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/expression.go b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/expression.go index 976e726fcf..c2aa702b14 100644 --- a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/expression.go +++ b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/expression.go @@ -52,7 +52,9 @@ func New(origExpr *ast.CallExpr, pass *analysis.Pass, handler gomegahandler.Hand exprClone := astcopy.CallExpr(origExpr) selClone := exprClone.Fun.(*ast.SelectorExpr) - origActual := handler.GetActualExpr(origSel) + errMethodExists := false + + origActual := handler.GetActualExpr(origSel, &errMethodExists) if origActual == nil { return nil, false } @@ -62,7 +64,7 @@ func New(origExpr *ast.CallExpr, pass *analysis.Pass, handler gomegahandler.Hand return nil, false } - actl, ok := actual.New(origExpr, exprClone, origActual, actualClone, pass, handler, timePkg) + actl, ok := actual.New(origExpr, exprClone, origActual, actualClone, pass, handler, timePkg, errMethodExists) if !ok { return nil, false } diff --git a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/dothandler.go b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/dothandler.go index bd3b93992f..c853ca9063 100644 --- a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/dothandler.go +++ b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/dothandler.go @@ -51,7 +51,7 @@ func (dotHandler) GetNewWrapperMatcher(name string, existing *ast.CallExpr) *ast } } -func (h dotHandler) GetActualExpr(assertionFunc *ast.SelectorExpr) *ast.CallExpr { +func (h dotHandler) GetActualExpr(assertionFunc *ast.SelectorExpr, errMethodExists *bool) *ast.CallExpr { actualExpr, ok := assertionFunc.X.(*ast.CallExpr) if !ok { return nil @@ -66,7 +66,11 @@ func (h dotHandler) GetActualExpr(assertionFunc *ast.SelectorExpr) *ast.CallExpr return actualExpr } } else { - return h.GetActualExpr(fun) + if fun.Sel.Name == "Error" { + *errMethodExists = true + } + + return h.GetActualExpr(fun, errMethodExists) } } return nil diff --git a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/handler.go b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/handler.go index 4dba604a4f..414438ba68 100644 --- a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/handler.go +++ b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/handler.go @@ -18,7 +18,7 @@ type Handler interface { // ReplaceFunction replaces the function with another one, for fix suggestions ReplaceFunction(*ast.CallExpr, *ast.Ident) - GetActualExpr(assertionFunc *ast.SelectorExpr) *ast.CallExpr + GetActualExpr(assertionFunc *ast.SelectorExpr, errMethodExists *bool) *ast.CallExpr GetActualExprClone(origFunc, funcClone *ast.SelectorExpr) *ast.CallExpr diff --git a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/namedhandler.go b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/namedhandler.go index 712442426d..66d5633115 100644 --- a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/namedhandler.go +++ b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/namedhandler.go @@ -51,7 +51,7 @@ func (g nameHandler) isGomegaVar(x ast.Expr) bool { return gomegainfo.IsGomegaVar(x, g.pass) } -func (g nameHandler) GetActualExpr(assertionFunc *ast.SelectorExpr) *ast.CallExpr { +func (g nameHandler) GetActualExpr(assertionFunc *ast.SelectorExpr, errMethodExists *bool) *ast.CallExpr { actualExpr, ok := assertionFunc.X.(*ast.CallExpr) if !ok { return nil @@ -69,7 +69,10 @@ func (g nameHandler) GetActualExpr(assertionFunc *ast.SelectorExpr) *ast.CallExp return actualExpr } } else { - return g.GetActualExpr(fun) + if fun.Sel.Name == "Error" { + *errMethodExists = true + } + return g.GetActualExpr(fun, errMethodExists) } } return nil diff --git a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/errorequalnilrule.go b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/errorequalnilrule.go index 7aaf7631b0..81932cc2c5 100644 --- a/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/errorequalnilrule.go +++ b/tools/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/errorequalnilrule.go @@ -12,8 +12,15 @@ import ( type ErrorEqualNilRule struct{} func (ErrorEqualNilRule) isApplied(gexp *expression.GomegaExpression, config types.Config) bool { - return !bool(config.SuppressErr) && - gexp.ActualArgTypeIs(actual.ErrorTypeArgType) && + if config.SuppressErr { + return false + } + + if !gexp.IsAsync() && gexp.ActualArgTypeIs(actual.FuncSigArgType) { + return false + } + + return gexp.ActualArgTypeIs(actual.ErrorTypeArgType) && gexp.MatcherTypeIs(matcher.BeNilMatcherType|matcher.EqualNilMatcherType) } diff --git a/tools/vendor/github.com/polyfloyd/go-errorlint/errorlint/allowed.go b/tools/vendor/github.com/polyfloyd/go-errorlint/errorlint/allowed.go index cf481708ab..c639af6f37 100644 --- a/tools/vendor/github.com/polyfloyd/go-errorlint/errorlint/allowed.go +++ b/tools/vendor/github.com/polyfloyd/go-errorlint/errorlint/allowed.go @@ -53,6 +53,7 @@ func setDefaultAllowedErrors() { {Err: "io.EOF", Fun: "(*io.SectionReader).Read"}, {Err: "io.EOF", Fun: "(*io.SectionReader).ReadAt"}, {Err: "io.ErrClosedPipe", Fun: "(*io.PipeWriter).Write"}, + {Err: "io.EOF", Fun: "io.ReadAtLeast"}, {Err: "io.ErrShortBuffer", Fun: "io.ReadAtLeast"}, {Err: "io.ErrUnexpectedEOF", Fun: "io.ReadAtLeast"}, {Err: "io.EOF", Fun: "io.ReadFull"}, @@ -84,6 +85,7 @@ func setDefaultAllowedErrors() { {Err: "context.Canceled", Fun: "(context.Context).Err"}, // pkg/encoding/json {Err: "io.EOF", Fun: "(*encoding/json.Decoder).Decode"}, + {Err: "io.EOF", Fun: "(*encoding/json.Decoder).Token"}, // pkg/encoding/csv {Err: "io.EOF", Fun: "(*encoding/csv.Reader).Read"}, // pkg/mime/multipart diff --git a/tools/vendor/github.com/polyfloyd/go-errorlint/errorlint/lint.go b/tools/vendor/github.com/polyfloyd/go-errorlint/errorlint/lint.go index 9ac465c650..ed3dd0dc65 100644 --- a/tools/vendor/github.com/polyfloyd/go-errorlint/errorlint/lint.go +++ b/tools/vendor/github.com/polyfloyd/go-errorlint/errorlint/lint.go @@ -82,7 +82,7 @@ func LintFmtErrorfCalls(fset *token.FileSet, info types.Info, multipleWraps bool argIndex++ } - if verb.format == "w" { + if verb.format == "w" || verb.format == "T" { continue } if argIndex-1 >= len(args) { diff --git a/tools/vendor/github.com/stretchr/testify/assert/assertion_compare.go b/tools/vendor/github.com/stretchr/testify/assert/assertion_compare.go index 4d4b4aad6f..7e19eba090 100644 --- a/tools/vendor/github.com/stretchr/testify/assert/assertion_compare.go +++ b/tools/vendor/github.com/stretchr/testify/assert/assertion_compare.go @@ -7,10 +7,13 @@ import ( "time" ) -type CompareType int +// Deprecated: CompareType has only ever been for internal use and has accidentally been published since v1.6.0. Do not use it. +type CompareType = compareResult + +type compareResult int const ( - compareLess CompareType = iota - 1 + compareLess compareResult = iota - 1 compareEqual compareGreater ) @@ -39,7 +42,7 @@ var ( bytesType = reflect.TypeOf([]byte{}) ) -func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) { +func compare(obj1, obj2 interface{}, kind reflect.Kind) (compareResult, bool) { obj1Value := reflect.ValueOf(obj1) obj2Value := reflect.ValueOf(obj2) @@ -325,7 +328,13 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) { timeObj2 = obj2Value.Convert(timeType).Interface().(time.Time) } - return compare(timeObj1.UnixNano(), timeObj2.UnixNano(), reflect.Int64) + if timeObj1.Before(timeObj2) { + return compareLess, true + } + if timeObj1.Equal(timeObj2) { + return compareEqual, true + } + return compareGreater, true } case reflect.Slice: { @@ -345,7 +354,7 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) { bytesObj2 = obj2Value.Convert(bytesType).Interface().([]byte) } - return CompareType(bytes.Compare(bytesObj1, bytesObj2)), true + return compareResult(bytes.Compare(bytesObj1, bytesObj2)), true } case reflect.Uintptr: { @@ -381,7 +390,7 @@ func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface if h, ok := t.(tHelper); ok { h.Helper() } - return compareTwoValues(t, e1, e2, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...) + return compareTwoValues(t, e1, e2, []compareResult{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...) } // GreaterOrEqual asserts that the first element is greater than or equal to the second @@ -394,7 +403,7 @@ func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...in if h, ok := t.(tHelper); ok { h.Helper() } - return compareTwoValues(t, e1, e2, []CompareType{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...) + return compareTwoValues(t, e1, e2, []compareResult{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...) } // Less asserts that the first element is less than the second @@ -406,7 +415,7 @@ func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) if h, ok := t.(tHelper); ok { h.Helper() } - return compareTwoValues(t, e1, e2, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...) + return compareTwoValues(t, e1, e2, []compareResult{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...) } // LessOrEqual asserts that the first element is less than or equal to the second @@ -419,7 +428,7 @@ func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inter if h, ok := t.(tHelper); ok { h.Helper() } - return compareTwoValues(t, e1, e2, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...) + return compareTwoValues(t, e1, e2, []compareResult{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...) } // Positive asserts that the specified element is positive @@ -431,7 +440,7 @@ func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool { h.Helper() } zero := reflect.Zero(reflect.TypeOf(e)) - return compareTwoValues(t, e, zero.Interface(), []CompareType{compareGreater}, "\"%v\" is not positive", msgAndArgs...) + return compareTwoValues(t, e, zero.Interface(), []compareResult{compareGreater}, "\"%v\" is not positive", msgAndArgs...) } // Negative asserts that the specified element is negative @@ -443,10 +452,10 @@ func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool { h.Helper() } zero := reflect.Zero(reflect.TypeOf(e)) - return compareTwoValues(t, e, zero.Interface(), []CompareType{compareLess}, "\"%v\" is not negative", msgAndArgs...) + return compareTwoValues(t, e, zero.Interface(), []compareResult{compareLess}, "\"%v\" is not negative", msgAndArgs...) } -func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool { +func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() } @@ -469,7 +478,7 @@ func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedCompare return true } -func containsValue(values []CompareType, value CompareType) bool { +func containsValue(values []compareResult, value compareResult) bool { for _, v := range values { if v == value { return true diff --git a/tools/vendor/github.com/stretchr/testify/assert/assertion_format.go b/tools/vendor/github.com/stretchr/testify/assert/assertion_format.go index 3ddab109ad..1906341657 100644 --- a/tools/vendor/github.com/stretchr/testify/assert/assertion_format.go +++ b/tools/vendor/github.com/stretchr/testify/assert/assertion_format.go @@ -104,8 +104,8 @@ func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...) } -// EqualValuesf asserts that two objects are equal or convertible to the same types -// and equal. +// EqualValuesf asserts that two objects are equal or convertible to the larger +// type and equal. // // assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted") func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { @@ -186,7 +186,7 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick // assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") { // // add assertions as needed; any assertion failure will fail the current tick // assert.True(c, externalValue, "expected 'externalValue' to be true") -// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -568,6 +568,23 @@ func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, a return NotContains(t, s, contains, append([]interface{}{msg}, args...)...) } +// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should not match. +// This is an inverse of ElementsMatch. +// +// assert.NotElementsMatchf(t, [1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false +// +// assert.NotElementsMatchf(t, [1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true +// +// assert.NotElementsMatchf(t, [1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> true +func NotElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NotElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...) +} + // NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // @@ -604,7 +621,16 @@ func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg s return NotEqualValues(t, expected, actual, append([]interface{}{msg}, args...)...) } -// NotErrorIsf asserts that at none of the errors in err's chain matches target. +// NotErrorAsf asserts that none of the errors in err's chain matches target, +// but if so, sets target to that error value. +func NotErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NotErrorAs(t, err, target, append([]interface{}{msg}, args...)...) +} + +// NotErrorIsf asserts that none of the errors in err's chain matches target. // This is a wrapper for errors.Is. func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { diff --git a/tools/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/tools/vendor/github.com/stretchr/testify/assert/assertion_forward.go index a84e09bd40..21629087ba 100644 --- a/tools/vendor/github.com/stretchr/testify/assert/assertion_forward.go +++ b/tools/vendor/github.com/stretchr/testify/assert/assertion_forward.go @@ -186,8 +186,8 @@ func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface return EqualExportedValuesf(a.t, expected, actual, msg, args...) } -// EqualValues asserts that two objects are equal or convertible to the same types -// and equal. +// EqualValues asserts that two objects are equal or convertible to the larger +// type and equal. // // a.EqualValues(uint32(123), int32(123)) func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { @@ -197,8 +197,8 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn return EqualValues(a.t, expected, actual, msgAndArgs...) } -// EqualValuesf asserts that two objects are equal or convertible to the same types -// and equal. +// EqualValuesf asserts that two objects are equal or convertible to the larger +// type and equal. // // a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted") func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { @@ -336,7 +336,7 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti // a.EventuallyWithT(func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick // assert.True(c, externalValue, "expected 'externalValue' to be true") -// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -361,7 +361,7 @@ func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor // a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") { // // add assertions as needed; any assertion failure will fail the current tick // assert.True(c, externalValue, "expected 'externalValue' to be true") -// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1128,6 +1128,40 @@ func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg strin return NotContainsf(a.t, s, contains, msg, args...) } +// NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should not match. +// This is an inverse of ElementsMatch. +// +// a.NotElementsMatch([1, 1, 2, 3], [1, 1, 2, 3]) -> false +// +// a.NotElementsMatch([1, 1, 2, 3], [1, 2, 3]) -> true +// +// a.NotElementsMatch([1, 2, 3], [1, 2, 4]) -> true +func (a *Assertions) NotElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotElementsMatch(a.t, listA, listB, msgAndArgs...) +} + +// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should not match. +// This is an inverse of ElementsMatch. +// +// a.NotElementsMatchf([1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false +// +// a.NotElementsMatchf([1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true +// +// a.NotElementsMatchf([1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> true +func (a *Assertions) NotElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotElementsMatchf(a.t, listA, listB, msg, args...) +} + // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // @@ -1200,7 +1234,25 @@ func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg str return NotEqualf(a.t, expected, actual, msg, args...) } -// NotErrorIs asserts that at none of the errors in err's chain matches target. +// NotErrorAs asserts that none of the errors in err's chain matches target, +// but if so, sets target to that error value. +func (a *Assertions) NotErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotErrorAs(a.t, err, target, msgAndArgs...) +} + +// NotErrorAsf asserts that none of the errors in err's chain matches target, +// but if so, sets target to that error value. +func (a *Assertions) NotErrorAsf(err error, target interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotErrorAsf(a.t, err, target, msg, args...) +} + +// NotErrorIs asserts that none of the errors in err's chain matches target. // This is a wrapper for errors.Is. func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { @@ -1209,7 +1261,7 @@ func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface return NotErrorIs(a.t, err, target, msgAndArgs...) } -// NotErrorIsf asserts that at none of the errors in err's chain matches target. +// NotErrorIsf asserts that none of the errors in err's chain matches target. // This is a wrapper for errors.Is. func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { diff --git a/tools/vendor/github.com/stretchr/testify/assert/assertion_order.go b/tools/vendor/github.com/stretchr/testify/assert/assertion_order.go index 00df62a059..1d2f71824a 100644 --- a/tools/vendor/github.com/stretchr/testify/assert/assertion_order.go +++ b/tools/vendor/github.com/stretchr/testify/assert/assertion_order.go @@ -6,7 +6,7 @@ import ( ) // isOrdered checks that collection contains orderable elements. -func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool { +func isOrdered(t TestingT, object interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool { objKind := reflect.TypeOf(object).Kind() if objKind != reflect.Slice && objKind != reflect.Array { return false @@ -50,7 +50,7 @@ func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareT // assert.IsIncreasing(t, []float{1, 2}) // assert.IsIncreasing(t, []string{"a", "b"}) func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - return isOrdered(t, object, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...) + return isOrdered(t, object, []compareResult{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...) } // IsNonIncreasing asserts that the collection is not increasing @@ -59,7 +59,7 @@ func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) boo // assert.IsNonIncreasing(t, []float{2, 1}) // assert.IsNonIncreasing(t, []string{"b", "a"}) func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - return isOrdered(t, object, []CompareType{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...) + return isOrdered(t, object, []compareResult{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...) } // IsDecreasing asserts that the collection is decreasing @@ -68,7 +68,7 @@ func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) // assert.IsDecreasing(t, []float{2, 1}) // assert.IsDecreasing(t, []string{"b", "a"}) func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - return isOrdered(t, object, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...) + return isOrdered(t, object, []compareResult{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...) } // IsNonDecreasing asserts that the collection is not decreasing @@ -77,5 +77,5 @@ func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) boo // assert.IsNonDecreasing(t, []float{1, 2}) // assert.IsNonDecreasing(t, []string{"a", "b"}) func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - return isOrdered(t, object, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...) + return isOrdered(t, object, []compareResult{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...) } diff --git a/tools/vendor/github.com/stretchr/testify/assert/assertions.go b/tools/vendor/github.com/stretchr/testify/assert/assertions.go index 0b7570f21c..4e91332bb5 100644 --- a/tools/vendor/github.com/stretchr/testify/assert/assertions.go +++ b/tools/vendor/github.com/stretchr/testify/assert/assertions.go @@ -19,7 +19,9 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/pmezard/go-difflib/difflib" - "gopkg.in/yaml.v3" + + // Wrapper around gopkg.in/yaml.v3 + "github.com/stretchr/testify/assert/yaml" ) //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_format.go.tmpl" @@ -45,6 +47,10 @@ type BoolAssertionFunc func(TestingT, bool, ...interface{}) bool // for table driven tests. type ErrorAssertionFunc func(TestingT, error, ...interface{}) bool +// PanicAssertionFunc is a common function prototype when validating a panic value. Can be useful +// for table driven tests. +type PanicAssertionFunc = func(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool + // Comparison is a custom function that returns true on success and false on failure type Comparison func() (success bool) @@ -496,7 +502,13 @@ func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) b h.Helper() } - if !samePointers(expected, actual) { + same, ok := samePointers(expected, actual) + if !ok { + return Fail(t, "Both arguments must be pointers", msgAndArgs...) + } + + if !same { + // both are pointers but not the same type & pointing to the same address return Fail(t, fmt.Sprintf("Not same: \n"+ "expected: %p %#v\n"+ "actual : %p %#v", expected, expected, actual, actual), msgAndArgs...) @@ -516,7 +528,13 @@ func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{} h.Helper() } - if samePointers(expected, actual) { + same, ok := samePointers(expected, actual) + if !ok { + //fails when the arguments are not pointers + return !(Fail(t, "Both arguments must be pointers", msgAndArgs...)) + } + + if same { return Fail(t, fmt.Sprintf( "Expected and actual point to the same object: %p %#v", expected, expected), msgAndArgs...) @@ -524,21 +542,23 @@ func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{} return true } -// samePointers compares two generic interface objects and returns whether -// they point to the same object -func samePointers(first, second interface{}) bool { +// samePointers checks if two generic interface objects are pointers of the same +// type pointing to the same object. It returns two values: same indicating if +// they are the same type and point to the same object, and ok indicating that +// both inputs are pointers. +func samePointers(first, second interface{}) (same bool, ok bool) { firstPtr, secondPtr := reflect.ValueOf(first), reflect.ValueOf(second) if firstPtr.Kind() != reflect.Ptr || secondPtr.Kind() != reflect.Ptr { - return false + return false, false //not both are pointers } firstType, secondType := reflect.TypeOf(first), reflect.TypeOf(second) if firstType != secondType { - return false + return false, true // both are pointers, but of different types } // compare pointer addresses - return first == second + return first == second, true } // formatUnequalValues takes two values of arbitrary types and returns string @@ -572,8 +592,8 @@ func truncatingFormat(data interface{}) string { return value } -// EqualValues asserts that two objects are equal or convertible to the same types -// and equal. +// EqualValues asserts that two objects are equal or convertible to the larger +// type and equal. // // assert.EqualValues(t, uint32(123), int32(123)) func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { @@ -615,21 +635,6 @@ func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs .. return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...) } - if aType.Kind() == reflect.Ptr { - aType = aType.Elem() - } - if bType.Kind() == reflect.Ptr { - bType = bType.Elem() - } - - if aType.Kind() != reflect.Struct { - return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", aType.Kind(), reflect.Struct), msgAndArgs...) - } - - if bType.Kind() != reflect.Struct { - return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", bType.Kind(), reflect.Struct), msgAndArgs...) - } - expected = copyExportedFields(expected) actual = copyExportedFields(actual) @@ -1170,6 +1175,39 @@ func formatListDiff(listA, listB interface{}, extraA, extraB []interface{}) stri return msg.String() } +// NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should not match. +// This is an inverse of ElementsMatch. +// +// assert.NotElementsMatch(t, [1, 1, 2, 3], [1, 1, 2, 3]) -> false +// +// assert.NotElementsMatch(t, [1, 1, 2, 3], [1, 2, 3]) -> true +// +// assert.NotElementsMatch(t, [1, 2, 3], [1, 2, 4]) -> true +func NotElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if isEmpty(listA) && isEmpty(listB) { + return Fail(t, "listA and listB contain the same elements", msgAndArgs) + } + + if !isList(t, listA, msgAndArgs...) { + return Fail(t, "listA is not a list type", msgAndArgs...) + } + if !isList(t, listB, msgAndArgs...) { + return Fail(t, "listB is not a list type", msgAndArgs...) + } + + extraA, extraB := diffLists(listA, listB) + if len(extraA) == 0 && len(extraB) == 0 { + return Fail(t, "listA and listB contain the same elements", msgAndArgs) + } + + return true +} + // Condition uses a Comparison to assert a complex condition. func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { @@ -1488,6 +1526,9 @@ func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAnd if err != nil { return Fail(t, err.Error(), msgAndArgs...) } + if math.IsNaN(actualEpsilon) { + return Fail(t, "relative error is NaN", msgAndArgs...) + } if actualEpsilon > epsilon { return Fail(t, fmt.Sprintf("Relative error is too high: %#v (expected)\n"+ " < %#v (actual)", epsilon, actualEpsilon), msgAndArgs...) @@ -1611,7 +1652,6 @@ func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...in // matchRegexp return true if a specified regexp matches a string. func matchRegexp(rx interface{}, str interface{}) bool { - var r *regexp.Regexp if rr, ok := rx.(*regexp.Regexp); ok { r = rr @@ -1619,7 +1659,14 @@ func matchRegexp(rx interface{}, str interface{}) bool { r = regexp.MustCompile(fmt.Sprint(rx)) } - return (r.FindStringIndex(fmt.Sprint(str)) != nil) + switch v := str.(type) { + case []byte: + return r.Match(v) + case string: + return r.MatchString(v) + default: + return r.MatchString(fmt.Sprint(v)) + } } @@ -1872,7 +1919,7 @@ var spewConfigStringerEnabled = spew.ConfigState{ MaxDepth: 10, } -type tHelper interface { +type tHelper = interface { Helper() } @@ -1911,6 +1958,9 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t // CollectT implements the TestingT interface and collects all errors. type CollectT struct { + // A slice of errors. Non-nil slice denotes a failure. + // If it's non-nil but len(c.errors) == 0, this is also a failure + // obtained by direct c.FailNow() call. errors []error } @@ -1919,9 +1969,10 @@ func (c *CollectT) Errorf(format string, args ...interface{}) { c.errors = append(c.errors, fmt.Errorf(format, args...)) } -// FailNow panics. -func (*CollectT) FailNow() { - panic("Assertion failed") +// FailNow stops execution by calling runtime.Goexit. +func (c *CollectT) FailNow() { + c.fail() + runtime.Goexit() } // Deprecated: That was a method for internal usage that should not have been published. Now just panics. @@ -1934,6 +1985,16 @@ func (*CollectT) Copy(TestingT) { panic("Copy() is deprecated") } +func (c *CollectT) fail() { + if !c.failed() { + c.errors = []error{} // Make it non-nil to mark a failure. + } +} + +func (c *CollectT) failed() bool { + return c.errors != nil +} + // EventuallyWithT asserts that given condition will be met in waitFor time, // periodically checking target function each tick. In contrast to Eventually, // it supplies a CollectT to the condition function, so that the condition @@ -1951,14 +2012,14 @@ func (*CollectT) Copy(TestingT) { // assert.EventuallyWithT(t, func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick // assert.True(c, externalValue, "expected 'externalValue' to be true") -// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() } var lastFinishedTickErrs []error - ch := make(chan []error, 1) + ch := make(chan *CollectT, 1) timer := time.NewTimer(waitFor) defer timer.Stop() @@ -1978,16 +2039,16 @@ func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time go func() { collect := new(CollectT) defer func() { - ch <- collect.errors + ch <- collect }() condition(collect) }() - case errs := <-ch: - if len(errs) == 0 { + case collect := <-ch: + if !collect.failed() { return true } // Keep the errors from the last ended condition, so that they can be copied to t if timeout is reached. - lastFinishedTickErrs = errs + lastFinishedTickErrs = collect.errors tick = ticker.C } } @@ -2049,7 +2110,7 @@ func ErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool { ), msgAndArgs...) } -// NotErrorIs asserts that at none of the errors in err's chain matches target. +// NotErrorIs asserts that none of the errors in err's chain matches target. // This is a wrapper for errors.Is. func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { @@ -2090,6 +2151,24 @@ func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{ ), msgAndArgs...) } +// NotErrorAs asserts that none of the errors in err's chain matches target, +// but if so, sets target to that error value. +func NotErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if !errors.As(err, target) { + return true + } + + chain := buildErrorChainString(err) + + return Fail(t, fmt.Sprintf("Target error should not be in err chain:\n"+ + "found: %q\n"+ + "in chain: %s", target, chain, + ), msgAndArgs...) +} + func buildErrorChainString(err error) string { if err == nil { return "" diff --git a/tools/vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go b/tools/vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go new file mode 100644 index 0000000000..baa0cc7d7f --- /dev/null +++ b/tools/vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go @@ -0,0 +1,25 @@ +//go:build testify_yaml_custom && !testify_yaml_fail && !testify_yaml_default +// +build testify_yaml_custom,!testify_yaml_fail,!testify_yaml_default + +// Package yaml is an implementation of YAML functions that calls a pluggable implementation. +// +// This implementation is selected with the testify_yaml_custom build tag. +// +// go test -tags testify_yaml_custom +// +// This implementation can be used at build time to replace the default implementation +// to avoid linking with [gopkg.in/yaml.v3]. +// +// In your test package: +// +// import assertYaml "github.com/stretchr/testify/assert/yaml" +// +// func init() { +// assertYaml.Unmarshal = func (in []byte, out interface{}) error { +// // ... +// return nil +// } +// } +package yaml + +var Unmarshal func(in []byte, out interface{}) error diff --git a/tools/vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go b/tools/vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go new file mode 100644 index 0000000000..b83c6cf64c --- /dev/null +++ b/tools/vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go @@ -0,0 +1,37 @@ +//go:build !testify_yaml_fail && !testify_yaml_custom +// +build !testify_yaml_fail,!testify_yaml_custom + +// Package yaml is just an indirection to handle YAML deserialization. +// +// This package is just an indirection that allows the builder to override the +// indirection with an alternative implementation of this package that uses +// another implementation of YAML deserialization. This allows to not either not +// use YAML deserialization at all, or to use another implementation than +// [gopkg.in/yaml.v3] (for example for license compatibility reasons, see [PR #1120]). +// +// Alternative implementations are selected using build tags: +// +// - testify_yaml_fail: [Unmarshal] always fails with an error +// - testify_yaml_custom: [Unmarshal] is a variable. Caller must initialize it +// before calling any of [github.com/stretchr/testify/assert.YAMLEq] or +// [github.com/stretchr/testify/assert.YAMLEqf]. +// +// Usage: +// +// go test -tags testify_yaml_fail +// +// You can check with "go list" which implementation is linked: +// +// go list -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml +// go list -tags testify_yaml_fail -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml +// go list -tags testify_yaml_custom -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml +// +// [PR #1120]: https://github.com/stretchr/testify/pull/1120 +package yaml + +import goyaml "gopkg.in/yaml.v3" + +// Unmarshal is just a wrapper of [gopkg.in/yaml.v3.Unmarshal]. +func Unmarshal(in []byte, out interface{}) error { + return goyaml.Unmarshal(in, out) +} diff --git a/tools/vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go b/tools/vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go new file mode 100644 index 0000000000..e78f7dfe69 --- /dev/null +++ b/tools/vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go @@ -0,0 +1,18 @@ +//go:build testify_yaml_fail && !testify_yaml_custom && !testify_yaml_default +// +build testify_yaml_fail,!testify_yaml_custom,!testify_yaml_default + +// Package yaml is an implementation of YAML functions that always fail. +// +// This implementation can be used at build time to replace the default implementation +// to avoid linking with [gopkg.in/yaml.v3]: +// +// go test -tags testify_yaml_fail +package yaml + +import "errors" + +var errNotImplemented = errors.New("YAML functions are not available (see https://pkg.go.dev/github.com/stretchr/testify/assert/yaml)") + +func Unmarshal([]byte, interface{}) error { + return errNotImplemented +} diff --git a/tools/vendor/github.com/stretchr/testify/mock/mock.go b/tools/vendor/github.com/stretchr/testify/mock/mock.go index 213bde2ea6..eb5682df97 100644 --- a/tools/vendor/github.com/stretchr/testify/mock/mock.go +++ b/tools/vendor/github.com/stretchr/testify/mock/mock.go @@ -80,12 +80,12 @@ type Call struct { requires []*Call } -func newCall(parent *Mock, methodName string, callerInfo []string, methodArguments ...interface{}) *Call { +func newCall(parent *Mock, methodName string, callerInfo []string, methodArguments Arguments, returnArguments Arguments) *Call { return &Call{ Parent: parent, Method: methodName, Arguments: methodArguments, - ReturnArguments: make([]interface{}, 0), + ReturnArguments: returnArguments, callerInfo: callerInfo, Repeatability: 0, WaitFor: nil, @@ -256,7 +256,7 @@ func (c *Call) Unset() *Call { // calls have been called as expected. The referenced calls may be from the // same mock instance and/or other mock instances. // -// Mock.On("Do").Return(nil).Notbefore( +// Mock.On("Do").Return(nil).NotBefore( // Mock.On("Init").Return(nil) // ) func (c *Call) NotBefore(calls ...*Call) *Call { @@ -273,6 +273,20 @@ func (c *Call) NotBefore(calls ...*Call) *Call { return c } +// InOrder defines the order in which the calls should be made +// +// For example: +// +// InOrder( +// Mock.On("init").Return(nil), +// Mock.On("Do").Return(nil), +// ) +func InOrder(calls ...*Call) { + for i := 1; i < len(calls); i++ { + calls[i].NotBefore(calls[i-1]) + } +} + // Mock is the workhorse used to track activity on another object. // For an example of its usage, refer to the "Example Usage" section at the top // of this document. @@ -351,7 +365,8 @@ func (m *Mock) On(methodName string, arguments ...interface{}) *Call { m.mutex.Lock() defer m.mutex.Unlock() - c := newCall(m, methodName, assert.CallerInfo(), arguments...) + + c := newCall(m, methodName, assert.CallerInfo(), arguments, make([]interface{}, 0)) m.ExpectedCalls = append(m.ExpectedCalls, c) return c } @@ -491,11 +506,12 @@ func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Argumen m.mutex.Unlock() if closestCall != nil { - m.fail("\n\nmock: Unexpected Method Call\n-----------------------------\n\n%s\n\nThe closest call I have is: \n\n%s\n\n%s\nDiff: %s", + m.fail("\n\nmock: Unexpected Method Call\n-----------------------------\n\n%s\n\nThe closest call I have is: \n\n%s\n\n%s\nDiff: %s\nat: %s\n", callString(methodName, arguments, true), callString(methodName, closestCall.Arguments, true), diffArguments(closestCall.Arguments, arguments), strings.TrimSpace(mismatch), + assert.CallerInfo(), ) } else { m.fail("\nassert: mock: I don't know what to return because the method call was unexpected.\n\tEither do Mock.On(\"%s\").Return(...) first, or remove the %s() call.\n\tThis method was unexpected:\n\t\t%s\n\tat: %s", methodName, methodName, callString(methodName, arguments, true), assert.CallerInfo()) @@ -529,7 +545,7 @@ func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Argumen call.totalCalls++ // add the call - m.Calls = append(m.Calls, *newCall(m, methodName, assert.CallerInfo(), arguments...)) + m.Calls = append(m.Calls, *newCall(m, methodName, assert.CallerInfo(), arguments, call.ReturnArguments)) m.mutex.Unlock() // block if specified @@ -764,9 +780,17 @@ const ( ) // AnythingOfTypeArgument contains the type of an argument -// for use when type checking. Used in Diff and Assert. +// for use when type checking. Used in [Arguments.Diff] and [Arguments.Assert]. // -// Deprecated: this is an implementation detail that must not be used. Use [AnythingOfType] instead. +// Deprecated: this is an implementation detail that must not be used. Use the [AnythingOfType] constructor instead, example: +// +// m.On("Do", mock.AnythingOfType("string")) +// +// All explicit type declarations can be replaced with interface{} as is expected by [Mock.On], example: +// +// func anyString interface{} { +// return mock.AnythingOfType("string") +// } type AnythingOfTypeArgument = anythingOfTypeArgument // anythingOfTypeArgument is a string that contains the type of an argument @@ -780,53 +804,54 @@ type anythingOfTypeArgument string // // For example: // -// Assert(t, AnythingOfType("string"), AnythingOfType("int")) +// args.Assert(t, AnythingOfType("string"), AnythingOfType("int")) func AnythingOfType(t string) AnythingOfTypeArgument { return anythingOfTypeArgument(t) } // IsTypeArgument is a struct that contains the type of an argument -// for use when type checking. This is an alternative to AnythingOfType. -// Used in Diff and Assert. +// for use when type checking. This is an alternative to [AnythingOfType]. +// Used in [Arguments.Diff] and [Arguments.Assert]. type IsTypeArgument struct { t reflect.Type } // IsType returns an IsTypeArgument object containing the type to check for. // You can provide a zero-value of the type to check. This is an -// alternative to AnythingOfType. Used in Diff and Assert. +// alternative to [AnythingOfType]. Used in [Arguments.Diff] and [Arguments.Assert]. // // For example: -// Assert(t, IsType(""), IsType(0)) +// +// args.Assert(t, IsType(""), IsType(0)) func IsType(t interface{}) *IsTypeArgument { return &IsTypeArgument{t: reflect.TypeOf(t)} } -// FunctionalOptionsArgument is a struct that contains the type and value of an functional option argument -// for use when type checking. +// FunctionalOptionsArgument contains a list of functional options arguments +// expected for use when matching a list of arguments. type FunctionalOptionsArgument struct { - value interface{} + values []interface{} } // String returns the string representation of FunctionalOptionsArgument func (f *FunctionalOptionsArgument) String() string { var name string - tValue := reflect.ValueOf(f.value) - if tValue.Len() > 0 { - name = "[]" + reflect.TypeOf(tValue.Index(0).Interface()).String() + if len(f.values) > 0 { + name = "[]" + reflect.TypeOf(f.values[0]).String() } - return strings.Replace(fmt.Sprintf("%#v", f.value), "[]interface {}", name, 1) + return strings.Replace(fmt.Sprintf("%#v", f.values), "[]interface {}", name, 1) } -// FunctionalOptions returns an FunctionalOptionsArgument object containing the functional option type -// and the values to check of +// FunctionalOptions returns an [FunctionalOptionsArgument] object containing +// the expected functional-options to check for. // // For example: -// Assert(t, FunctionalOptions("[]foo.FunctionalOption", foo.Opt1(), foo.Opt2())) -func FunctionalOptions(value ...interface{}) *FunctionalOptionsArgument { +// +// args.Assert(t, FunctionalOptions(foo.Opt1("strValue"), foo.Opt2(613))) +func FunctionalOptions(values ...interface{}) *FunctionalOptionsArgument { return &FunctionalOptionsArgument{ - value: value, + values: values, } } @@ -873,10 +898,11 @@ func (f argumentMatcher) String() string { // and false otherwise. // // Example: -// m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" })) // -// |fn|, must be a function accepting a single argument (of the expected type) -// which returns a bool. If |fn| doesn't match the required signature, +// m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" })) +// +// fn must be a function accepting a single argument (of the expected type) +// which returns a bool. If fn doesn't match the required signature, // MatchedBy() panics. func MatchedBy(fn interface{}) argumentMatcher { fnType := reflect.TypeOf(fn) @@ -979,20 +1005,17 @@ func (args Arguments) Diff(objects []interface{}) (string, int) { output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, expected.t.Name(), actualT.Name(), actualFmt) } case *FunctionalOptionsArgument: - t := expected.value - var name string - tValue := reflect.ValueOf(t) - if tValue.Len() > 0 { - name = "[]" + reflect.TypeOf(tValue.Index(0).Interface()).String() + if len(expected.values) > 0 { + name = "[]" + reflect.TypeOf(expected.values[0]).String() } - tName := reflect.TypeOf(t).Name() - if name != reflect.TypeOf(actual).String() && tValue.Len() != 0 { + const tName = "[]interface{}" + if name != reflect.TypeOf(actual).String() && len(expected.values) != 0 { differences++ output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, tName, reflect.TypeOf(actual).Name(), actualFmt) } else { - if ef, af := assertOpts(t, actual); ef == "" && af == "" { + if ef, af := assertOpts(expected.values, actual); ef == "" && af == "" { // match output = fmt.Sprintf("%s\t%d: PASS: %s == %s\n", output, i, tName, tName) } else { @@ -1092,7 +1115,7 @@ func (args Arguments) Error(index int) error { return nil } if s, ok = obj.(error); !ok { - panic(fmt.Sprintf("assert: arguments: Error(%d) failed because object wasn't correct type: %v", index, args.Get(index))) + panic(fmt.Sprintf("assert: arguments: Error(%d) failed because object wasn't correct type: %v", index, obj)) } return s } @@ -1181,32 +1204,38 @@ type tHelper interface { func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { expectedOpts := reflect.ValueOf(expected) actualOpts := reflect.ValueOf(actual) + + var expectedFuncs []*runtime.Func var expectedNames []string for i := 0; i < expectedOpts.Len(); i++ { - expectedNames = append(expectedNames, funcName(expectedOpts.Index(i).Interface())) + f := runtimeFunc(expectedOpts.Index(i).Interface()) + expectedFuncs = append(expectedFuncs, f) + expectedNames = append(expectedNames, funcName(f)) } + var actualFuncs []*runtime.Func var actualNames []string for i := 0; i < actualOpts.Len(); i++ { - actualNames = append(actualNames, funcName(actualOpts.Index(i).Interface())) + f := runtimeFunc(actualOpts.Index(i).Interface()) + actualFuncs = append(actualFuncs, f) + actualNames = append(actualNames, funcName(f)) } - if !assert.ObjectsAreEqual(expectedNames, actualNames) { + + if expectedOpts.Len() != actualOpts.Len() { expectedFmt = fmt.Sprintf("%v", expectedNames) actualFmt = fmt.Sprintf("%v", actualNames) return } for i := 0; i < expectedOpts.Len(); i++ { - expectedOpt := expectedOpts.Index(i).Interface() - actualOpt := actualOpts.Index(i).Interface() - - expectedFunc := expectedNames[i] - actualFunc := actualNames[i] - if expectedFunc != actualFunc { - expectedFmt = expectedFunc - actualFmt = actualFunc + if !isFuncSame(expectedFuncs[i], actualFuncs[i]) { + expectedFmt = expectedNames[i] + actualFmt = actualNames[i] return } + expectedOpt := expectedOpts.Index(i).Interface() + actualOpt := actualOpts.Index(i).Interface() + ot := reflect.TypeOf(expectedOpt) var expectedValues []reflect.Value var actualValues []reflect.Value @@ -1224,9 +1253,9 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { reflect.ValueOf(actualOpt).Call(actualValues) for i := 0; i < ot.NumIn(); i++ { - if !assert.ObjectsAreEqual(expectedValues[i].Interface(), actualValues[i].Interface()) { - expectedFmt = fmt.Sprintf("%s %+v", expectedNames[i], expectedValues[i].Interface()) - actualFmt = fmt.Sprintf("%s %+v", expectedNames[i], actualValues[i].Interface()) + if expectedArg, actualArg := expectedValues[i].Interface(), actualValues[i].Interface(); !assert.ObjectsAreEqual(expectedArg, actualArg) { + expectedFmt = fmt.Sprintf("%s(%T) -> %#v", expectedNames[i], expectedArg, expectedArg) + actualFmt = fmt.Sprintf("%s(%T) -> %#v", expectedNames[i], actualArg, actualArg) return } } @@ -1235,7 +1264,25 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { return "", "" } -func funcName(opt interface{}) string { - n := runtime.FuncForPC(reflect.ValueOf(opt).Pointer()).Name() - return strings.TrimSuffix(path.Base(n), path.Ext(n)) +func runtimeFunc(opt interface{}) *runtime.Func { + return runtime.FuncForPC(reflect.ValueOf(opt).Pointer()) +} + +func funcName(f *runtime.Func) string { + name := f.Name() + trimmed := strings.TrimSuffix(path.Base(name), path.Ext(name)) + splitted := strings.Split(trimmed, ".") + + if len(splitted) == 0 { + return trimmed + } + + return splitted[len(splitted)-1] +} + +func isFuncSame(f1, f2 *runtime.Func) bool { + f1File, f1Loc := f1.FileLine(f1.Entry()) + f2File, f2Loc := f2.FileLine(f2.Entry()) + + return f1File == f2File && f1Loc == f2Loc } diff --git a/tools/vendor/github.com/uudashr/iface/opaque/opaque.go b/tools/vendor/github.com/uudashr/iface/opaque/opaque.go index fda0f001ba..f8b7bf4c65 100644 --- a/tools/vendor/github.com/uudashr/iface/opaque/opaque.go +++ b/tools/vendor/github.com/uudashr/iface/opaque/opaque.go @@ -53,6 +53,11 @@ func (r *runner) run(pass *analysis.Pass) (interface{}, error) { return } + if funcDecl.Body == nil { + // skip functions without body + return + } + if funcDecl.Type.Results == nil { // skip functions without return values return @@ -133,7 +138,7 @@ func (r *runner) run(pass *analysis.Pass) (interface{}, error) { typ := pass.TypesInfo.TypeOf(res) switch typ := typ.(type) { case *types.Tuple: - for i := 0; i < typ.Len(); i++ { + for i := range typ.Len() { v := typ.At(i) vTyp := v.Type() retStmtTypes[i][vTyp] = struct{}{} diff --git a/tools/vendor/modules.txt b/tools/vendor/modules.txt index 99f89fcb49..2471792a26 100644 --- a/tools/vendor/modules.txt +++ b/tools/vendor/modules.txt @@ -16,7 +16,7 @@ github.com/Antonboom/errname/pkg/analyzer # github.com/Antonboom/nilnil v1.0.0 ## explicit; go 1.22.0 github.com/Antonboom/nilnil/pkg/analyzer -# github.com/Antonboom/testifylint v1.5.0 +# github.com/Antonboom/testifylint v1.5.2 ## explicit; go 1.22.1 github.com/Antonboom/testifylint/analyzer github.com/Antonboom/testifylint/internal/analysisutil @@ -28,7 +28,7 @@ github.com/Antonboom/testifylint/internal/testify ## explicit; go 1.18 github.com/BurntSushi/toml github.com/BurntSushi/toml/internal -# github.com/Crocmagnon/fatcontext v0.5.2 +# github.com/Crocmagnon/fatcontext v0.5.3 ## explicit; go 1.22.0 github.com/Crocmagnon/fatcontext/pkg/analyzer # github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 @@ -234,7 +234,7 @@ github.com/golangci/go-printf-func-name/pkg/analyzer github.com/golangci/gofmt/gofmt github.com/golangci/gofmt/gofmt/internal/diff github.com/golangci/gofmt/goimports -# github.com/golangci/golangci-lint v1.62.0 +# github.com/golangci/golangci-lint v1.62.2 ## explicit; go 1.22.1 github.com/golangci/golangci-lint/cmd/golangci-lint github.com/golangci/golangci-lint/internal/cache @@ -507,7 +507,7 @@ github.com/mattn/go-runewidth # github.com/matttproud/golang_protobuf_extensions v1.0.1 ## explicit github.com/matttproud/golang_protobuf_extensions/pbutil -# github.com/mgechev/revive v1.5.0 +# github.com/mgechev/revive v1.5.1 ## explicit; go 1.22.1 github.com/mgechev/revive/config github.com/mgechev/revive/formatter @@ -535,7 +535,7 @@ github.com/nishanths/exhaustive # github.com/nishanths/predeclared v0.2.2 ## explicit; go 1.14 github.com/nishanths/predeclared/passes/predeclared -# github.com/nunnatsa/ginkgolinter v0.18.0 +# github.com/nunnatsa/ginkgolinter v0.18.3 ## explicit; go 1.22.0 github.com/nunnatsa/ginkgolinter github.com/nunnatsa/ginkgolinter/internal/expression @@ -570,7 +570,7 @@ github.com/pelletier/go-toml/v2/unstable # github.com/pmezard/go-difflib v1.0.0 ## explicit github.com/pmezard/go-difflib/difflib -# github.com/polyfloyd/go-errorlint v1.6.0 +# github.com/polyfloyd/go-errorlint v1.7.0 ## explicit; go 1.20 github.com/polyfloyd/go-errorlint/errorlint # github.com/prometheus/client_golang v1.12.1 @@ -722,9 +722,10 @@ github.com/stbenjam/no-sprintf-host-port/pkg/analyzer # github.com/stretchr/objx v0.5.2 ## explicit; go 1.20 github.com/stretchr/objx -# github.com/stretchr/testify v1.9.0 +# github.com/stretchr/testify v1.10.0 ## explicit; go 1.17 github.com/stretchr/testify/assert +github.com/stretchr/testify/assert/yaml github.com/stretchr/testify/mock # github.com/subosito/gotenv v1.4.1 ## explicit; go 1.18 @@ -763,8 +764,8 @@ github.com/ultraware/whitespace # github.com/uudashr/gocognit v1.1.3 ## explicit; go 1.18 github.com/uudashr/gocognit -# github.com/uudashr/iface v1.2.0 -## explicit; go 1.21.0 +# github.com/uudashr/iface v1.2.1 +## explicit; go 1.22.1 github.com/uudashr/iface/identical github.com/uudashr/iface/internal/directive github.com/uudashr/iface/opaque @@ -816,7 +817,7 @@ go.uber.org/zap/zapcore ## explicit; go 1.22.0 golang.org/x/exp/constraints golang.org/x/exp/maps -# golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0 +# golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f ## explicit; go 1.18 golang.org/x/exp/typeparams # golang.org/x/mod v0.22.0