Gilad Katz

Senior Academic

Code Smells Thresholds Optimization

Defect Prediction as a Case Study

Tom Mashiach, Gilad Katz,Meir Kalech

In software engineering, detecting and managing code smells are pivotal for maintaining software quality and reducing the risk of defects. Code smells signify potential issues in code that, while not problematic in themselves, may indicate deeper design flaws or future complications. Traditional code smells detection methods, which compare code metrics against fixed or statistically derived thresholds, may not always yield the most accurate code smells relevant to specific software practices. Addressing this gap, this research introduces an innovative methodology that utilizes a neural threshold generator, trained via a cooperative critic, to dynamically generate threshold values for detecting code smells in software components. Although the critic is conceptually related to the discriminator in a Generative Adversarial Network (GAN), its training objective is aligned with rather than adversarial to that of the generator. By integrating relevant code metrics, the proposed model generates customized thresholds for each software component. Our current evaluation focuses on a set of 11 class-level code smells defined by single or AND-connected conditions. It then uses these thresholds to identify code smells, which serve as input features to train a defect prediction model. A key feature of our approach is a cooperative-critic feedback mechanism that continuously refines the thresholds based on the defect prediction outcomes, ensuring the model’s effectiveness in identifying potential software issues is consistently improved. This advanced approach has demonstrated superior defect prediction performance, as evidenced by improved metrics such as the F1-score, AUC-ROC, and AUC-PRC, compared with the results of a defect prediction model that uses the traditional thresholds. Our study underscores the effectiveness of generating context-specific thresholds through neural networks, suggesting a promising avenue for exploring related software practices.

Publication language English
Journal Algorithms
Volume 19
Issue number 5
Publication status Published - 01.05.2026
412

Keywords

code smells
defect prediction
thresholds

ASJC Scopus subject areas

Theoretical Computer Science
Numerical Analysis
Computational Theory and Mathematics
Computational Mathematics
Access to Document
10.3390/a19050412
Other files and links
Link to publication in Scopus