function totalDefects(project, model) { return defects("requirements", project, model) + \ defects("design", project, model) + \ defects("code", project, model) } function defects(type, project, model, percentRemoved,introduced,ksloc) { ksloc = project[getTuning("ksloc")] if (type == "requirements") introduced = 10 * ksloc * defectsIntroduced(type, project, model) if (type == "design") introduced = 20 * ksloc * defectsIntroduced(type, project, model) if (type == "code") introduced = 30 * ksloc * defectsIntroduced(type, project, model) percentRemoved = defectsRemovedRatio(type, project, model) return introduced * percentRemoved } function defectsRemovedRatio(type, project, model, product,drkeys,key,indx) { split(model[getDRKeys()], drkeys, " ") product = 1 for (indx in drkeys) { key = drkeys[indx] if (type == "requirements") product *= (1 - dr2rout(key, project)) if (type == "design") product *= (1 - dr2dout(key, project)) if (type == "code") product *= (1 - dr2cout(key, project)) } return product } function totalDefectsIntroduced(project, model, ksloc) { ksloc = project[getTuning("ksloc")] return 10 * ksloc * defectsIntroduced("requirements", project, model) + \ 20 * ksloc * defectsIntroduced("design", project, model) + \ 30 * ksloc * defectsIntroduced("code", project, model) } function defectsIntroduced(type, project, model, sfkeys,emkeys,key,indx,product) { split(model[getSFKeys()], sfkeys, " ") split(model[getEMKeys()], emkeys, " ") product = 1 for (indx in sfkeys) { key = sfkeys[indx] if (type == "requirements") product *= sf2rin(key, project) if (type == "design") product *= sf2din(key, project) if (type == "code") product *= sf2cin(key, project) } for (indx in emkeys) { key = emkeys[indx] if (type == "requirements") product *= em2rin(key, project) if (type == "design") product *= em2din(key, project) if (type == "code") product *= em2cin(key, project) } return product }