| Code smell,that is,some poorly designed code segments(Code Smell)in the code program,code smell will cause potential problems in some programs and affect the maintainability of the program,which is one of the causes of software quality decline.The use of mobile devices and mobile software applications has experienced exponential growth worldwide over the past decade.Along with mobile software,there is also Android-specific code smell.Android code smell is different from traditional code smell.Its existence will cause problems such as energy consumption,security,stability,memory and startup time of mobile software.The internal Getter or Setter method smell is one of the Android-specific code smells,and its existence will cause resource leaks(CPU,memory,battery,etc.)to the application program,thereby hindering the sustainable development of the software.And the frequency and quantity of this code smell are much higher than most other code smells,so this article chooses this code smell as the research object.The internal Getter or Setter method smell means that a non-static method in a class accesses the member variables defined in this class by calling the get method or the set method.In an Android application,compared with the way of directly accessing variables,this indirect access will prolong the running time of the program and occupy more system resources.At present,the detection of this kind of smell is mainly based on rule-based methods or manual inspection.These methods use certain rules to detect,but due to different detection rules,some false detections and missed detections will inevitably occur in the results.These methods greatly increase the time and labor costs of smell detection.This paper proposes to use machine learning to detect the smell of the internal Getter or Setter method in the program,and classify and predict the smell by using some classification algorithms and building a deep network.The method proposed in this paper first constructs a data set with internal Getter or Setter methods,converts each sample in the data set into a text form that can contain more program information,and improves the accuracy of the model after training;it proposes a feature screening The algorithm LGM_SU performs feature screening on the converted data set,removes features that are useless for classification,and solves the redundancy problem of features according to the correlation between features;finally,uses the trained model to detect smell and obtain the detection results.Comparing the detection results of this method with the existing detection methods,the detection accuracy and F1 value have been greatly improved. |