Data Preparation for Deep Learning based Code Smell Detection: A Systematic Literature Review

Fengji Zhang, Zexian Zhang, Jacky Wai Keung, Xiangru Tang, Zhen Yang, Xiao Yu, Wenhua Hu · DOI

Introduction

In software engineering, "code smells" represent surface-level indicators of deeper design flaws. Common examples like "God Class" (a class that centralizes too much functionality) or "Feature Envy" (a method that interacts more with another class than its own) can significantly hinder maintainability and increase technical debt. While traditional detection relied on manual, rule-based heuristics, the advent of Deep Learning (DL) has transformed Code Smell Detection (CSD) by enabling models to learn complex patterns directly from source code.

However, the effectiveness of these models is governed by the principle of "Garbage In, Garbage Out." If the training data is noisy, imbalanced, or incorrectly labeled, the resulting model will be unreliable. Despite the critical nature of data quality, research often prioritizes novel model architectures over the rigorous process of data preparation. This systematic literature review (SLR) addresses this gap by investigating the workflows, challenges, and solutions involved in building high-quality datasets for DL-based CSD.

Methodology

The authors conducted a Systematic Literature Review following the PICO (Population, Intervention, Comparison, Outcomes) framework. The study began with an initial pool of 1,270 papers sourced from major digital libraries, including IEEE Xplore and ACM Digital Library. Through a rigorous filtering process, 36 primary studies published through December 2023 were selected for in-depth analysis.

The review focused on four distinct phases of the data preparation pipeline:

  1. Data Requirements: Defining the target programming languages and specific smell types.
  2. Data Collection: Sourcing code from real-world repositories versus generating synthetic data.
  3. Data Labeling: Evaluating manual, automatic, and semi-automatic annotation methods.
  4. Data Cleaning: Techniques for removing noise and redundancy to improve model performance.

The Landscape of CSD Datasets

The review provides a comprehensive census of the datasets currently driving CSD research. Several key trends emerged regarding how data is sourced and structured:

The Java Dominance

A significant finding is the overwhelming focus on the Java ecosystem. Out of the 36 studies analyzed, 33 focused exclusively on Java. The Qualitas Corpus remains the most influential dataset, appearing in approximately 15% of the studies. Other prominent benchmarks include LandFill, MUSE, MLCQ, and CodeXGlue. This lack of linguistic diversity suggests a "generalization trap," where models trained on Java may fail to adapt to the syntax and idioms of Python, C#, or C++.

Data Sources

Most researchers (27 papers) rely on real-world data harvested from open-source platforms like GitHub and the Apache Software Foundation. Six studies utilized purely synthetic data—artificially injected smells—while three employed a hybrid approach. While real-world data offers authenticity, it often suffers from extreme class imbalance.

Critical Challenges in Data Preparation

The SLR identified seven primary challenges that complicate the development of robust CSD models:

  • The Labeling Dilemma: Manual labeling by experts is considered the "gold standard" for accuracy but is notoriously difficult to scale. Conversely, automatic labeling using tools like JDeodorant or PMD is fast but introduces "tool bias," where the DL model simply learns to replicate the limitations and errors of the underlying tool.
  • Data Imbalance: In the wild, code smells are rare, often constituting less than 2% of a given dataset. Without intervention, models tend to achieve high accuracy by simply predicting "no smell" for every instance, failing to detect the actual flaws.
  • Data Scarcity and Inaccessibility: High-quality, labeled datasets for specific or obscure smells are rare, and many researchers do not share their final datasets or cleaning scripts, hindering reproducibility.

Emerging Solutions and Best Practices

To combat these challenges, the reviewed studies have proposed several strategic interventions:

  • Semi-Automatic Labeling: The most effective modern studies use a hybrid approach where automated tools generate initial labels, which are then validated or corrected by human experts. This balances scalability with precision.
  • Two-Phase Data Utilization: A clever emerging strategy involves pre-training a model on large volumes of synthetic data to learn basic structural patterns of code smells, followed by fine-tuning on a smaller, high-quality set of real-world examples.
  • Resampling Techniques: To address class imbalance, researchers frequently employ SMOTE (Synthetic Minority Over-sampling Technique) or undersampling of the majority class to ensure the model receives enough exposure to "smelly" instances.
  • Rigorous Data Cleaning: Beyond simple collection, successful models require the removal of "noise," such as comments, blank lines, and non-ASCII characters, which can distract DL architectures from the underlying logic.

Conclusion and Future Outlook

This SLR highlights that while DL-based code smell detection has made significant strides, the field remains heavily dependent on Java-centric datasets and faces persistent labeling hurdles. The authors suggest that the future of CSD lies in three areas:

  1. Leveraging LLMs: Large Language Models offer untapped potential for both automated data labeling and the generation of sophisticated synthetic data.
  2. Multi-Language Research: There is an urgent need to move beyond Java to support the polyglot nature of modern software development.
  3. Transparency: Improved data governance and the open sharing of datasets and preprocessing pipelines are essential for the field to mature and for results to be truly validated.

Summary updated

BibTeX
@article{zhang2024data,
  author = {Fengji Zhang and Zexian Zhang and Jacky Wai Keung and Xiangru Tang and Zhen Yang and Xiao Yu and Wenhua Hu},
  title = {{Data Preparation for Deep Learning based Code Smell Detection: A Systematic Literature Review}},
  journal = {J. Syst. Softw.},
  year = {2024},
  doi = {10.1016/j.jss.2024.112131},
}
Figure