未验证 提交 43d0a3ca 编写于 作者: P Phodal Huang

refactor: update performance for tbs

上级 ddd69770
......@@ -24,11 +24,13 @@ func (a TbsApp) AnalysisPath(deps []models.JClassNode, identifiersMap map[string
for _, clz := range deps {
// TODO refactoring identify & annotation
for _, method := range clz.Methods {
checkIgnoreTest(clz.Path, method, &results)
checkEmptyTest(clz.Path, method, &results)
checkRedundantPrintTest(clz.Path, method, &results)
for _, annotation := range method.Annotations {
checkIgnoreTest(clz.Path, annotation, &results)
checkEmptyTest(clz.Path, annotation, &results, method)
}
for _, methodCall := range method.MethodCalls {
checkRedundantPrintTest(clz.Path, methodCall, &results)
checkUnknownTest(clz.Path, methodCall, &results)
}
}
......@@ -50,9 +52,8 @@ func checkUnknownTest(path string, method models.JMethodCall, results *[]TestBad
}
}
func checkRedundantPrintTest(path string, method models.JMethod, results *[]TestBadSmell) {
for _, method := range method.MethodCalls {
if method.Class == "System.out" && (method.MethodName == "println" || method.MethodName == "printf" || method.MethodName == "print") {
func checkRedundantPrintTest(path string, mCall models.JMethodCall, results *[]TestBadSmell) {
if mCall.Class == "System.out" && (mCall.MethodName == "println" || mCall.MethodName == "printf" || mCall.MethodName == "print") {
tbs := *&TestBadSmell{
FileName: path,
Type: "RedundantPrintTest",
......@@ -62,11 +63,9 @@ func checkRedundantPrintTest(path string, method models.JMethod, results *[]Test
*results = append(*results, tbs)
}
}
}
func checkEmptyTest(path string, method models.JMethod, results *[]TestBadSmell) {
for _, annotation := range method.Annotations {
func checkEmptyTest(path string, annotation models.Annotation, results *[]TestBadSmell, method models.JMethod) {
if annotation.QualifiedName == "Test" {
if len(method.MethodCalls) <= 1 {
tbs := *&TestBadSmell{
......@@ -79,12 +78,9 @@ func checkEmptyTest(path string, method models.JMethod, results *[]TestBadSmell)
*results = append(*results, tbs)
}
}
}
}
func checkIgnoreTest(clzPath string, method models.JMethod, results *[]TestBadSmell) {
for _, annotation := range method.Annotations {
func checkIgnoreTest(clzPath string, annotation models.Annotation, results *[]TestBadSmell) {
if annotation.QualifiedName == "Ignore" {
tbs := *&TestBadSmell{
FileName: clzPath,
......@@ -95,5 +91,4 @@ func checkIgnoreTest(clzPath string, method models.JMethod, results *[]TestBadSm
*results = append(*results, tbs)
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册