Font Size: a A A

Research And Implementation Of Code Smells Detection Based On Deep Learning

Posted on:2022-03-10Degree:MasterType:Thesis
Country:ChinaCandidate:S SuFull Text:PDF
GTID:2518306737978909Subject:Computer technology
Abstract/Summary:PDF Full Text Request
The detection of code smells is one of the key steps in refactoring.The software may run successfully even though there are code smells in the source code.However,such software that has code smells can potentially cause deep and serious problems during software maintenance.Dealing with these problems may take programmers a lot of time and money.In recent years,deep learning technology has made a great advance in many domains.By using this technique,we can build the complex mapping between features and predictions automatically.In this paper,we propose a deep learning-based approach to detect six kinds of code smells,i.e.,Intensive Coupling,Dispersed Coupling,Shotgun Surgery,Feature Envy,God Class,and Data Class.In this paper,datasets for detecting these six kinds of code smells are generated first.21 projects are collected from Git Hub to generate train sets and 10 projects are collected to generate test sets.Then we take them as the input of a tool to extract metrics.The classes or methods that have code smells can also be labeled by the tool.We will verify the labeled data manually.After these steps,the test sets are generated.For the train sets,we use under-sampling and over-sampling algorithms to improve the data imbalance in the labeled data.We build a deep learning model that combines the Attention Mechanism and the Convolutional Neural Network(CNN)to detect these six kinds of code smells.The Attention Mechanism is added to the model to assign weights to the metrics so that the important metrics can be captured.The CNN is used to extract features.The metrics are the input of the model.The Attention Mechanism layer will assign weights to the input data.After extracting features by the convolution layer,the flatten layer will make multidimensional data to one-dimensional space.In the end,the dense layer will map the features to the predictions to complete the classification.The experimental results show that the model proposed in this paper for detecting Intensive Coupling,Dispersed Coupling,Feature Envy,God Class,and Data Class has high accuracy.In the detection of Shotgun Surgery,CNN has a better performance.The model proposed in the paper is integrated into a system,and programmers can use the system to detect code smells.This system can provide powerful help for programmers to detect code structure defects.
Keywords/Search Tags:code smell, metric, deep learning, Convolutional Neural Network, Attention Mechanism
PDF Full Text Request
Related items