I'd be nice to be able to disable go vet's -composites analysis.
Thanks for considering.
golangci-lint --version (or git commit if you don't use binary distribution)$ golangci-lint --version
golangci-lint has version 1.15.0 built from 901cf25 on 2019-02-18T08:24:43Z
cat .golangci.ymllinters:
disable-all: true
enable:
- errcheck
- golint
- vet
- ineffassign
- unconvert
- misspell
linters-settings:
gocyclo:
min-complexity: 11
errcheck:
ignore: fmt:.*,io/ioutil:^Read.*,github.com/spf13/cobra:MarkFlagRequired,github.com/spf13/viper:BindPFlag
golint:
min-confidence: 1.1
run:
tests: false
go version && go env$ go version && go env
go version go1.12.1 linux/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/alessio/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/alessio/work/tendermint"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/alessio/work/tendermint/src/github.com/cosmos/cosmos-sdk/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build889440970=/tmp/go-build -gno-record-gcc-switches"
golangci-lint run -v$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/alessio/work/tendermint/src/github.com/cosmos/cosmos-sdk /home/alessio/work/tendermint/src/github.com/cosmos /home/alessio/work/tendermint/src/github.com /home/alessio/work/tendermint/src /home/alessio/work/tendermint /home/alessio/work /home/alessio /home /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 6 linters: [errcheck golint govet ineffassign misspell unconvert]
INFO [loader] Go packages loading at mode load types and syntax took 622.618185ms
INFO [loader/astcache] Parsed AST of all pkg.GoFiles: [] for 251ns
INFO [runner] worker.1 took 1.507碌s
INFO [runner] worker.6 took 1.63碌s
INFO [runner] worker.4 took 20.620196ms with stages: errcheck: 20.613662ms
INFO [runner] worker.7 took 21.335645ms with stages: unconvert: 21.321962ms
client/lcd/certificates.go:148:9: Error return value of `h.Write` is not checked (errcheck)
h.Write(cert.Raw)
^
client/lcd/test_helpers.go:230:15: Error return value of `genDoc.SaveAs` is not checked (errcheck)
genDoc.SaveAs(genesisFile)
^
client/lcd/test_helpers.go:340:12: Error return value of `node.Stop` is not checked (errcheck)
node.Stop()
^
client/lcd/test_helpers.go:397:26: Error return value of `tmrpc.StartHTTPServer` is not checked (errcheck)
go tmrpc.StartHTTPServer(listener, rs.Mux, logger)
^
client/rest/rest.go:70:9: Error return value of `w.Write` is not checked (errcheck)
w.Write(output)
^
client/rpc/block.go:119:11: Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte("ERROR: Couldn't parse block height. Assumed format is '/block/{height}'."))
^
client/rpc/block.go:125:11: Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte("ERROR: Requested block height is bigger then the chain length."))
^
client/tx/broadcast.go:113:22: Error return value of `cliCtx.PrintOutput` is not checked (errcheck)
cliCtx.PrintOutput(res)
^
client/tx/encode.go:100:22: Error return value of `cliCtx.PrintOutput` is not checked (errcheck)
cliCtx.PrintOutput(response)
^
client/utils/utils.go:105:20: Error return value of `cliCtx.PrintOutput` is not checked (errcheck)
cliCtx.PrintOutput(res)
^
x/auth/client/cli/multisign.go:108:38: Error return value of `multisigSig.AddSignatureFromPubKey` is not checked (errcheck)
multisigSig.AddSignatureFromPubKey(stdSig.Signature, stdSig.PubKey, multisigPub.PubKeys)
^
x/gov/client/cli/query.go:178:21: Error return value of `cdc.UnmarshalJSON` is not checked (errcheck)
cdc.UnmarshalJSON(res, &vote)
^
x/gov/client/cli/query.go:185:22: Error return value of `cdc.UnmarshalJSON` is not checked (errcheck)
cdc.UnmarshalJSON(res, &vote)
^
x/gov/client/rest/rest.go:349:20: Error return value of `cdc.UnmarshalJSON` is not checked (errcheck)
cdc.UnmarshalJSON(res, &deposit)
^
INFO [runner] worker.3 took 181.194741ms with stages: misspell: 181.189034ms
INFO [runner] worker.8 took 216.291757ms with stages: ineffassign: 216.280904ms
INFO [runner] worker.2 took 643.027863ms with stages: govet: 643.018803ms
store/cachemulti/store.go:60:24: `dbadapter.Store` composite literal uses unkeyed fields (govet)
return NewFromKVStore(dbadapter.Store{db}, stores, keys, traceWriter, traceContext)
^
store/transient/store.go:21:16: `dbadapter.Store` composite literal uses unkeyed fields (govet)
return &Store{dbadapter.Store{dbm.NewMemDB()}}
^
store/transient/store.go:27:13: `dbadapter.Store` composite literal uses unkeyed fields (govet)
ts.Store = dbadapter.Store{dbm.NewMemDB()}
^
x/staking/types/params.go:59:3: `subspace.ParamSetPair` composite literal uses unkeyed fields (govet)
{KeyUnbondingTime, &p.UnbondingTime},
^
x/staking/types/params.go:60:3: `subspace.ParamSetPair` composite literal uses unkeyed fields (govet)
{KeyMaxValidators, &p.MaxValidators},
^
x/staking/types/params.go:61:3: `subspace.ParamSetPair` composite literal uses unkeyed fields (govet)
{KeyMaxEntries, &p.MaxEntries},
^
x/staking/keeper/test_common.go:135:5: `types.Coin` composite literal uses unkeyed fields (govet)
{keeper.BondDenom(ctx), initCoins},
^
x/staking/genesis.go:115:53: `types.LastValidatorPower` composite literal uses unkeyed fields (govet)
lastValidatorPowers = append(lastValidatorPowers, types.LastValidatorPower{addr, power})
^
x/slashing/params.go:53:9: Sprintf format %d has arg p.SlashFractionDoubleSign of wrong type github.com/cosmos/cosmos-sdk/types.Dec (govet)
return fmt.Sprintf(`Slashing Params:
^
x/slashing/test_common.go:85:4: `types.Coin` composite literal uses unkeyed fields (govet)
{sk.GetParams(ctx).BondDenom, initCoins},
^
client/lcd/test_helpers.go:562:8: `keys.AddNewKey` composite literal uses unkeyed fields (govet)
pk := clientkeys.AddNewKey{name, password, mnemonic, account, index}
^
client/lcd/test_helpers.go:588:8: `keys.RecoverKey` composite literal uses unkeyed fields (govet)
pk := clientkeys.RecoverKey{recoverPassword, mnemonic, int(account), int(index)}
^
client/lcd/test_helpers.go:616:8: `keys.UpdateKeyReq` composite literal uses unkeyed fields (govet)
kr := clientkeys.UpdateKeyReq{oldPassword, newPassword}
^
client/lcd/test_helpers.go:630:8: `keys.DeleteKeyReq` composite literal uses unkeyed fields (govet)
dk := clientkeys.DeleteKeyReq{password}
^
INFO [runner] worker.5 took 2.432092815s with stages: golint: 2.432082822s
INFO [runner] Workers idle times: #1: 2.431957654s, #2: 1.789051819s, #3: 2.250824808s, #4: 2.411384793s, #6: 2.431914589s, #7: 2.410649961s, #8: 2.215745214s
INFO [runner/max_same_issues] 14/17 issues with text "Error return value of `w.Write` is not checked" were hidden, use --max-same-issues
INFO [runner/max_same_issues] 7/10 issues with text "`subspace.ParamSetPair` composite literal uses unkeyed fields" were hidden, use --max-same-issues
INFO [runner/max_same_issues] 1/4 issues with text "Error return value of `cdc.UnmarshalJSON` is not checked" were hidden, use --max-same-issues
INFO [runner/max_same_issues] 1/4 issues with text "`dbadapter.Store` composite literal uses unkeyed fields" were hidden, use --max-same-issues
INFO [runner] Issues before processing: 85, after processing: 28
INFO [runner] processing took 31.13324ms with stages: nolint: 10.764659ms, exclude: 10.210366ms, identifier_marker: 3.704013ms, autogenerated_exclude: 2.342808ms, skip_dirs: 1.609554ms, path_prettifier: 1.163413ms, source_code: 726.128碌s, cgo: 369.901碌s, max_same_issues: 112.382碌s, uniq_by_line: 52.871碌s, path_shortener: 23.154碌s, max_from_linter: 18.218碌s, replacement_builder: 17.875碌s, max_per_file_from_linter: 14.894碌s, exclude-rules: 1.24碌s, diff: 1.107碌s, skip_files: 657ns
INFO Memory: 31 samples, avg is 224.8MB, max is 270.2MB
INFO Execution took 3.093984782s
hi!
I've commented in the pull request. As the workaround, you can just exclude these messages by text.
exclude by text worked; leaving a reference here for others:
# .golangci.yml
linters-settings:
govet:
check-shadowing: true
# ...
issues:
exclude:
- composites
The following worked for me (s/composites/composite/):
diff --git a/.golangci.yml b/.golangci.yml
index ce8010e7..5b39faf1 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -6,6 +6,7 @@ linters:
- ineffassign
- unconvert
- misspell
+ - govet
linters-settings:
gocyclo:
min-complexity: 11
@@ -13,5 +14,8 @@ linters-settings:
ignore: fmt:.*,io/ioutil:^Read.*,github.com/spf13/cobra:MarkFlagRequired,github.com/spf13/viper:BindPFlag
golint:
min-confidence: 1.1
+issues:
+ exclude:
+ - composite
run:
tests: false
This should now be configurable (see: https://github.com/golangci/golangci-lint/pull/697).
Most helpful comment
exclude by text worked; leaving a reference here for others: