Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
0b010e9f
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 搜索 >>
未验证
提交
0b010e9f
编写于
1月 09, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
styles: update output styles to markdown
上级
100281a8
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
35 addition
and
53 deletion
+35
-53
cmd/api.go
cmd/api.go
+1
-2
cmd/api_test.go
cmd/api_test.go
+1
-1
cmd/cmd_util/coca_output.go
cmd/cmd_util/coca_output.go
+13
-0
cmd/count.go
cmd/count.go
+1
-2
cmd/dep.go
cmd/dep.go
+2
-2
cmd/evaluate.go
cmd/evaluate.go
+1
-2
cmd/git.go
cmd/git.go
+2
-9
cmd/git_test.go
cmd/git_test.go
+1
-1
cmd/suggest.go
cmd/suggest.go
+1
-2
cmd/suggest_test.go
cmd/suggest_test.go
+1
-1
cmd/tbs.go
cmd/tbs.go
+1
-4
cmd/tbs_test.go
cmd/tbs_test.go
+1
-1
cmd/testdata/api.txt
cmd/testdata/api.txt
+1
-3
cmd/testdata/api_sort_remove.txt
cmd/testdata/api_sort_remove.txt
+1
-3
cmd/testdata/count.txt
cmd/testdata/count.txt
+1
-3
cmd/testdata/deps_gradle.txt
cmd/testdata/deps_gradle.txt
+1
-3
cmd/testdata/deps_maven.txt
cmd/testdata/deps_maven.txt
+1
-3
cmd/testdata/evaluate.txt
cmd/testdata/evaluate.txt
+1
-3
cmd/testdata/suggest_normal.txt
cmd/testdata/suggest_normal.txt
+1
-3
cmd/testdata/tbs_normal.txt
cmd/testdata/tbs_normal.txt
+1
-3
cmd/todo.go
cmd/todo.go
+1
-2
未找到文件。
cmd/api.go
浏览文件 @
0b010e9f
...
...
@@ -2,7 +2,6 @@ package cmd
import
(
"encoding/json"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/cmd/config"
"github.com/phodal/coca/pkg/application/api"
...
...
@@ -73,7 +72,7 @@ var apiCmd = &cobra.Command{
}
if
apiCmdConfig
.
ShowCount
{
table
:=
tablewriter
.
NewWriter
(
output
)
table
:=
cmd_util
.
NewOutput
(
output
)
table
.
SetHeader
([]
string
{
"Size"
,
"Method"
,
"URI"
,
"Caller"
})
...
...
cmd/api_test.go
浏览文件 @
0b010e9f
...
...
@@ -39,4 +39,4 @@ func Test_ApiWithSortRemove(t *testing.T) {
Golden
:
"testdata/api_sort_remove.txt"
,
}}
RunTestCmd
(
t
,
tests
)
}
\ No newline at end of file
}
cmd/cmd_util/coca_output.go
0 → 100644
浏览文件 @
0b010e9f
package
cmd_util
import
(
"github.com/olekukonko/tablewriter"
"io"
)
func
NewOutput
(
output
io
.
Writer
)
*
tablewriter
.
Table
{
table
:=
tablewriter
.
NewWriter
(
output
)
table
.
SetBorders
(
tablewriter
.
Border
{
Left
:
true
,
Top
:
false
,
Right
:
true
,
Bottom
:
false
})
table
.
SetCenterSeparator
(
"|"
)
return
table
}
cmd/count.go
浏览文件 @
0b010e9f
...
...
@@ -2,7 +2,6 @@ package cmd
import
(
"encoding/json"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/cmd/config"
"github.com/phodal/coca/pkg/application/count"
...
...
@@ -41,7 +40,7 @@ var countCmd = &cobra.Command{
callMapSort
=
callMapSort
[
:
countCmdConfig
.
Top
]
}
table
:=
tablewriter
.
NewWriter
(
output
)
table
:=
cmd_util
.
NewOutput
(
output
)
table
.
SetHeader
([]
string
{
"Refs Count"
,
"method"
})
for
_
,
count
:=
range
callMapSort
{
...
...
cmd/dep.go
浏览文件 @
0b010e9f
...
...
@@ -2,7 +2,7 @@ package cmd
import
(
"fmt"
"github.com/
olekukonko/tablewriter
"
"github.com/
phodal/coca/cmd/cmd_util
"
"github.com/phodal/coca/pkg/adapter/cocafile"
"github.com/phodal/coca/pkg/application/analysis"
"github.com/phodal/coca/pkg/application/deps"
...
...
@@ -50,7 +50,7 @@ var depCmd = &cobra.Command{
results
:=
app
.
AnalysisPath
(
path
,
classNodes
)
fmt
.
Fprintln
(
output
,
"unused"
)
table
:=
tablewriter
.
NewWriter
(
output
)
table
:=
cmd_util
.
NewOutput
(
output
)
table
.
SetHeader
([]
string
{
"GroupId"
,
"ArtifactId"
,
"Scope"
})
for
_
,
dep
:=
range
results
{
table
.
Append
([]
string
{
dep
.
GroupId
,
dep
.
ArtifactId
,
dep
.
Scope
})
...
...
cmd/evaluate.go
浏览文件 @
0b010e9f
...
...
@@ -3,7 +3,6 @@ package cmd
import
(
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/cmd/config"
"github.com/phodal/coca/pkg/application/evaluate"
...
...
@@ -51,7 +50,7 @@ var evaluateCmd = &cobra.Command{
}
func
buildOutput
(
result
evaluator
.
EvaluateModel
)
{
table
:=
tablewriter
.
NewWriter
(
output
)
table
:=
cmd_util
.
NewOutput
(
output
)
table
.
SetHeader
([]
string
{
"Type"
,
"Count"
,
"Level"
,
"Total"
,
"Rate"
})
classCount
:=
result
.
Summary
.
ClassCount
...
...
cmd/git.go
浏览文件 @
0b010e9f
...
...
@@ -3,7 +3,6 @@ package cmd
import
(
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
.
"github.com/phodal/coca/pkg/application/git"
"github.com/spf13/cobra"
...
...
@@ -41,9 +40,9 @@ var gitCmd = &cobra.Command{
isFullMessage
:=
cmd
.
Flag
(
"full"
)
.
Value
.
String
()
==
"true"
size
:=
gitCmdConfig
.
Size
if
cmd
.
Flag
(
"basic"
)
.
Value
.
String
()
==
"true"
{
table
:=
tablewriter
.
NewWriter
(
output
)
table
:=
cmd_util
.
NewOutput
(
output
)
if
cmd
.
Flag
(
"basic"
)
.
Value
.
String
()
==
"true"
{
basicSummary
:=
BasicSummary
(
commitMessages
)
table
.
SetHeader
([]
string
{
"Statistic"
,
"Number"
})
table
.
Append
([]
string
{
"Commits"
,
strconv
.
Itoa
(
basicSummary
.
Commits
)})
...
...
@@ -54,8 +53,6 @@ var gitCmd = &cobra.Command{
}
if
cmd
.
Flag
(
"team"
)
.
Value
.
String
()
==
"true"
{
table
:=
tablewriter
.
NewWriter
(
output
)
teamSummary
:=
GetTeamSummary
(
commitMessages
)
table
.
SetHeader
([]
string
{
"EntityName"
,
"RevsCount"
,
"AuthorCount"
})
...
...
@@ -69,8 +66,6 @@ var gitCmd = &cobra.Command{
}
if
cmd
.
Flag
(
"age"
)
.
Value
.
String
()
==
"true"
{
table
:=
tablewriter
.
NewWriter
(
output
)
ages
:=
CalculateCodeAge
(
commitMessages
)
var
agesDisplay
[]
CodeAgeDisplay
for
_
,
info
:=
range
ages
{
...
...
@@ -92,8 +87,6 @@ var gitCmd = &cobra.Command{
}
if
cmd
.
Flag
(
"top"
)
.
Value
.
String
()
==
"true"
{
table
:=
tablewriter
.
NewWriter
(
output
)
authors
:=
GetTopAuthors
(
commitMessages
)
table
.
SetHeader
([]
string
{
"Author"
,
"CommitCount"
,
"LineCount"
})
...
...
cmd/git_test.go
浏览文件 @
0b010e9f
...
...
@@ -13,4 +13,4 @@ func TestGit(t *testing.T) {
Golden
:
""
,
}}
RunTestCmd
(
t
,
tests
)
}
\ No newline at end of file
}
cmd/suggest.go
浏览文件 @
0b010e9f
...
...
@@ -2,7 +2,6 @@ package cmd
import
(
"encoding/json"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/cmd/config"
"github.com/phodal/coca/pkg/application/suggest"
...
...
@@ -30,7 +29,7 @@ var suggestCmd = &cobra.Command{
app
:=
suggest
.
NewSuggestApp
()
results
:=
app
.
AnalysisPath
(
parsedDeps
)
table
:=
tablewriter
.
NewWriter
(
output
)
table
:=
cmd_util
.
NewOutput
(
output
)
table
.
SetHeader
([]
string
{
"Class"
,
"Pattern"
,
"Reason"
})
for
_
,
result
:=
range
results
{
...
...
cmd/suggest_test.go
浏览文件 @
0b010e9f
...
...
@@ -19,4 +19,4 @@ func TestSuggest(t *testing.T) {
Golden
:
"testdata/suggest_normal.txt"
,
}}
RunTestCmd
(
t
,
tests
)
}
\ No newline at end of file
}
cmd/tbs.go
浏览文件 @
0b010e9f
...
...
@@ -3,7 +3,6 @@ package cmd
import
(
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/pkg/adapter/cocafile"
"github.com/phodal/coca/pkg/application/analysis"
...
...
@@ -47,7 +46,6 @@ var tbsCmd = &cobra.Command{
result
:=
app
.
AnalysisPath
(
classNodes
,
identifiersMap
)
fmt
.
Fprintf
(
output
,
"Test Bad Smell nums: %d
\n
"
,
len
(
result
))
resultContent
,
_
:=
json
.
MarshalIndent
(
result
,
""
,
"
\t
"
)
if
tbsCmdConfig
.
IsSort
{
...
...
@@ -60,9 +58,8 @@ var tbsCmd = &cobra.Command{
}
cmd_util
.
WriteToCocaFile
(
"tbs.json"
,
string
(
resultContent
))
if
len
(
result
)
<=
20
{
table
:=
tablewriter
.
NewWriter
(
output
)
table
:=
cmd_util
.
NewOutput
(
output
)
table
.
SetHeader
([]
string
{
"Type"
,
"FileName"
,
"Line"
})
for
_
,
result
:=
range
result
{
...
...
cmd/tbs_test.go
浏览文件 @
0b010e9f
...
...
@@ -12,4 +12,4 @@ func TestTbs(t *testing.T) {
Golden
:
"testdata/tbs_normal.txt"
,
}}
RunTestCmd
(
t
,
tests
)
}
\ No newline at end of file
}
cmd/testdata/api.txt
浏览文件 @
0b010e9f
+------+--------+-------------+-----------------------------------------------------+
| SIZE | METHOD | URI | CALLER |
+------+--------+-------------+-----------------------------------------------------+
|------|--------|-------------|-----------------------------------------------------|
| 2 | POST | /books | com.phodal.pholedge.book.BookController.createBook |
| 2 | PUT | /books/{id} | com.phodal.pholedge.book.BookController.updateBook |
| 2 | GET | /books/ | com.phodal.pholedge.book.BookController.getBookList |
| 2 | GET | /books/{id} | com.phodal.pholedge.book.BookController.getBookById |
+------+--------+-------------+-----------------------------------------------------+
cmd/testdata/api_sort_remove.txt
浏览文件 @
0b010e9f
+------+--------+-------------+----------------------------+
| SIZE | METHOD | URI | CALLER |
+------+--------+-------------+----------------------------+
|------|--------|-------------|----------------------------|
| 2 | POST | /books | BookController.createBook |
| 2 | PUT | /books/{id} | BookController.updateBook |
| 2 | GET | /books/ | BookController.getBookList |
| 2 | GET | /books/{id} | BookController.getBookById |
+------+--------+-------------+----------------------------+
cmd/testdata/count.txt
浏览文件 @
0b010e9f
+------------+------------------------------------------------------------+
| REFS COUNT | METHOD |
+------------+------------------------------------------------------------+
|------------|------------------------------------------------------------|
| 1 | study.huhao.demo.infrastructure.persistence.blog.BlogPO.of |
+------------+------------------------------------------------------------+
cmd/testdata/deps_gradle.txt
浏览文件 @
0b010e9f
unused
+---------------------------+-------------------------------------------+--------------------+
| GROUPID | ARTIFACTID | SCOPE |
+---------------------------+-------------------------------------------+--------------------+
|---------------------------|-------------------------------------------|--------------------|
| org.flywaydb | flyway-core | implementation |
| org.springframework.cloud | spring-cloud-starter-zipkin | implementation |
| org.springframework.cloud | spring-cloud-starter-zookeeper-config | implementation |
| io.projectreactor | reactor-test | testImplementation |
| org.springframework.cloud | spring-cloud-starter-contract-stub-runner | testImplementation |
| org.springframework.cloud | spring-cloud-starter-contract-verifier | testImplementation |
+---------------------------+-------------------------------------------+--------------------+
cmd/testdata/deps_maven.txt
浏览文件 @
0b010e9f
unused
+---------------------------+----------------------------------------+---------+
| GROUPID | ARTIFACTID | SCOPE |
+---------------------------+----------------------------------------+---------+
|---------------------------|----------------------------------------|---------|
| org.flywaydb | flyway-core | |
| mysql | mysql-connector-java | runtime |
| org.springframework.cloud | spring-cloud-starter-contract-verifier | test |
+---------------------------+----------------------------------------+---------+
cmd/testdata/evaluate.txt
浏览文件 @
0b010e9f
+--------------------------------+-------+-----------------------+-------+----------+
| TYPE | COUNT | LEVEL | TOTAL | RATE |
+--------------------------------+-------+-----------------------+-------+----------+
|--------------------------------|-------|-----------------------|-------|----------|
| Nullable / Return Null | 0 | Method | 6 | 0.00% |
| Utils | 0 | Class | 14 | 0.00% |
| Static Method | 1 | Method | 6 | 0.00% |
...
...
@@ -8,4 +7,3 @@
| Method Num. Std Dev / 标准差 | 6 | Class | - | 0.646206 |
| Average Method Length | 0 | Without Getter/Setter | 0 | NaN |
| Method Length Std Dev / 标准差 | 6 | Method | - | NaN |
+--------------------------------+-------+-----------------------+-------+----------+
cmd/testdata/suggest_normal.txt
浏览文件 @
0b010e9f
+------------+------------------+--------------------------------+
| CLASS | PATTERN | REASON |
+------------+------------------+--------------------------------+
|------------|------------------|--------------------------------|
| BeeBuilder | factory, builder | too many constructor, too many |
| | | parameters |
| Insect | factory | too many constructor |
| Bee | factory, builder | complex constructor, too |
| | | many constructor, too many |
| | | parameters |
+------------+------------------+--------------------------------+
cmd/testdata/tbs_normal.txt
浏览文件 @
0b010e9f
Test Bad Smell nums: 12
+------------------------+---------------------------------------------------+------+
| TYPE | FILENAME | LINE |
+------------------------+---------------------------------------------------+------+
|------------------------|---------------------------------------------------|------|
| DuplicateAssertTest | ../_fixtures/tbs/code/DuplicateAssertTest.java | 9 |
| EmptyTest | ../_fixtures/tbs/code/EmptyTest.java | 8 |
| IgnoreTest | ../_fixtures/tbs/code/IgnoreTest.java | 0 |
...
...
@@ -14,4 +13,3 @@ Test Bad Smell nums: 12
| RedundantAssertionTest | ../_fixtures/tbs/code/SleepyTest.java | 7 |
| EmptyTest | ../_fixtures/tbs/code/UnknownTest.java | 7 |
| UnknownTest | ../_fixtures/tbs/code/UnknownTest.java | 7 |
+------------------------+---------------------------------------------------+------+
cmd/todo.go
浏览文件 @
0b010e9f
...
...
@@ -3,7 +3,6 @@ package cmd
import
(
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/pkg/application/todo"
"github.com/spf13/cobra"
...
...
@@ -39,7 +38,7 @@ var todoCmd = &cobra.Command{
cModel
,
_
:=
json
.
MarshalIndent
(
todos
,
""
,
"
\t
"
)
cmd_util
.
WriteToCocaFile
(
"todos.json"
,
string
(
cModel
))
table
:=
tablewriter
.
NewWriter
(
output
)
table
:=
cmd_util
.
NewOutput
(
output
)
table
.
SetHeader
([]
string
{
"Date"
,
"Author"
,
"Messages"
,
"FileName"
,
"Line"
})
for
_
,
todo
:=
range
gitTodos
{
table
.
Append
([]
string
{
todo
.
Date
,
todo
.
Author
,
strings
.
Join
(
todo
.
Message
,
"
\n
"
),
todo
.
FileName
,
todo
.
Line
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录