fix: fix methodname empty unknown issue

上级 d064daa6
......@@ -41,6 +41,9 @@ func (a TbsApp) AnalysisPath(deps []domain.JClassNode, identifiersMap map[string
var hasAssert = false
for index, methodCall := range currentMethodCalls {
if methodCall.MethodName == "" {
if index == len(currentMethodCalls)-1 {
checkAssert(hasAssert, clz, method, &results, &testType)
}
continue
}
......@@ -55,9 +58,7 @@ func (a TbsApp) AnalysisPath(deps []domain.JClassNode, identifiersMap map[string
}
if index == len(currentMethodCalls)-1 {
if !hasAssert {
checkUnknownTest(clz, method, &results, &testType)
}
checkAssert(hasAssert, clz, method, &results, &testType)
}
}
......@@ -68,6 +69,21 @@ func (a TbsApp) AnalysisPath(deps []domain.JClassNode, identifiersMap map[string
return results
}
func checkAssert(hasAssert bool, clz domain.JClassNode, method domain.JMethod, results *[]TestBadSmell, testType *string) {
if !hasAssert {
*testType = "UnknownTest"
tbs := *&TestBadSmell{
FileName: clz.Path,
Type: *testType,
Description: "",
Line: method.StartLine,
}
*results = append(*results, tbs)
}
}
func updateMethodCallsForSelfCall(method domain.JMethod, clz domain.JClassNode, callMethodMap map[string]domain.JMethod) []domain.JMethodCall {
currentMethodCalls := method.MethodCalls
for _, methodCall := range currentMethodCalls {
......@@ -98,18 +114,6 @@ func checkRedundantAssertionTest(path string, call domain.JMethodCall, method do
}
}
func checkUnknownTest(clz domain.JClassNode, method domain.JMethod, results *[]TestBadSmell, testType *string) {
*testType = "UnknownTest"
tbs := *&TestBadSmell{
FileName: clz.Path,
Type: *testType,
Description: "",
Line: method.StartLine,
}
*results = append(*results, tbs)
}
func checkDuplicateAssertTest(clz domain.JClassNode, results *[]TestBadSmell, methodCallMap map[string][]domain.JMethodCall, method domain.JMethod, testType *string) {
var isDuplicateAssert = false
for _, methodCall := range methodCallMap {
......
......@@ -128,7 +128,7 @@ func TestTbsApp_ShouldReturnMultipleResult(t *testing.T) {
result := buildTbsResult(codePath)
g.Expect(len(result)).To(Equal(3))
g.Expect(len(result)).To(Equal(4))
}
func buildTbsResult(codePath string) []TestBadSmell {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册