Severe software defects can lead to significant issues and even result in substantial financial losses. As a result, automated code defect detection has garnered widespread attention. To fix these defects as soon as possible, J ust- I n- T ime D efect P rediction (JIT-DP) and J ust- I n- T ime D efect L ocalization (JIT-DL) have been investigated. Specifically, JIT-DP aims to predict commit-level defects when a code change is submitted, and JIT-DL aims to perform line-level defect localization before they lead to failures. Several methods have been developed for JIT-DP and JIT-DL, with those using C ode P re- T rained M odels (CPTMs) leading to the best results. However, most previous studies concentrate on JIT-DP, even though JIT-DL is arguably more crucial. Identifying which specific lines of a commit are defective facilitates the prediction of whether the commit is defective. Therefore, we propose a M ulti- T ask L earning method (JIT-MTL) designed to address both JIT-DP and JIT-DL. Specifically, we train a CPTM to simultaneously identify defective commits and lines. The line-level predictions are directly used for JIT-DL, while the commit-level predictions for the same commit are merged to determine the results for JIT-DP. To enhance the accuracy of line-level predictions, we provide the CPTM with additional commit-level information, including commit-level defect code representation and expert features. Experimental results on the JIT-Defect4J dataset show that JIT-MTL outperforms the state-of-the-art baselines, with improvements of 14% in F1 in JIT-DP, 53.9% in Top-10 Accuracy, and 36.4% in Top-5 Accuracy in JIT-DL.
Shen et al. (Mon,) studied this question.