Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
049a6c4d
C
Coca
项目概览
Phodal
/
Coca
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coca
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
049a6c4d
编写于
12月 27, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add basic evaluate summary
上级
ed05faea
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
66 addition
and
16 deletion
+66
-16
README.md
README.md
+43
-10
cmd/evaluate.go
cmd/evaluate.go
+23
-6
未找到文件。
README.md
浏览文件 @
049a6c4d
...
...
@@ -306,16 +306,49 @@ coca evaluate
```
```
custom [customKeyGenerator customCacheManager]
throw [throwUnchecked throwCheckedSync throwUncheckedSync throwChecked]
evict [evictWithException evictAllEarly evictAll evict evictEarly]
multi [multiCacheAndEvict multiCache multiUpdate multiEvict multiConditionalCacheAndEvict]
conditional [conditional conditionalUpdate conditionalSync]
unknown [unknownCustomCacheManager unknownCustomKeyGenerator]
throw [throwException throwCheckedException]
put [putWithException put]
early [earlyRemoveWithException earlyRemoveAllWithException earlyRemoveAll earlyPut earlyPutWithException earlyRemove]
evict [evictAll evictWithException evict evictEarly evictAllEarly]
+------------------------+-------+--------+-------+-------+
| TYPE | COUNT | LEVEL | TOTAL | RATE |
+------------------------+-------+--------+-------+-------+
| Nullable / Return Null | 8 | Method | 161 | 4.97% |
| Utils | 1 | Class | 64 | 1.56% |
| Static Method | 19 | Method | 19 | 0.62% |
+------------------------+-------+--------+-------+-------+
```
Evaluate.json examples
```
json
{
"Nullable"
:
{
"Items"
:
[
"nonnull.Name.testNull"
,
"nonnull.Name.orElseNull"
,
"org.ofbiz.base.util.UtilURL.fromResource"
,
"org.ofbiz.base.util.UtilURL.getOfbizHomeRelativeLocationFromFilePath"
,
"study.huhao.demo.adapters.outbound.persistence.blog.BlogPO.toDomainModel"
,
"study.huhao.demo.adapters.outbound.persistence.blog.BlogPO.toDomainModel"
,
"study.huhao.demo.adapters.outbound.persistence.blog.BlogPO.of"
,
"study.huhao.demo.infrastructure.persistence.blog.BlogPO.convertDomain"
]
},
"ServiceSummary"
:
{
"LifecycleMap"
:
null
,
"ReturnTypeMap"
:
{
"BookRepresentaion"
:
[
"com.phodal.pholedge.book.BookService.getBookById"
,
"com.phodal.pholedge.book.BookService.updateBook"
]
},
"RelatedMethod"
:
null
},
"UtilsSummary"
:
{},
"Summary"
:
{
"UtilsCount"
:
1
,
"ClassCount"
:
64
,
"MethodCount"
:
161
,
"StaticMethodCount"
:
19
}
}
```
### Todo
...
...
cmd/evaluate.go
浏览文件 @
049a6c4d
...
...
@@ -3,12 +3,15 @@ package cmd
import
(
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/config"
"github.com/phodal/coca/core/domain/evaluate"
"github.com/phodal/coca/core/models"
.
"github.com/phodal/coca/core/support"
"github.com/spf13/cobra"
"log"
"os"
"strconv"
)
type
EvaluateConfig
struct
{
...
...
@@ -43,16 +46,30 @@ var evaluateCmd = &cobra.Command{
cModel
,
_
:=
json
.
MarshalIndent
(
result
,
""
,
"
\t
"
)
WriteToCocaFile
(
"evaluate.json"
,
string
(
cModel
))
fmt
.
Println
(
" ----- same type in service ------ "
)
fmt
.
Println
(
result
.
ServiceSummary
.
ReturnTypeMap
)
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
table
.
SetHeader
([]
string
{
"Type"
,
"Count"
,
"Level"
,
"Total"
,
"Rate"
}
)
fmt
.
Println
(
"-------- Null -------- Method"
)
for
_
,
nullItem
:=
range
result
.
Nullable
.
Items
{
fmt
.
Println
(
nullItem
)
}
classCount
:=
result
.
Summary
.
ClassCount
methodCount
:=
result
.
Summary
.
MethodCount
nullItemsLength
:=
len
(
result
.
Nullable
.
Items
)
table
.
Append
([]
string
{
"Nullable / Return Null"
,
strconv
.
Itoa
(
nullItemsLength
),
"Method"
,
strconv
.
Itoa
(
methodCount
),
Percent
(
nullItemsLength
,
methodCount
)})
utilsCount
:=
result
.
Summary
.
UtilsCount
table
.
Append
([]
string
{
"Utils"
,
strconv
.
Itoa
(
utilsCount
),
"Class"
,
strconv
.
Itoa
(
classCount
),
Percent
(
utilsCount
,
classCount
)})
staticCount
:=
result
.
Summary
.
StaticMethodCount
table
.
Append
([]
string
{
"Static Method"
,
strconv
.
Itoa
(
staticCount
),
"Method"
,
strconv
.
Itoa
(
methodCount
),
Percent
(
utilsCount
,
methodCount
)})
table
.
Render
()
},
}
func
Percent
(
pcent
int
,
all
int
)
string
{
percent
:=
100.0
*
float64
(
pcent
)
/
float64
(
all
)
return
fmt
.
Sprintf
(
"%3.2f%%"
,
percent
)
}
func
init
()
{
rootCmd
.
AddCommand
(
evaluateCmd
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录