遇见数据集

A Framework for Code Quality Assessment

收藏
Zenodo2026-06-23 更新2026-06-28 收录
官方服务:

资源简介:

1. 项目级代码气味严重度评估示例 为了展示SmellScore框架的完整计算过程,从原始指标值到最终项目级得分,我们构建了一个假设的微型项目(项目A),包含两个类(Class1和Class2)和三种方法(Method1、Method2和Method3)。方法1和方法2属于类1,而方法3属于类2。 本示例仅用于演示计算过程,而非真实的软件系统。因此,一些度量值在实际操作中可能显得异常,但这不会影响对框架的理解。 班级指标 度规 一级 二级 NOAM 0 0 NOPA 0 0 有色人种 0.94 0 LCOM* 0.94 0 世界音乐大会 96 4 NOF 1 0 RFC 118 3 ATFD 7 0 TCC 0 0 诺姆 17 3 时空 308 16 散开 47 1 粉丝聚会 1 0 CBO 10 4 方法级度量 度规 方法1 方法2 方法3 赛克洛 1 2 3 时空 6 24 15 不行 0 0 0 最大嵌套 0 1 1 诺尔夫 2 5 5 ATFD 1 1 2 自由民主党 0 0 0 LAA 1 1 1 CBO 3 6 4 ALD 2 8 13 第一步:嗅觉检测 根据表3-1中定义的检测策略: 第一类触发: 神级攻略1 神级攻略2 大型类策略2 大类策略3 大类策略5 二级不会触发任何职业级的气味策略。 在方法层面: 方法2触发条件: 特色羡慕策略2 脑法策略2 方法3触发条件: 脑法策略2 方法1不会触发任何嗅觉策略。 第二步:度量冲突解决 从所有触发策略中提取的初始度量配置元组(MCT)如下: 对于一年级: 反反向性死亡(6,2,阳性) WMC(47,2,阳性) TCC(0.33,2,阴性) NOM(15,2,阳性) ATFD(4,1,阳性) WMC(47,1,阳性) TCC(0.33,1,阴性) LOC(150,2,阳性) 应用最小阈值原则和权重优先原则可得: ATFD(4,1,阳性) WMC(47,2,阳性) TCC(0.33, 2, negative) NOM(15, 2, positive) LOC(150, 2, positive) For Method2: CBO(5, 2, positive) NOLV(5, 2, positive) ALD(4, 2, positive) For Method3: NOLV(5, 2, positive) ALD(4, 2, positive) No conflicts occur for Method2 or Method3. Step 3: Entity Severity Calculation Using Eq .3, the self-severity of Class1 is: SelfSev(Class1)= (7−4)/4 × 1+(96−47)/47 × 2+(0.33−0)/0.33 × 2+(17−15)/15 × 2+(308−150)/150 × 2= 7.2085 Since Class2 does not trigger any smell strategy: SelfSev(Class2) = 0 Method-level severity values are: Method2: Sev(Method2)= (6−5)/5 × 2+(5−5)/5 × 2+(8−4)/4 × 2= 0.4 + 0 + 2.0= 2.4 Method3: Sev(Method3)= (5−5)/5 × 2+(13−4)/4 × 2= 4.5 Method1: Sev(Method1) = 0 Step 4: LOC-Weighted Method Severity Using Eq .4: Class1 contains Method1 and Method2, whereas Class2 contains only Method3. For Class1: AvgMethodSev(Class1)= (0 × 6 + 2.4 × 24) / (6 + 24)= 1.92 For Class2: AvgMethodSev(Class2)= 4.5 Step 5: Class-Level Severity Using Eq .5, with a class weight of 0.75 and a method weight of 0.25: ClassSev(Class1)= 0.75 × 7.2085 + 0.25 × 1.92= 5.886 ClassSev(Class2)= 0.75 × 0 + 0.25 × 4.5= 1.125 Step 6: Structural Adjustment Factor (SAF) Using Eq .6: For Class1: SAF(Class1)= 1 + 0.5 × log2(1 + 1) + 0.3 × 10= 4.5 For Class2: SAF(Class2)= 1 + 0.5 × log2(0 + 1) + 0.3 × 4= 2.2 Step 7: Project-Level CSS Calculation The total project LOC is: Total LOC = 308 + 16 = 324 Therefore: LOC Ratio(Class1) = 308 / 324 = 0.951 LOC Ratio(Class2) = 16 / 324 = 0.049 Using Eq .7: CSS= 5.886 × 4.5 × 0.951+1.125 × 2.2 × 0.049= 25.2956 Thus, the final Code Smell Severity Score (CSS) of Project A is: CSS = 25.2956 2. Parameter Sensitivity and Robustness Analysis Although SmellScore employs several configurable parameters, its effectiveness should not depend on extensive parameter tuning. To evaluate the robustness of the proposed model, we conducted a systematic sensitivity analysis of its three default parameters. The explored parameter ranges were: class_weight ∈ {0.25, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90} saf_fanin ∈ {0.35, 0.50, 0.65} saf_cbo ∈ {0.21, 0.30, 0.39} The default configuration was: class_weight = 0.75 saf_fanin = 0.50 saf_cbo = 0.30 Using this configuration as the baseline, we calculated the Spearman rank correlation coefficient between the CSS ranking of 48 projects produced by each parameter combination and the baseline ranking. 2.1 Results The results are shown in the following figure (Parameter.png).When class_weight varies between 0.60 and 0.90, all parameter combinations produce Spearman correlation coefficients greater than 0.98, indicating that the resulting project rankings are nearly identical to the baseline. Even when class_weight is reduced to 0.50, the correlation remains above 0.96. Noticeable ranking changes only appear when class_weight decreases to 0.30 or 0.25, where the correlation falls to approximately 0.88–0.92. These results indicate that the default value of 0.75 lies near the center of a broad stable region, within which moderate parameter variations have little influence on the final project rankings. 2.2 Influence of SAF Parameters Fixing class_weight at 0.75 and varying saf_fanin and saf_cbo within ±30% of their default values yields Spearman correlations consistently above 0.98. The corresponding ranking curves are nearly indistinguishable, demonstrating that project rankings are highly insensitive to these two coefficients. Across all evaluated parameter combinations: Lowest correlation: approximately 0.884 class_weight = 0.25 saf_fanin = 0.35 saf_cbo = 0.21 Vast majority of configurations: Spearman correlation > 0.95 2.3 Conclusion The sensitivity analysis demonstrates that the default parameter settings of SmellScore reside in a highly stable region of the parameter space. Reasonable adjustments to: class_weight (0.25~0.9) saf_fanin (approximately ±30%) saf_cbo (approximately ±30%) have only negligible effects on project-level rankings. These findings indicate that SmellScore is robust against parameter variation, reducing the need for project-specific tuning and improving both the practical applicability and reproducibility of the framework. The package contains the source code of the code quality assessment framework, as well as the complete experimental dataset, including code smell statistics for 50 open-source Java projects and 16 evolutionary versions of Apache Calcite (v1.10.0 to v1.40.0).

提供机构:
Zenodo
创建时间:
2026-06-23
二维码
社区交流群
二维码
科研交流群
商业服务