Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
b4893c47
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 搜索 >>
未验证
提交
b4893c47
编写于
12月 30, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: [tbs] add RedundantAssertionTest
上级
a046289a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
59 addition
and
23 deletion
+59
-23
core/adapter/call/java_call_app_test.go
core/adapter/call/java_call_app_test.go
+18
-0
core/adapter/call/java_call_listener.go
core/adapter/call/java_call_listener.go
+24
-11
core/adapter/sql/sql_identifier_listener.go
core/adapter/sql/sql_identifier_listener.go
+0
-8
core/domain/tbs/tbs_app.go
core/domain/tbs/tbs_app.go
+14
-1
core/domain/tbs/tbs_app_test.go
core/domain/tbs/tbs_app_test.go
+2
-2
core/models/jmethod_call.go
core/models/jmethod_call.go
+1
-1
未找到文件。
core/adapter/call/java_call_app_test.go
浏览文件 @
b4893c47
...
...
@@ -193,3 +193,21 @@ func Test_ShouldNotGetCreators(t *testing.T) {
g
.
Expect
(
len
(
methodMap
[
"testTrue"
]
.
Creators
))
.
To
(
Equal
(
0
))
}
func
Test_ShouldGetMethodCallParameters
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
codePath
:=
"../../../_fixtures/tbs/code/RedundantAssertionTest.java"
codePath
=
filepath
.
FromSlash
(
codePath
)
callNodes
:=
getCallNodes
(
codePath
)
methodCallMap
:=
make
(
map
[
string
]
models
.
JMethodCall
)
for
_
,
method
:=
range
callNodes
[
0
]
.
Methods
{
for
_
,
call
:=
range
method
.
MethodCalls
{
methodCallMap
[
call
.
MethodName
]
=
call
}
}
g
.
Expect
(
methodCallMap
[
"assertEquals"
]
.
Parameters
)
.
To
(
Equal
([]
string
{
"true"
,
"true"
}))
}
core/adapter/call/java_call_listener.go
浏览文件 @
b4893c47
...
...
@@ -318,17 +318,7 @@ func buildMethodParameters(parameters parser.IFormalParametersContext, method *m
return
true
}
var
methodParams
[]
models
.
JParameter
=
nil
parameterList
:=
parameters
.
GetChild
(
1
)
.
(
*
parser
.
FormalParameterListContext
)
formalParameter
:=
parameterList
.
AllFormalParameter
()
for
_
,
param
:=
range
formalParameter
{
paramContext
:=
param
.
(
*
parser
.
FormalParameterContext
)
paramType
:=
paramContext
.
TypeType
()
.
GetText
()
paramValue
:=
paramContext
.
VariableDeclaratorId
()
.
(
*
parser
.
VariableDeclaratorIdContext
)
.
IDENTIFIER
()
.
GetText
()
localVars
[
paramValue
]
=
paramType
methodParams
=
append
(
methodParams
,
*&
models
.
JParameter
{
Name
:
paramValue
,
Type
:
paramType
})
}
methodParams
:=
getMethodParameters
(
parameters
)
method
.
Parameters
=
methodParams
updateMethod
(
method
)
...
...
@@ -336,6 +326,21 @@ func buildMethodParameters(parameters parser.IFormalParametersContext, method *m
return
false
}
func
getMethodParameters
(
parameters
parser
.
IFormalParametersContext
)
[]
models
.
JParameter
{
var
methodParams
[]
models
.
JParameter
=
nil
parameterList
:=
parameters
.
GetChild
(
1
)
.
(
*
parser
.
FormalParameterListContext
)
formalParameter
:=
parameterList
.
AllFormalParameter
()
for
_
,
param
:=
range
formalParameter
{
paramContext
:=
param
.
(
*
parser
.
FormalParameterContext
)
paramType
:=
paramContext
.
TypeType
()
.
GetText
()
paramValue
:=
paramContext
.
VariableDeclaratorId
()
.
(
*
parser
.
VariableDeclaratorIdContext
)
.
IDENTIFIER
()
.
GetText
()
localVars
[
paramValue
]
=
paramType
methodParams
=
append
(
methodParams
,
*&
models
.
JParameter
{
Name
:
paramValue
,
Type
:
paramType
})
}
return
methodParams
}
func
updateMethod
(
method
*
models
.
JMethod
)
{
if
currentType
==
"CreatorClass"
{
creatorMethodMap
[
getMethodMapName
(
*
method
)]
=
*
method
...
...
@@ -535,6 +540,14 @@ func (s *JavaCallListener) EnterMethodCall(ctx *parser.MethodCallContext) {
}
jMethodCall
.
Class
=
targetType
if
ctx
.
ExpressionList
()
!=
nil
{
var
parameters
[]
string
for
_
,
expression
:=
range
ctx
.
ExpressionList
()
.
(
*
parser
.
ExpressionListContext
)
.
AllExpression
()
{
parameters
=
append
(
parameters
,
expression
.
(
*
parser
.
ExpressionContext
)
.
GetText
())
}
jMethodCall
.
Parameters
=
parameters
}
addMethodCall
(
jMethodCall
)
}
...
...
core/adapter/sql/sql_identifier_listener.go
浏览文件 @
b4893c47
...
...
@@ -22,14 +22,6 @@ func NewSqlIdentifierListener() *SqlIdentifierListener {
return
&
SqlIdentifierListener
{}
}
func
(
s
*
SqlIdentifierListener
)
EnterSelect_stmt
(
ctx
*
parser
.
Select_stmtContext
)
{
}
func
(
s
*
SqlIdentifierListener
)
EnterSelect_or_values
(
ctx
*
parser
.
Select_or_valuesContext
)
{
}
func
(
s
*
SqlIdentifierListener
)
EnterSelect_core
(
ctx
*
parser
.
Select_coreContext
)
{
columns
:=
ctx
.
AllResult_column
()
for
_
,
col
:=
range
columns
{
...
...
core/domain/tbs/tbs_app.go
浏览文件 @
b4893c47
...
...
@@ -86,8 +86,21 @@ func (a TbsApp) AnalysisPath(deps []models.JClassNode, identifiersMap map[string
return
results
}
func
checkRedundantAssertionTest
(
path
string
,
call
models
.
JMethodCall
,
method
models
.
JMethod
,
result
*
[]
TestBadSmell
,
testType
*
string
)
{
func
checkRedundantAssertionTest
(
path
string
,
call
models
.
JMethodCall
,
method
models
.
JMethod
,
results
*
[]
TestBadSmell
,
testType
*
string
)
{
TWO_PARAMETERS
:=
2
if
len
(
call
.
Parameters
)
==
TWO_PARAMETERS
{
if
call
.
Parameters
[
0
]
==
call
.
Parameters
[
1
]
{
*
testType
=
"RedundantAssertionTest"
tbs
:=
*&
TestBadSmell
{
FileName
:
path
,
Type
:
*
testType
,
Description
:
""
,
Line
:
method
.
StartLine
,
}
*
results
=
append
(
*
results
,
tbs
)
}
}
}
func
hasAssertion
(
methodName
string
)
bool
{
...
...
core/domain/tbs/tbs_app_test.go
浏览文件 @
b4893c47
...
...
@@ -86,8 +86,8 @@ func TestTbsApp_RedundantAssertionTest(t *testing.T) {
result
:=
buildTbsResult
(
codePath
)
g
.
Expect
(
len
(
result
))
.
To
(
Equal
(
0
))
//g.Expect(result[0].Type).To(Equal("Empty
Test"))
g
.
Expect
(
len
(
result
))
.
To
(
Equal
(
1
))
g
.
Expect
(
result
[
0
]
.
Type
)
.
To
(
Equal
(
"RedundantAssertion
Test"
))
}
func
TestTbsApp_CreatorNotUnknownTest
(
t
*
testing
.
T
)
{
...
...
core/models/jmethod_call.go
浏览文件 @
b4893c47
...
...
@@ -5,7 +5,7 @@ type JMethodCall struct {
Type
string
Class
string
MethodName
string
Parameters
[]
JParameter
Parameters
[]
string
StartLine
int
StartLinePosition
int
StopLine
int
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录