OpenAtomFoundation / xupercore

The kernel of xuperchain.
Apache License 2.0
61 stars 47 forks source link

Fix problems reported by Go Report Card #402

Open zhugelianglongming opened 1 year ago

zhugelianglongming commented 1 year ago

Problems

see Go Report Card

gofmt

431

bcs/consensus/tdpos/common.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/ledger/xledger/state/xmodel/xmodel_test.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/ledger/xledger/tx/topsort_test.go Line 1: warning: file is not gofmted with -s (gofmt) lib/storage/mstorage/file_storage_solaris.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/consensus/pow/common.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/consensus/tdpos/tdpos.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/ledger/xledger/ledger/ledger_test.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/ledger/xledger/state/utxo/spin_lock_test.go Line 1: warning: file is not gofmted with -s (gofmt) kernel/consensus/base/common/common.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/consensus/tdpos/kernel_contract.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/consensus/xpoa/kernel_contract.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/network/p2pv1/client.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/ledger/xledger/state/utxo/topsort_test.go Line 1: warning: file is not gofmted with -s (gofmt) lib/storage/mstorage/file_storage_unix.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/consensus/tdpos/schedule.go Line 1: warning: file is not gofmted with -s (gofmt) bcs/ledger/xledger/state/xmodel/dbutils_test.go Line 1: warning: file is not gofmted with -s (gofmt) kernel/network/p2p/dispatcher.go Line 1: warning: file is not gofmted with -s (gofmt) lib/storage/mstorage/file_storage_nacl.go Line 1: warning: file is not gofmted with -s (gofmt)

gocyclo

bcs/ledger/xledger/state/utxo/utxo.go Line 366: warning: cyclomatic complexity 30 of function (UtxoVM).SelectUtxos() is high (> 15) (gocyclo) Line 131: warning: cyclomatic complexity 21 of function (UtxoVM).CheckInputEqualOutput() is high (> 15) (gocyclo) kernel/engines/xuperos/chain.go Line 118: warning: cyclomatic complexity 23 of function (Chain).PreExec() is high (> 15) (gocyclo) kernel/engines/xuperos/xtoken/xtoken_contract.go Line 218: warning: cyclomatic complexity 21 of function (Contract).TransferFrom() is high (> 15) (gocyclo) Line 553: warning: cyclomatic complexity 21 of function (Contract).checkTokenData() is high (> 15) (gocyclo) Line 436: warning: cyclomatic complexity 17 of function (Contract).Burn() is high (> 15) (gocyclo) Line 147: warning: cyclomatic complexity 17 of function (Contract).Transfer() is high (> 15) (gocyclo) bcs/ledger/xledger/tx/topsort.go Line 17: warning: cyclomatic complexity 18 of function TopSortDFS() is high (> 15) (gocyclo) bcs/ledger/xledger/state/state_test.go Line 211: warning: cyclomatic complexity 36 of function TestStateWorkWithLedger() is high (> 15) (gocyclo) Line 458: warning: cyclomatic complexity 20 of function TestFrozenHeight() is high (> 15) (gocyclo) kernel/consensus/base/driver/chained-bft/smr_test.go Line 124: warning: cyclomatic complexity 18 of function TestSMR() is high (> 15) (gocyclo) bcs/ledger/xledger/state/utxo/topsort.go Line 17: warning: cyclomatic complexity 18 of function TopSortDFS() is high (> 15) (gocyclo) bcs/ledger/xledger/tx/node.go Line 270: warning: cyclomatic complexity 17 of function (Node).breakOutputs() is high (> 15) (gocyclo) bcs/ledger/xledger/state/tx_verification.go Line 543: warning: cyclomatic complexity 28 of function (State).verifyTxRWSets() is high (> 15) (gocyclo) Line 43: warning: cyclomatic complexity 20 of function (State).ImmediateVerifyTx() is high (> 15) (gocyclo) Line 217: warning: cyclomatic complexity 18 of function (State).verifySignatures() is high (> 15) (gocyclo) bcs/consensus/pow/pow.go Line 157: warning: cyclomatic complexity 16 of function (PoWConsensus).CheckMinerMatch() is high (> 15) (gocyclo) bcs/ledger/xledger/state/utxo/txhash/txhash.go Line 40: warning: cyclomatic complexity 41 of function encodeTxData() is high (> 15) (gocyclo) bcs/ledger/xledger/ledger/ledger.go Line 594: warning: cyclomatic complexity 34 of function (Ledger).ConfirmBlock() is high (> 15) (gocyclo) Line 944: warning: cyclomatic complexity 17 of function (Ledger).FindUndoAndTodoBlocks() is high (> 15) (gocyclo) bcs/consensus/tdpos/kernel_contract.go Line 257: warning: cyclomatic complexity 19 of function (tdposConsensus).runRevokeVote() is high (> 15) (gocyclo) Line 95: warning: cyclomatic complexity 17 of function (tdposConsensus).runRevokeCandidate() is high (> 15) (gocyclo) bcs/ledger/xledger/state/reserved_contract.go Line 30: warning: cyclomatic complexity 19 of function (State).VerifyReservedWhitelist() is high (> 15) (gocyclo) bcs/ledger/xledger/state/meta/meta_test.go Line 61: warning: cyclomatic complexity 22 of function TestMetaGetFunc() is high (> 15) (gocyclo) kernel/engines/xuperos/xtoken/xtoken_propose.go Line 115: warning: cyclomatic complexity 20 of function (Contract).Vote() is high (> 15) (gocyclo) Line 195: warning: cyclomatic complexity 18 of function (Contract).CheckVote() is high (> 15) (gocyclo) bcs/network/p2pv2/client.go Line 222: warning: cyclomatic complexity 18 of function (P2PServerV2).getFilter() is high (> 15) (gocyclo) bcs/ledger/xledger/ledger/ledger_hash.go Line 220: warning: cyclomatic complexity 17 of function MakeBlockID() is high (> 15) (gocyclo) kernel/contract/bridge/contract_manager.go Line 21: warning: cyclomatic complexity 16 of function (*contractManager).DeployContract() is high (> 15) (gocyclo) bcs/ledger/xledger/ledger/ledger_test.go Line 218: warning: cyclomatic complexity 28 of function TestSplitFunc() is high (> 15) (gocyclo) Line 95: warning: cyclomatic complexity 16 of function TestBasicFunc() is high (> 15) (gocyclo) bcs/ledger/xledger/state/xmodel/xmodel_test.go Line 56: warning: cyclomatic complexity 24 of function TestBaiscFunc() is high (> 15) (gocyclo)

430

kernel/engines/xuperos/engine.go Line 166: warning: cyclomatic complexity 19 of function (Engine).loadChains() is high (> 15) (gocyclo) kernel/consensus/base/driver/chained-bft/smr.go Line 471: warning: cyclomatic complexity 19 of function (Smr).handleReceivedProposal() is high (> 15) (gocyclo) bcs/ledger/xledger/tx/mempool.go Line 352: warning: cyclomatic complexity 35 of function (Mempool).FindConflictByTx() is high (> 15) (gocyclo) Line 107: warning: cyclomatic complexity 32 of function (Mempool).Range() is high (> 15) (gocyclo) Line 1011: warning: cyclomatic complexity 26 of function (Mempool).processOrphansToUnconfirmed() is high (> 15) (gocyclo) Line 1235: warning: cyclomatic complexity 17 of function (Mempool).processTxInputsExt() is high (> 15) (gocyclo) Line 1151: warning: cyclomatic complexity 16 of function (Mempool).processTxInputs() is high (> 15) (gocyclo) bcs/contract/evm/creator.go Line 71: warning: cyclomatic complexity 19 of function (evmInstance).Exec() is high (> 15) (gocyclo) bcs/ledger/xledger/state/utxo/utxo_test.go Line 63: warning: cyclomatic complexity 23 of function TestBasicFunc() is high (> 15) (gocyclo) lib/storage/mstorage/multi_disk_storage.go Line 324: warning: cyclomatic complexity 41 of function (*MultiDiskStorage).GetMeta() is high (> 15) (gocyclo)