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

test: add test for large class

上级 6944c1cb
package com.phodal.coca.analysis.identifier.model;
public class DataClass {
public void method1() {}
public void method2() {}
public void method3() {}
public void method4() {}
public void method5() {}
public void method6() {}
public void method7() {}
public void method8() {}
public void method9() {}
public void method10() {}
public void method11() {}
public void method12() {}
public void method13() {}
public void method14() {}
public void method15() {}
public void method16() {}
public void method17() {}
public void method18() {}
public void method19() {}
public void method20() {}
}
......@@ -91,3 +91,17 @@ func TestBadSmellApp_MultipleIf(t *testing.T) {
g.Expect(len(bsList)).To(Equal(1))
g.Expect(bsList[0].Bs).To(Equal("repeatedSwitches"))
}
func TestBadSmellApp_LargeClass(t *testing.T) {
g := NewGomegaWithT(t)
bsApp := NewBadSmellApp()
codePath := "../../../_fixtures/bs/LargeClass.java"
codePath = filepath.FromSlash(codePath)
bs := bsApp.AnalysisPath(codePath)
bsList := bsApp.FilterBadSmell(bs, nil)
g.Expect(len(bsList)).To(Equal(1))
g.Expect(bsList[0].Bs).To(Equal("largeClass"))
}
......@@ -75,7 +75,7 @@ func checkRefusedBequest(node bs_domain.BsJClass, badSmellList *[]bs_domain.BadS
func checkLargeClass(node bs_domain.BsJClass, badSmellList *[]bs_domain.BadSmellModel) {
normalClassLength := withOutGetterSetterClass(node.Methods)
if node.Type == "Class" && normalClassLength > BS_LARGE_LENGTH {
if node.Type == "Class" && normalClassLength >= BS_LARGE_LENGTH {
description := "methods number (without getter/setter): " + strconv.Itoa(normalClassLength)
*badSmellList = append(*badSmellList, *&bs_domain.BadSmellModel{node.Path, "", "largeClass", description, normalClassLength})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册