YANG ET AL:ARE SLICE-BASED COHESION METRICS ACTUALLY USEFUL IN EFFORT-AWARE POST-RELEASE FAULT-PRONENESS.. 335 TABLE 2 End Slice Profile and Metric Slice Profile for Function Fun Line Code End slice Forward slice Metric slice largest smallest range largest smallest range largest smallest range int fun( 1 int A[] 2 int size, 3 int"largest, 4 int 'smallest) 5 inti; 6 int range; 7 1=1少 8 range =0; 9 "smallest =A[0]; 10 "largest ='smallest; 11 while(i size) 12 if('smallest Alil) 13 smallest =A[i]; 14 if("largest Ali]) 15 "largest=Alil; 16 计+: 17 range="largest-'smallest; 18 return range; Data tokens included in the end slice for the variable smallest are indicated by the underline. example function fun shown in Table 2,we find that,except MaxCoverage,MinCoverage,Overlap,Tightness,WFC,NHD, an unnecessary initialization statement (statement 8 in and SBFC.During our analysis,a function is regarded as a Table 2:range=0;),all the rest statements are all related to module and the output variables of a function consist of the the computation of the final outputs.In other words,intui- function return value,modified global variables,modified tively,this function has a high cohesion.In this sense,when reference parameters,and standard outputs by the function. measuring its cohesion,it appears that metric-slice-based cohesion metrics are more accurate than end-slice-based 2.2 The Most Commonly Used Code and Process cohesion metrics. Metrics As mentioned above,Coverage,MaxCoverage,MinCover- In this study,we employ the most commonly used code and age,Overlap,Tightness,SFC,WFC,and A are originally based process metrics as the baseline metrics to analyze the actual on metric slices[4l,[6l,[13l,[15],[16,[17,[18,[211.How- usefulness of slice-based cohesion metrics in effort-aware ever,NHD and SBFC are originally based on end slices.In post-release fault-proneness prediction.As shown in Table5, this study,we will use metric slices to compute all the cohe- the baseline code and process metrics cover 16 product met- sion metrics.In particular,we will use metric-slice-based rics and three process metrics.These 16 product metrics con- cohesion metrics at the data-token level to investigate the sist of 1 size metric,11 structural complexity metrics,and actual usefulness of slice-based cohesion metrics in effort- 4 software science metrics.The size metric SLOC simply aware post-release fault-proneness prediction.The reason counts the non-blank non-commentary source lines of code for choosing the data-token level rather than the statement (SLOC)in a function.There is a common belief that a func- level is that the former is at a finer granularity.Previous tion with a larger size tends to be more fault-prone [221,[23], studies suggested that software metrics at a finer granularity [24],[25].The structural complexity metrics,including the would accordingly have a higher discriminative power and well-known McCabe's Cyclomatic complexity metrics hence may be more useful for fault-proneness prediction assume that a function with complex control flow structure [62],[63].Note that,at the data-token level,SFC is equiva- is likely to be fault-prone [26],[271,[28],[29].The Halstead's lent to Tightness and A is equivalent to Coverage.Therefore, software science metrics estimate reading complexity based in the subsequent analysis,only the following eight metric- on the counts of operators and operands,in which a function slice-based cohesion metrics will be examined:Coverage, hard to read is assumed to be fault-prone [30].Note that weexample function fun shown in Table 2, we find that, except an unnecessary initialization statement (statement 8 in Table 2: range ¼ 0;), all the rest statements are all related to the computation of the final outputs. In other words, intuitively, this function has a high cohesion. In this sense, when measuring its cohesion, it appears that metric-slice-based cohesion metrics are more accurate than end-slice-based cohesion metrics. As mentioned above, Coverage, MaxCoverage, MinCoverage, Overlap, Tightness, SFC, WFC, and A are originally based on metric slices [4], [6], [13], [15], [16], [17], [18], [21]. However, NHD and SBFC are originally based on end slices. In this study, we will use metric slices to compute all the cohesion metrics. In particular, we will use metric-slice-based cohesion metrics at the data-token level to investigate the actual usefulness of slice-based cohesion metrics in effortaware post-release fault-proneness prediction. The reason for choosing the data-token level rather than the statement level is that the former is at a finer granularity. Previous studies suggested that software metrics at a finer granularity would accordingly have a higher discriminative power and hence may be more useful for fault-proneness prediction [62], [63]. Note that, at the data-token level, SFC is equivalent to Tightness and A is equivalent to Coverage. Therefore, in the subsequent analysis, only the following eight metricslice-based cohesion metrics will be examined: Coverage, MaxCoverage, MinCoverage, Overlap, Tightness, WFC, NHD, and SBFC. During our analysis, a function is regarded as a module and the output variables of a function consist of the function return value, modified global variables, modified reference parameters, and standard outputs by the function. 2.2 The Most Commonly Used Code and Process Metrics In this study, we employ the most commonly used code and process metrics as the baseline metrics to analyze the actual usefulness of slice-based cohesion metrics in effort-aware post-release fault-proneness prediction. As shown in Table 5, the baseline code and process metrics cover 16 product metrics and three process metrics. These 16 product metrics consist of 1 size metric, 11 structural complexity metrics, and 4 software science metrics. The size metric SLOC simply counts the non-blank non-commentary source lines of code (SLOC) in a function. There is a common belief that a function with a larger size tends to be more fault-prone [22], [23], [24], [25]. The structural complexity metrics, including the well-known McCabe’s Cyclomatic complexity metrics, assume that a function with complex control flow structure is likely to be fault-prone [26], [27], [28], [29]. The Halstead’s software science metrics estimate reading complexity based on the counts of operators and operands, in which a function hard to read is assumed to be fault-prone [30]. Note that we TABLE 2 End Slice Profile and Metric Slice Profile for Function Fun Line Code End slice Forward slice Metric slice largest smallest range largest smallest range largest smallest range int fun( 1 int A[] j jj j jj 2 int size, j jj j jj 3 int largest, jj jj 4 int smallest) j jj j jj { 5 int i; j jj j jj 6 int range; j j 7 i ¼ 1; j jj j jj 8 range ¼ 0; 9 smallest ¼ A[0]; j jj j j jj 10 largest ¼ smallest; j jj j j j j 11 while(i < size) { j jj j jj 12 if( smallest > A[i]) jj j jj 13 smallest ¼ A[i]; jj j jj 14 if( largest < A[i]) j jj j j j j 15 largest ¼ A[i]; j jj j j j j 16 iþþ; j jj j jj } 17 range ¼ largest - smallest; jj j jj j j 18 return range; jj j jj j j } Data tokens included in the end slice for the variable smallest are indicated by the underline. YANG ET AL.: ARE SLICE-BASED COHESION METRICS ACTUALLY USEFUL IN EFFORT-AWARE POST-RELEASE FAULT-PRONENESS... 335