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

refactor: update performance for tbs

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