private void BTNFindAPsInRoles_Click(object sender, EventArgs e) { Debug.WriteLine("Mapping roles to antipatterns..."); List <JavaClass> javaClasses = ClassRoleIdentifier.AttachRolesToJavaClasses(TBSelectedClassifiedCSV.Text); javaClasses = AntiPatternDetector.AttachAntipatternsToJavaClasses(TBSelectedIniDir.Text, javaClasses); // For each role, find classes that has that role, add each antipattern to a counter... foreach (string role in ClassRoleIdentifier.ROLES) { Debug.WriteLine("//========== " + role + " ==========//"); int[] numAntipatterns = new int[18]; // 0=AntiSingleton, 1=BaseClassKnowsDerivedClass, 2=BaseClassShouldBeAbstract, // 3=Blob, 4=ClassDataShouldBePrivate, 5=ComplexClass, // 6=FunctionalDecomposition, 7=LargeClass, 8=LazyClass, // 9=LongMethod, 10=LongParameterList, 11=ManyFieldAttributesButNotComplex, // 12=MessageChains, 13=RefusedParentBequest, 14=SpaghettiCode, // 15=SpeculativeGenerality, 16=SwissArmyKnife, 17=TraditionBreaker int index = 0; foreach (string ap in AntiPatternDetector.ANTIPATTERNS) { foreach (JavaClass jc in javaClasses) { if (jc.classRole == role && jc.aps.Contains(ap)) { //Debug.WriteLine(jc.name + " contains " + ap); //Debug.WriteLine("Adding 1 to " + AntiPatternDetector.ANTIPATTERNS[index]); numAntipatterns[index]++; } } index++; } Debug.WriteLine("//---------- In respective order ----------//"); for (int i = 0; i < numAntipatterns.Length; i++) { Debug.WriteLine(numAntipatterns[i]); } } Debug.WriteLine("Done.\n"); }
// Link this method to Find Total Antipatterns button if you want to find .ini in sub directories // instead. Useful to get all data from the entire history of a project instead of doing it // manually for each version. private void BTNFindTotalAPsInSubDirs_Click(object sender, EventArgs e) { AntiPatternDetector.FindTotalAntipatternsInSubDirectories(TBSelectedIniDir.Text); }