Software Quality Journal Программное обеспечение
Software maintainability prediction using static code metrics and machine learning
Аннотация
Software maintainability is a critical quality attribute that directly affects maintenance and evolution costs. This study evaluates the extent to which machine learning models can predict high-risk maintainability classes from static code metrics and how well these predictions generalize across unseen projects. Using 304 Java classes from five open-source projects in a publicly available, expert-labeled dataset, six machine learning models were trained on 17 static code metrics and evaluated using recall-oriented and balanced performance measures. The results show that the multilayer perceptron (MLP) achieved the highest average recall (0.849) under internal validation and obtained a recall of 1.00 with an accuracy of 0.93 on the holdout test set. However, leave-one-project-out validation reduced the mean recall to 0.464 across all projects and to 0.773 for projects containing at least five high-risk classes, highlighting the challenge of cross-project generalization. SHAP (SHapley Additive exPlanations) analysis identified Response for a Class, Number of Lines of Code, and Cyclomatic Complexity Number as the most influential predictors, indicating that broader class response sets, larger code size, and more complex control flow are associated with higher maintainability risk. Overall, the findings show that static code metrics can support maintainability assessment, while project-level heterogeneity remains a major challenge for reliable prediction in unseen software projects.