Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
31dad88a
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 搜索 >>
未验证
提交
31dad88a
编写于
12月 31, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: tbs behavior to jmethod
上级
537660bd
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
42 addition
and
26 deletion
+42
-26
core/context/count/count_app.go
core/context/count/count_app.go
+1
-1
core/context/rcall/rcall_graph.go
core/context/rcall/rcall_graph.go
+1
-1
core/context/tbs/tbs_app.go
core/context/tbs/tbs_app.go
+8
-22
core/domain/jannotation.go
core/domain/jannotation.go
+12
-0
core/domain/jmethod.go
core/domain/jmethod.go
+11
-1
core/domain/jmethod_call.go
core/domain/jmethod_call.go
+9
-1
未找到文件。
core/context/count/count_app.go
浏览文件 @
31dad88a
...
...
@@ -13,7 +13,7 @@ func BuildCallMap(parserDeps []domain.JClassNode) map[string]int {
for
_
,
clz
:=
range
parserDeps
{
for
_
,
method
:=
range
clz
.
Methods
{
for
_
,
call
:=
range
method
.
MethodCalls
{
callMethod
:=
call
.
BuilFullMethodName
()
callMethod
:=
call
.
Buil
d
FullMethodName
()
if
_
,
ok
:=
projectMethods
[
callMethod
];
ok
{
if
callMap
[
callMethod
]
==
0
{
callMap
[
callMethod
]
=
1
...
...
core/context/rcall/rcall_graph.go
浏览文件 @
31dad88a
...
...
@@ -47,7 +47,7 @@ func BuildRCallMethodMap(parserDeps []domain.JClassNode, projectMaps map[string]
var
caller
=
method
.
BuildFullMethodName
(
clz
)
for
_
,
call
:=
range
method
.
MethodCalls
{
if
call
.
Class
!=
""
{
callee
:=
call
.
BuilFullMethodName
()
callee
:=
call
.
Buil
d
FullMethodName
()
if
projectMaps
[
callee
]
<
1
{
continue
}
...
...
core/context/tbs/tbs_app.go
浏览文件 @
31dad88a
...
...
@@ -25,7 +25,7 @@ func (a TbsApp) AnalysisPath(deps []domain.JClassNode, identifiersMap map[string
callMethodMap
:=
buildCallMethodMap
(
deps
)
for
_
,
clz
:=
range
deps
{
for
_
,
method
:=
range
clz
.
Methods
{
if
!
isTest
(
method
)
{
if
!
method
.
IsJunitTest
(
)
{
continue
}
...
...
@@ -44,7 +44,7 @@ func (a TbsApp) AnalysisPath(deps []domain.JClassNode, identifiersMap map[string
continue
}
methodCallMap
[
getMethodCallFullPath
(
methodCall
)]
=
append
(
methodCallMap
[
getMethodCallFullPath
(
methodCall
)],
methodCall
)
methodCallMap
[
methodCall
.
BuildFullMethodName
()]
=
append
(
methodCallMap
[
methodCall
.
BuildFullMethodName
(
)],
methodCall
)
checkRedundantPrintTest
(
clz
.
Path
,
methodCall
,
&
results
,
&
testType
)
checkSleepyTest
(
clz
.
Path
,
methodCall
,
method
,
&
results
,
&
testType
)
...
...
@@ -72,7 +72,7 @@ func buildCallMethodMap(deps []domain.JClassNode) map[string]domain.JMethod {
var
callMethodMap
=
make
(
map
[
string
]
domain
.
JMethod
)
for
_
,
clz
:=
range
deps
{
for
_
,
method
:=
range
clz
.
Methods
{
callMethodMap
[
clz
.
Package
+
"."
+
clz
.
Class
+
"."
+
method
.
Name
]
=
method
callMethodMap
[
method
.
BuildFullMethodName
(
clz
)
]
=
method
}
}
return
callMethodMap
...
...
@@ -82,7 +82,7 @@ func updateMethodCallsForSelfCall(method domain.JMethod, clz domain.JClassNode,
currentMethodCalls
:=
method
.
MethodCalls
for
_
,
methodCall
:=
range
currentMethodCalls
{
if
methodCall
.
Class
==
clz
.
Class
{
jMethod
:=
callMethodMap
[
getMethodCallFullPath
(
methodCall
)]
jMethod
:=
callMethodMap
[
methodCall
.
BuildFullMethodName
(
)]
if
jMethod
.
Name
!=
""
{
currentMethodCalls
=
append
(
currentMethodCalls
,
jMethod
.
MethodCalls
...
)
}
...
...
@@ -119,16 +119,6 @@ func hasAssertion(methodName string) bool {
return
false
}
func
isTest
(
method
domain
.
JMethod
)
bool
{
var
isTest
=
false
for
_
,
annotation
:=
range
method
.
Annotations
{
if
annotation
.
QualifiedName
==
"Test"
||
annotation
.
QualifiedName
==
"Ignore"
{
isTest
=
true
}
}
return
isTest
}
func
checkUnknownTest
(
clz
domain
.
JClassNode
,
method
domain
.
JMethod
,
results
*
[]
TestBadSmell
,
testType
*
string
)
{
*
testType
=
"UnknownTest"
tbs
:=
*&
TestBadSmell
{
...
...
@@ -165,12 +155,8 @@ func checkDuplicateAssertTest(clz domain.JClassNode, results *[]TestBadSmell, me
}
}
func
getMethodCallFullPath
(
methodCall
domain
.
JMethodCall
)
string
{
return
methodCall
.
Package
+
"."
+
methodCall
.
Class
+
"."
+
methodCall
.
MethodName
}
func
checkSleepyTest
(
path
string
,
method
domain
.
JMethodCall
,
jMethod
domain
.
JMethod
,
results
*
[]
TestBadSmell
,
testType
*
string
)
{
if
method
.
MethodName
==
"sleep"
&&
method
.
Class
==
"Thread"
{
if
method
.
IsThreadSleep
()
{
*
testType
=
"SleepyTest"
tbs
:=
*&
TestBadSmell
{
FileName
:
path
,
...
...
@@ -184,7 +170,7 @@ func checkSleepyTest(path string, method domain.JMethodCall, jMethod domain.JMet
}
func
checkRedundantPrintTest
(
path
string
,
mCall
domain
.
JMethodCall
,
results
*
[]
TestBadSmell
,
testType
*
string
)
{
if
mCall
.
Class
==
"System.out"
&&
(
mCall
.
MethodName
==
"println"
||
mCall
.
MethodName
==
"printf"
||
mCall
.
MethodName
==
"print"
)
{
if
mCall
.
IsSystemOutput
(
)
{
*
testType
=
"RedundantPrintTest"
tbs
:=
*&
TestBadSmell
{
FileName
:
path
,
...
...
@@ -198,7 +184,7 @@ func checkRedundantPrintTest(path string, mCall domain.JMethodCall, results *[]T
}
func
checkEmptyTest
(
path
string
,
annotation
domain
.
Annotation
,
results
*
[]
TestBadSmell
,
method
domain
.
JMethod
,
testType
*
string
)
{
if
annotation
.
QualifiedName
==
"Test"
{
if
annotation
.
IsTest
()
{
if
len
(
method
.
MethodCalls
)
<=
1
{
*
testType
=
"EmptyTest"
tbs
:=
*&
TestBadSmell
{
...
...
@@ -214,7 +200,7 @@ func checkEmptyTest(path string, annotation domain.Annotation, results *[]TestBa
}
func
checkIgnoreTest
(
clzPath
string
,
annotation
domain
.
Annotation
,
results
*
[]
TestBadSmell
,
testType
*
string
)
{
if
annotation
.
QualifiedName
==
"Ignore"
{
if
annotation
.
IsIgnoreTest
()
{
*
testType
=
"IgnoreTest"
tbs
:=
*&
TestBadSmell
{
FileName
:
clzPath
,
...
...
core/domain/jannotation.go
浏览文件 @
31dad88a
...
...
@@ -19,4 +19,16 @@ func NewAnnotation() Annotation {
func
(
n
*
Annotation
)
IsComponentOrRepository
()
bool
{
return
n
.
QualifiedName
==
"Component"
||
n
.
QualifiedName
==
"Repository"
}
func
(
n
*
Annotation
)
IsTest
()
bool
{
return
n
.
QualifiedName
==
"Test"
}
func
(
n
*
Annotation
)
IsIgnoreTest
()
bool
{
return
n
.
QualifiedName
==
"Ignore"
}
func
(
n
*
Annotation
)
IsIgnoreOrTest
()
bool
{
return
n
.
IsTest
()
||
n
.
IsIgnoreTest
()
}
\ No newline at end of file
core/domain/jmethod.go
浏览文件 @
31dad88a
...
...
@@ -64,8 +64,18 @@ func (m *JMethod) GetAllCallString() []string {
var
calls
[]
string
for
_
,
call
:=
range
m
.
MethodCalls
{
if
call
.
Class
!=
""
{
calls
=
append
(
calls
,
call
.
BuilFullMethodName
())
calls
=
append
(
calls
,
call
.
Buil
d
FullMethodName
())
}
}
return
calls
}
func
(
m
*
JMethod
)
IsJunitTest
()
bool
{
var
isTest
=
false
for
_
,
annotation
:=
range
m
.
Annotations
{
if
annotation
.
IsIgnoreOrTest
()
{
isTest
=
true
}
}
return
isTest
}
core/domain/jmethod_call.go
浏览文件 @
31dad88a
...
...
@@ -26,6 +26,14 @@ func NewJMethodCall() JMethodCall {
}
}
func
(
c
*
JMethodCall
)
BuilFullMethodName
()
string
{
func
(
c
*
JMethodCall
)
Buil
d
FullMethodName
()
string
{
return
c
.
Package
+
"."
+
c
.
Class
+
"."
+
c
.
MethodName
}
func
(
c
*
JMethodCall
)
IsSystemOutput
()
bool
{
return
c
.
Class
==
"System.out"
&&
(
c
.
MethodName
==
"println"
||
c
.
MethodName
==
"printf"
||
c
.
MethodName
==
"print"
)
}
func
(
c
*
JMethodCall
)
IsThreadSleep
()
bool
{
return
c
.
MethodName
==
"sleep"
&&
c
.
Class
==
"Thread"
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录