Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
1169387b
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,发现更多精彩内容 >>
未验证
提交
1169387b
编写于
12月 27, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add method num filter
上级
1acd669d
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
143 addition
and
5 deletion
+143
-5
README.md
README.md
+4
-0
cmd/api.go
cmd/api.go
+5
-5
cmd/evaluate.go
cmd/evaluate.go
+11
-0
core/domain/evaluate/analyser.go
core/domain/evaluate/analyser.go
+5
-0
core/domain/evaluate/evaluator/models.go
core/domain/evaluate/evaluator/models.go
+2
-0
docs/patterns/evaluate.md
docs/patterns/evaluate.md
+116
-0
未找到文件。
README.md
浏览文件 @
1169387b
...
...
@@ -22,6 +22,10 @@ Todo:
-
Evaluate API
-
[ ] Average Method Length
-
[ ] Average Class Method Count
-
Date Collections
-
[ ] monolithic
-
[ ] microservice
-
[ ] big data
## Usage
...
...
cmd/api.go
浏览文件 @
1169387b
package
cmd
import
(
"encoding/json"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/config"
"github.com/phodal/coca/core/adapter"
.
"github.com/phodal/coca/core/adapter/api"
"github.com/phodal/coca/core/domain/call_graph"
"github.com/phodal/coca/core/models"
.
"github.com/phodal/coca/core/support"
"encoding/json"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"log"
"os"
...
...
cmd/evaluate.go
浏览文件 @
1169387b
...
...
@@ -61,6 +61,12 @@ var evaluateCmd = &cobra.Command{
staticCount
:=
result
.
Summary
.
StaticMethodCount
table
.
Append
([]
string
{
"Static Method"
,
strconv
.
Itoa
(
staticCount
),
"Method"
,
strconv
.
Itoa
(
methodCount
),
Percent
(
utilsCount
,
methodCount
)})
table
.
Append
([]
string
{
"Average Method Num"
,
strconv
.
Itoa
(
methodCount
),
"Method/Class"
,
strconv
.
Itoa
(
classCount
),
Rate
(
methodCount
,
classCount
)})
totalLength
:=
result
.
Summary
.
TotalMethodLength
normalMethodCount
:=
result
.
Summary
.
NormalMethodCount
table
.
Append
([]
string
{
"Average Method Length"
,
strconv
.
Itoa
(
totalLength
),
"Without Getter/Setter"
,
strconv
.
Itoa
(
normalMethodCount
),
Rate
(
totalLength
,
normalMethodCount
)})
table
.
Render
()
},
}
...
...
@@ -70,6 +76,11 @@ func Percent(pcent int, all int) string {
return
fmt
.
Sprintf
(
"%3.2f%%"
,
percent
)
}
func
Rate
(
pcent
int
,
all
int
)
string
{
percent
:=
float64
(
pcent
)
/
float64
(
all
)
return
fmt
.
Sprintf
(
"%f"
,
percent
)
}
func
init
()
{
rootCmd
.
AddCommand
(
evaluateCmd
)
...
...
core/domain/evaluate/analyser.go
浏览文件 @
1169387b
...
...
@@ -46,6 +46,11 @@ func (a Analyser) Analysis(classNodes []models.JClassNode, identifiers []models.
if
support
.
Contains
(
method
.
Modifiers
,
"static"
)
{
result
.
Summary
.
StaticMethodCount
++
}
if
!
strings
.
HasPrefix
(
method
.
Name
,
"set"
)
&&
!
strings
.
HasPrefix
(
method
.
Name
,
"get"
)
{
result
.
Summary
.
NormalMethodCount
++
result
.
Summary
.
TotalMethodLength
=
result
.
Summary
.
TotalMethodLength
+
method
.
StopLine
-
method
.
StartLine
+
1
}
}
}
...
...
core/domain/evaluate/evaluator/models.go
浏览文件 @
1169387b
...
...
@@ -20,6 +20,8 @@ type Summary struct {
UtilsCount
int
ClassCount
int
MethodCount
int
NormalMethodCount
int
TotalMethodLength
int
StaticMethodCount
int
}
...
...
docs/patterns/evaluate.md
0 → 100644
浏览文件 @
1169387b
url: https://github.com/macrozheng/mall
```
+------------------------+-------+-----------------------+-------+-----------+
| TYPE | COUNT | LEVEL | TOTAL | RATE |
+------------------------+-------+-----------------------+-------+-----------+
| Nullable / Return Null | 22 | Method | 12682 | 0.17% |
| Utils | 2 | Class | 458 | 0.44% |
| Static Method | 7 | Method | 12682 | 0.02% |
| Average Method Num | 12682 | Method/Class | 458 | 27.689956 |
| Average Method Length | 45091 | Without Getter/Setter | 10205 | 4.418520 |
+------------------------+-------+-----------------------+-------+-----------+
```
// issues: big data class / god service
url: https://github.com/shuzheng/zheng
```
+------------------------+-------+-----------------------+-------+-----------+
| TYPE | COUNT | LEVEL | TOTAL | RATE |
+------------------------+-------+-----------------------+-------+-----------+
| Nullable / Return Null | 0 | Method | 5256 | 0.00% |
| Utils | 18 | Class | 366 | 4.92% |
| Static Method | 0 | Method | 5256 | 0.34% |
| Average Method Num | 5256 | Method/Class | 366 | 14.360656 |
| Average Method Length | 19644 | Without Getter/Setter | 4328 | 4.538817 |
+------------------------+-------+-----------------------+-------+-----------+
```
// data class
big data
```
+------------------------+-------+-----------------------+-------+-----------+
| TYPE | COUNT | LEVEL | TOTAL | RATE |
+------------------------+-------+-----------------------+-------+-----------+
| Nullable / Return Null | 128 | Method | 3041 | 4.21% |
| Utils | 18 | Class | 496 | 7.06% |
| Static Method | 400 | Method | 3041 | 1.15% |
| Average Method Num | 3041 | Method/Class | 496 | 6.13 |
| Average Method Length | 17730 | Without Getter/Setter | 1551 | 11.43 |
+------------------------+-------+-----------------------+-------+-----------+
```
// null issues
Common Project
```
+------------------------+-------+-----------------------+-------+-----------+
| TYPE | COUNT | LEVEL | TOTAL | RATE |
+------------------------+-------+-----------------------+-------+-----------+
| Nullable / Return Null | 234 | Method | 16642 | 1.41% |
| Utils | 26 | Class | 1007 | 7.06% |
| Static Method | 2062 | Method | 16642 | 0.16% |
| Average Method Num | 16642 | Method/Class | 1007 | 16.52 |
| Average Method Length | 69012 | Without Getter/Setter | 6020 | 11.46 |
+------------------------+-------+-----------------------+-------+-----------+
```
// static projects
Algo Project
```
+------------------------+-------+-----------------------+-------+-----------+
| TYPE | COUNT | LEVEL | TOTAL | RATE |
+------------------------+-------+-----------------------+-------+-----------+
| Nullable / Return Null | 101 | Method | 4914 | 2.06% |
| Utils | 43 | Class | 926 | 4.64% |
| Static Method | 542 | Method | 4914 | 0.88% |
| Average Method Num | 4914 | Method/Class | 927 | 5.30 |
| Average Method Length | 51056 | Without Getter/Setter | 2603 | 19.61 |
+------------------------+-------+-----------------------+-------+-----------+
```
// longest method
CMS
url: https://github.com/sanluan/PublicCMS
```
+------------------------+-------+-----------------------+-------+-----------+
| TYPE | COUNT | LEVEL | TOTAL | RATE |
+------------------------+-------+-----------------------+-------+-----------+
| Nullable / Return Null | 131 | Method | 2707 | 4.84% |
| Utils | 21 | Class | 483 | 4.35% |
| Static Method | 246 | Method | 2707 | 0.78% |
| Average Method Num | 2707 | Method/Class | 483 | 5.604555 |
| Average Method Length | 13622 | Without Getter/Setter | 1350 | 10.090370 |
+------------------------+-------+-----------------------+-------+-----------+
```
// to many null
ERP
url: https://github.com/ilscipio/scipio-erp
```
+------------------------+--------+-----------------------+-------+-----------+
| TYPE | COUNT | LEVEL | TOTAL | RATE |
+------------------------+--------+-----------------------+-------+-----------+
| Nullable / Return Null | 1660 | Method | 23461 | 7.08% |
| Utils | 86 | Class | 2288 | 3.76% |
| Static Method | 6469 | Method | 23461 | 0.37% |
| Average Method Num | 23461 | Method/Class | 2288 | 10.253934 |
| Average Method Length | 228550 | Without Getter/Setter | 14080 | 16.232244 |
+------------------------+--------+-----------------------+-------+-----------+
```
// longest method
// to many null (bugs)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录