Feature envy detection based on cross-graph local semantics matching
As a typical code smell, feature envy occurs when a method exhibits excessive reliance and usage on specific functionalities of another class, which can lead to issues with the maintainability and extensibility of the code. As such, detecting and avoiding feature envy is critical for software develo...
Gespeichert in:
Veröffentlicht in: | Information and software technology 2024-10, Vol.174, p.107515, Article 107515 |
---|---|
Hauptverfasser: | , , , , , |
Format: | Artikel |
Sprache: | eng |
Schlagworte: | |
Online-Zugang: | Volltext |
Tags: |
Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
|
Zusammenfassung: | As a typical code smell, feature envy occurs when a method exhibits excessive reliance and usage on specific functionalities of another class, which can lead to issues with the maintainability and extensibility of the code. As such, detecting and avoiding feature envy is critical for software development. Previous research on detecting feature envy has demonstrated significant advantages of deep learning-based approaches over static code analysis tools. However, current deep learning-based approaches still suffer from two limitations: (1) They focus on the functional or overall semantics of the code, which ignores the opportunities for local code semantics matching, making it challenging to identify some more complex cases; (2) Existing feature envy datasets are collected or synthesized using static code analysis tools, which limits feature envy cases to fixed rules and makes it challenging to cover other complex cases in real projects.
We are motivated to propose a Siamese graph neural network based on code local semantics matching and collect feature envy refactoring cases from real projects for experimental evaluation.
To address the first issue, we propose a cross-graph local semantics matching network, which aims to simulate human intuition or experience to detect feature envy by analyzing the local semantics matching between code graphs. To address the second one, we manually review and collect commits for refactoring feature envy cases on GitHub. Then, we refer to image data augmentation technology to construct two datasets for identifying feature envy and recommending Move Method refactorings, respectively.
Extensive experiments show that our approach outperforms state-of-the-art baselines regarding both tasks’ comprehensive metrics, F1-score and AUC.
The experimental results indicate that the proposed Siamese graph neural network based on code local semantics matching is effective. In addition, the provided data augmentation algorithms can significantly improve model performance. |
---|---|
ISSN: | 0950-5849 1873-6025 |
DOI: | 10.1016/j.infsof.2024.107515 |