Commit eeac504f authored by liuyuhang's avatar liuyuhang

modify md file

parent 0d7521c6
### chain33和plugin lint warning统计
### chain33和plugin lint warning统计
> * 主要是缺少注释:全局 结构体、变量、常量、函数
> * 格式(禁止下划线、注释格式、go代码风格等)以及其他问题
## chain33(2400):
> * account
<br> Found 35 lint suggestions; failing.
> * blockchain
<br> Found 157 lint suggestions; failing
> * client
<br> Found 62 lint suggestions; failing
> * cmd
<br> Found 159 lint suggestions; failing.
> * common
<br> Found 319 lint suggestions; failing.
> * consensus
<br> Found 1 lint suggestions; failing.
> * executor
<br> Found 38 lint suggestions; failing.
> * mempool
<br> Found 36 lint suggestions; failing.
> * p2p
<br> Found 181 lint suggestions; failing.
> * pluginmgr
<br> Found 14 lint suggestions; failing
> * queue
<br> Found 12 lint suggestions; failing
> * rpc
<br> Found 228 lint suggestions; failing.
> * store
<br> Found 2 lint suggestions; failing.
> * system
<br> Found 552 lint suggestions; failing.
> * types
<br> Found 279 lint suggestions; failing.
> * util
<br> Found 86 lint suggestions; failing.
> * wallet
<br> Found 240 lint suggestions; failing.
## plugin(2861):
> * consensus
<br> Found 476 lint suggestions; failing.
> * crypto
<br> Found 37 lint suggestions; failing.
> * dapp
<br> Found 2176 lint suggestions; failing.
> * store
<br> Found 171 lint suggestions; failing.
\ No newline at end of file
主要是缺少注释:全局 结构体、变量、常量、函数
++ /dev/null
主要是缺少注释:全局 结构体、变量、常量、函数
格式(禁止下划线、注释格式、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
查看当前模块lint提示命令:golint -set_exit_status plugin/...
## 本地查看自己所修改模块lint warning的命令:
查看当前模块lint提示命令:golint -set_exit_status plugin/...
## 本地查看自己所修改模块lint warning的命令:
> * golint -set_exit_status plugin/...
> * golint -set_exit_status plugin/dapp/...
1、结构体、变量、常量、函数注释,提示-----
warning: exported const HashSize should have comment or be unexported
warning: exported var ManageX should have comment or be unexported
(如果exported 则需要加注释)
格式如下:
### 1、导出结构体、变量、常量、函数需加注释
> * lint warning: exported const HashSize should have comment or be unexported
```
注释格式:
const (
// KeyWalletPassKey .......
KeyWalletPassKey = "WalletPassKey"
......@@ -13,12 +14,19 @@ const (
func CalcWalletPassKey() []byte {
return []byte(keyWalletPassKey)
}
(注:如果是某些函数或者变量没有必要exported的话,首字母改为小写就不需要注释了)
2、函数注释不规范system/dapp/query.go:15:1:warning: comment on exported method DriverBase.GetTxsByAddr should be of the form "GetTxsByAddr ..." (golint)
需要改成上面1示例
```
> **注:如果是某些函数或者变量没有必要exported的话,首字母改为小写就不需要注释了**
```
func calcWalletPassKey() []byte {
return []byte(keyWalletPassKey)
}
```
### 2、函数注释不规范,需要按照1中方法修改
> * lint warning: comment on exported method DriverBase.GetTxsByAddr should be of the form "GetTxsByAddr ..."
3、不需要初始化,默认为零,提示-----should drop = 0 from declaration of var currentHeight; it is the zero value
### 3、默认为零,不需要进行为零初始化
> * lint warning: should drop = 0 from declaration of var currentHeight; it is the zero value
```
var (
currentHeight int64 = 0
currentIndex int64 = 0
......@@ -28,8 +36,10 @@ 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)
```
### 4、if else 如下格式的return,不需要加else,直接return
> * lint warning: if block ends with a return statement, so drop this else and outdent its block
```
if head == nil {
blockhight := chain.GetBlockHeight()
tmpHead, err := chain.blockStore.GetBlockHeaderByHeight(blockhight)
......@@ -50,16 +60,22 @@ var (
}
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"
```
### 5、不出现this, self等参数
> * lint 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、使用自加格式
> * lint warning: should replace resp.Actual += 1 with resp.Actual++
### 7、函数名、变量不使用带下划线(我们chain33利用加下划线实现了一些功能,因此这个暂时不需要改)
> * lint warning: don't use underscores in Go names; method ExecDelLocal_Transfer should be ExecDelLocalTransfer
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)
### 8、实现接口方法中前后形参要一致
> * lint warning: receiver name store should be consistent with previous receiver name ws for walletStore
```
func (ws *walletStore) SetFeeAmount(FeeAmount int64) error {
....
return nil
......@@ -77,8 +93,10 @@ 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)
```
9、errors.New(fmt.Sprintf(...)) 这种格式替换为fmt.Errorf(...)
> * lint 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))
......@@ -88,5 +106,4 @@ func (ws *walletStore) GetFeeAmount(minFee int64) int64 {
if index < 0 {
return fmt.Errorf("Action %s Not Existed", this.ActionName)
}
```
\ 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