MARS: Detecting brain class/method code smell based on metric–attention mechanism and residual network

Abstract Code smell is the structural design defect that makes programs difficult to understand, maintain, and evolve. Existing works of code smell detection mainly focus on prevalent code smells, such as feature envy, god class, and long method. Few works have been done on detecting brain class/met...

Full description

Saved in:
Bibliographic Details
Published inJournal of software : evolution and process Vol. 36; no. 1
Main Authors Zhang, Yang, Dong, Chunhao
Format Journal Article
LanguageEnglish
Published Chichester Wiley Subscription Services, Inc 01.01.2024
Subjects
Online AccessGet full text

Cover

Loading…
More Information
Summary:Abstract Code smell is the structural design defect that makes programs difficult to understand, maintain, and evolve. Existing works of code smell detection mainly focus on prevalent code smells, such as feature envy, god class, and long method. Few works have been done on detecting brain class/method. Furthermore, existing deep‐learning‐based approaches leverage the CNN model to improve accuracy by barely increasing the number of layers, which may cause a problem of gradient degradation. To this end, this paper proposes a novel approach called MARS to detect brain class/method. MARS improves the gradient degradation by employing an improved residual network. It increases the weight value of those important code metrics to label smelly samples by introducing a metric–attention mechanism. To support the training of MARS, a dataset called BrainCode is generated by extracting more than 270,000 samples from 20 real‐world applications. MARS is evaluated on BrainCode and compared to other machine‐learning‐based and deep‐learning‐based approaches. The experimental results demonstrate that the average accuracy of MARS is 2.01 % higher than that of the existing approaches, which improves state‐of‐the‐art.
ISSN:2047-7473
2047-7481
DOI:10.1002/smr.2403