Commit 38cc12d5 authored by liuyuhang's avatar liuyuhang

add

parents
查看当前模块lint命令:golint -set_exit_status plugin/...
1、结构体、变量、常量、函数注释,提示-----
warning: exported const HashSize should have comment or be unexported
warning: exported var ManageX should have comment or be unexported
(如果exported 则需要加注释)
格式如下:
const (
// KeyWalletPassKey .......
KeyWalletPassKey = "WalletPassKey"
)
// CalcWalletPassKey .......
func CalcWalletPassKey() []byte {
return []byte(keyWalletPassKey)
}
2、函数注释不规范system/dapp/query.go:15:1:warning: comment on exported method DriverBase.GetTxsByAddr should be of the form "GetTxsByAddr ..." (golint)
需要改成上面1示例
3、不需要初始化,默认为零,提示-----should drop = 0 from declaration of var currentHeight; it is the zero value
var (
currentHeight int64 = 0
currentIndex int64 = 0
)
改为
var (
currentHeight int64
currentIndex int64
)
4、if else 如下格式的return,不需要加else,直接return,提示-----warning: if block ends with a return statement, so drop this else and outdent its block (golint)
if head == nil {
blockhight := chain.GetBlockHeight()
tmpHead, err := chain.blockStore.GetBlockHeaderByHeight(blockhight)
if err == nil && tmpHead != nil {
chainlog.Error("ProcGetLastHeaderMsg from cache is nil.", "blockhight", blockhight, "hash", common.ToHex(tmpHead.Hash))
return tmpHead, nil
} else {
return nil, err
}
}
改为:
if head == nil {
blockhight := chain.GetBlockHeight()
tmpHead, err := chain.blockStore.GetBlockHeaderByHeight(blockhight)
if err == nil && tmpHead != nil {
chainlog.Error("ProcGetLastHeaderMsg from cache is nil.", "blockhight", blockhight, "hash", common.ToHex(tmpHead.Hash))
return tmpHead, nil
}
return nil, err
}
5、不出现this, self等参数,提示----- warning: receiver name should be a reflection of its identity; don't use generic names such as "this" or "self"
func (this *UpdateInitFileTask) genInitFile() error {}
改为:
func (up *UpdateInitFileTask) genInitFile() error {}
6、使用自加格式, 提示-----warning: should replace resp.Actual += 1 with resp.Actual++ (golint)
7、函数名、变量不使用带下划线(我们chain33利用加下划线实现了一些功能,因此这个暂时不需要改), 提示-----warning: don't use underscores in Go names; method ExecDelLocal_Transfer should be ExecDelLocalTransfer (golint)
8、实现接口方法,中前后形参要一致, 提示-----warning: receiver name store should be consistent with previous receiver name ws for walletStore (golint)
func (ws *walletStore) SetFeeAmount(FeeAmount int64) error {
....
return nil
}
func (store *walletStore) GetFeeAmount(minFee int64) int64 {
....
return FeeAmount
}
改为:
func (ws *walletStore) SetFeeAmount(FeeAmount int64) error {
....
return nil
}
func (ws *walletStore) GetFeeAmount(minFee int64) int64 {
....
return FeeAmount
}
9、errors.New(fmt.Sprintf(...)) 这种格式替换为fmt.Errorf(...), 提示-----warning: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (golint)
index := strings.Index(context, this.ActionName)
if index < 0 {
return errors.New(fmt.Sprintf("Action %s Not Existed", this.ActionName))
}
改为:
index := strings.Index(context, this.ActionName)
if index < 0 {
return fmt.Errorf("Action %s Not Existed", this.ActionName)
}
主要是缺少注释:全局 结构体、变量、常量、函数
主要是缺少注释:全局 结构体、变量、常量、函数
格式(禁止下划线、注释格式、go代码风格等)以及其他问题
chain33(2400):
account
Found 35 lint suggestions; failing.
blockchain
Found 157 lint suggestions; failing
client
Found 62 lint suggestions; failing
cmd
Found 159 lint suggestions; failing.
common
Found 319 lint suggestions; failing.
consensus
Found 1 lint suggestions; failing.
executor
Found 38 lint suggestions; failing.
mempool
Found 36 lint suggestions; failing.
p2p
Found 181 lint suggestions; failing.
pluginmgr
Found 14 lint suggestions; failing
queue
Found 12 lint suggestions; failing
rpc
Found 228 lint suggestions; failing.
store
Found 2 lint suggestions; failing.
system
Found 552 lint suggestions; failing.
types
Found 279 lint suggestions; failing.
util
Found 86 lint suggestions; failing.
wallet
Found 240 lint suggestions; failing.
plugin(2861):
consensus
Found 476 lint suggestions; failing.
crypto
Found 37 lint suggestions; failing.
dapp
Found 2176 lint suggestions; failing.
store
Found 171 lint suggestions; failing.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment