Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
f501c4b4
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 搜索 >>
未验证
提交
f501c4b4
编写于
12月 29, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: add test for tbs
上级
93e186e3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
69 addition
and
11 deletion
+69
-11
README.md
README.md
+5
-1
cmd/tbs.go
cmd/tbs.go
+1
-1
core/adapter/call/java_call_app.go
core/adapter/call/java_call_app.go
+1
-3
core/adapter/helper.go
core/adapter/helper.go
+6
-6
core/domain/tbs/tbs_app_test.go
core/domain/tbs/tbs_app_test.go
+34
-0
core/support/file_analysis_helper.go
core/support/file_analysis_helper.go
+22
-0
未找到文件。
README.md
浏览文件 @
f501c4b4
...
...
@@ -487,7 +487,11 @@ results
-
[x] Architecture Visualization
-
[ ] Architecture Guard
-
[ ] DSL Design
Tech Debt
-
Duplicate Code
-
cmd/ -> user builder to refactoring
## Dev
...
...
cmd/tbs.go
浏览文件 @
f501c4b4
...
...
@@ -27,7 +27,7 @@ var tbsCmd = &cobra.Command{
var
identifiers
[]
models
.
JIdentifier
identifiers
=
adapter
.
LoadTestIdentify
(
files
)
identifiersMap
=
adapter
.
BuildIdentifierMap
(
identifiers
)
identifiersMap
:
=
adapter
.
BuildIdentifierMap
(
identifiers
)
var
classes
[]
string
=
nil
for
_
,
node
:=
range
identifiers
{
...
...
core/adapter/call/java_call_app.go
浏览文件 @
f501c4b4
...
...
@@ -28,9 +28,7 @@ func (j *JavaCallApp) AnalysisFiles(identNodes []models.JIdentifier, files []str
identMap
[
ident
.
Package
+
"."
+
ident
.
ClassName
]
=
ident
}
for
index
:=
range
files
{
file
:=
files
[
index
]
for
_
,
file
:=
range
files
{
displayName
:=
filepath
.
Base
(
file
)
fmt
.
Println
(
"Start parse java call: "
+
displayName
)
...
...
core/adapter/helper.go
浏览文件 @
f501c4b4
package
adapter
import
(
"encoding/json"
"github.com/phodal/coca/core/adapter/identifier"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/support"
"encoding/json"
)
func
BuildIdentifierMap
(
identifiers
[]
models
.
JIdentifier
)
map
[
string
]
models
.
JIdentifier
{
...
...
@@ -20,7 +20,7 @@ func LoadIdentify(importPath string) []models.JIdentifier {
var
identifiers
[]
models
.
JIdentifier
apiContent
:=
support
.
ReadCocaFile
(
"identify.json"
)
if
apiContent
==
nil
{
if
apiContent
==
nil
||
string
(
apiContent
)
==
"null"
{
identifierApp
:=
new
(
identifier
.
JavaIdentifierApp
)
ident
:=
identifierApp
.
AnalysisPath
(
importPath
)
...
...
@@ -38,8 +38,9 @@ func LoadTestIdentify(files []string) []models.JIdentifier {
var
identifiers
[]
models
.
JIdentifier
apiContent
:=
support
.
ReadCocaFile
(
"tidentify.json"
)
if
apiContent
==
nil
{
identifierApp
:=
new
(
identifier
.
JavaIdentifierApp
)
if
apiContent
==
nil
||
string
(
apiContent
)
==
"null"
{
identifierApp
:=
identifier
.
NewJavaIdentifierApp
()
ident
:=
identifierApp
.
AnalysisFiles
(
files
)
identModel
,
_
:=
json
.
MarshalIndent
(
ident
,
""
,
"
\t
"
)
...
...
@@ -60,7 +61,7 @@ func BuildDIMap(identifiers []models.JIdentifier, identifierMap map[string]model
name
:=
annotation
.
QualifiedName
if
(
name
==
"Component"
||
name
==
"Repository"
)
&&
len
(
clz
.
Implements
)
>
0
{
superClz
:=
identifierMap
[
clz
.
Implements
[
0
]]
diMap
[
superClz
.
Package
+
"."
+
superClz
.
ClassName
]
=
clz
.
Package
+
"."
+
clz
.
ClassName
diMap
[
superClz
.
Package
+
"."
+
superClz
.
ClassName
]
=
clz
.
Package
+
"."
+
clz
.
ClassName
}
}
}
...
...
@@ -68,4 +69,3 @@ func BuildDIMap(identifiers []models.JIdentifier, identifierMap map[string]model
return
diMap
}
core/domain/tbs/tbs_app_test.go
0 → 100644
浏览文件 @
f501c4b4
package
tbs
import
(
.
"github.com/onsi/gomega"
"github.com/phodal/coca/core/adapter"
"github.com/phodal/coca/core/adapter/call"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/support"
"testing"
)
func
TestTbsApp_AnalysisPath
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
codePath
:=
"../../../_fixtures/tbs/code/EmptyTest.java"
files
:=
support
.
GetJavaTestFiles
(
codePath
)
var
identifiers
[]
models
.
JIdentifier
identifiers
=
adapter
.
LoadTestIdentify
(
files
)
identifiersMap
:=
adapter
.
BuildIdentifierMap
(
identifiers
)
var
classes
[]
string
=
nil
for
_
,
node
:=
range
identifiers
{
classes
=
append
(
classes
,
node
.
Package
+
"."
+
node
.
ClassName
)
}
analysisApp
:=
call
.
NewJavaCallApp
()
classNodes
:=
analysisApp
.
AnalysisFiles
(
identifiers
,
files
,
classes
)
app
:=
NewTbsApp
()
result
:=
app
.
AnalysisPath
(
classNodes
,
identifiersMap
)
g
.
Expect
(
result
[
0
]
.
Type
)
.
To
(
Equal
(
"EmptyTest"
))
}
\ No newline at end of file
core/support/file_analysis_helper.go
浏览文件 @
f501c4b4
...
...
@@ -17,6 +17,17 @@ func GetJavaFiles(codeDir string) []string {
fmt
.
Println
(
err
)
}
fi
,
err
:=
os
.
Stat
(
codeDir
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
nil
}
if
fi
.
Mode
()
.
IsRegular
()
{
files
=
append
(
files
,
codeDir
)
return
files
}
_
=
filepath
.
Walk
(
codeDir
,
func
(
path
string
,
fi
os
.
FileInfo
,
err
error
)
error
{
if
gitIgnore
!=
nil
{
if
gitIgnore
.
MatchesPath
(
path
)
{
...
...
@@ -39,6 +50,17 @@ func GetJavaTestFiles(codeDir string) []string {
fmt
.
Println
(
err
)
}
fi
,
err
:=
os
.
Stat
(
codeDir
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
nil
}
if
fi
.
Mode
()
.
IsRegular
()
{
files
=
append
(
files
,
codeDir
)
return
files
}
_
=
filepath
.
Walk
(
codeDir
,
func
(
path
string
,
fi
os
.
FileInfo
,
err
error
)
error
{
if
gitIgnore
!=
nil
{
if
gitIgnore
.
MatchesPath
(
path
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录