Code smells are manifestations of design flaws and bad coding conventions that can degrade code quality.Instead of causing the software to fail directly by general code defects,code smells cause different aspects of quality issues including readability,un-derstandability and efficiency.Especially,code smells also increase the difficulty of software maintenance.Therefore,there is an urgent need to evaluate and detect code smells to improve software quality and save maintenance costs.Nowadays,the study of code smells faces several challenges.On the one hand,the identification of code smells by programmers is subjective,thus there is a lack of effective code smell detection tools.On the other hand,except the code smells caused by bad code structures,the study of code smells ignores many other types of code smells.To this end,this paper explores and mines the history of software maintenance to evaluate and detect the code smells which reduce software maintainability.Firstly,we implement a metric-based technique to detect code smells,and conduct an empirical study to evaluate the effects of code smells on code maintainability.Secondly,in view of the popularity of dynamic typing languages and the increasing demand of users for software performance,we propose two types of code smells caused by dynamic type-aware bad practices and performance problems.For each type of code smells,we develop the tool to detect these code smells and evaluate their negative effects on maintenance activities.The main contributions are summarized as follows:1)For the effectiveness of code smell detection techniques,we implement a metric-based detection tool(named Pysmell)which combines three thresholds strategies to detect 10 kinds of code smells.After mining the history of software maintenance activities,our empirical study evaluates the effectiveness of three thresholds strate-gies and the effects of code smells on code maintainability.The results show that the metric-based detection tool can effectively detect code smells,and code smells are sig-nificantly correlated with code change-proneness and error-proneness.2)For the code smells caused by dynamic type-aware bad practices,we propose six kinds of code smells that are caused by misuse of dynamic typing discipline,and implement the tool to detect the analyzed code smells.Our empirical study combines quantitative and qualitative analysis to investigate the characteristics of the analyzed code smells and evaluate their effects on bugs during software maintenance.The results show that programmers generally introduce the analyzed code smells into software systems during the early development phase,and most kinds of code smells have a significant positive correlation with bugs.3)For the code smells caused by performance problems,we propose and imple-ment a novel approach(named Speedoo)to locate the code smells caused by perfor-mance problems,which also computes the optimization priorities of the located code smells.Then we evaluate the effectiveness and efficiency of Speedoo based on the opti-mization histories of three real-world software systems.The results show that Speedoo outperforms one of the state-of-the-art profiling tools YourKit by 2 to 3 times,and scales to large-scale software systems. |