Hist-Inspect: A Tool for History-Sensitive Detection of Code Smells Leandra Mara, Gustavo Honorato, Francisco Dantas, Alessandro Garcia, Carlos Lucena Informatics Department, Pontifical Catholic University of Rio de Janeiro (PUC-Rio) Rio de Janeiro – RJ – Brazil {lsilva,ghonorato,fneto,afgarcia,lucena}@inf.puc-rio.br ABSTRACT Hist-Inspect is a tool that allows the specification and evaluation of different configurations for detection strategies by means of a domain-specific language. The tool enables to easily adjust thresholds and combination of software metrics as well as compare the performance of conventional and history-sensitive detection strategies. The tool also provides a diverse set of views, including graphical representation of module evolution measures. These views enable the code reviewer to reason about the stability of individual modules, the growth or decline of a particular structural property (e.g. coupling or cohesion), without the burden of recovering all the values for each version under analysis. Categories and Subject Descriptors D.2.2 [Design Tools and Techniques]: Modules and interface General Terms Measurement, Experimentation, Design Keywords Metrics, Detection Strategy 1. THE TOOL HIST-INSPECT The conventional wisdom is that many code smells can only be detected by observing the modular structure evolution in a project history. However, there is little empirical knowledge on how the use of module history information can improve the detection of code smells. One of the stumbling blocks for enabling this investigation is the lack of tool support for defining history- sensitive strategies for smell detection. The main goal of the environment Hist-Inspect is to support the implementation and evaluation of history-sensitive strategies for code smell detection. Various complimentary history-sensitive resources are also available, such as graphs that illustrate changes in code properties and metrics. Hist-Inspect supports three main functionalities: visualization of evolution graphs, history-sensitive metrics and definition of detection strategies. A basic step in history-sensitive analysis is the observation of historical data about the evolution behavior of a system and its individual modules. By means of Hist-Inspect graphs, the reviewers can understand the stability variation of a given code property, such as lines of code. They have no need to recover the value of this property in each version. As many smell detection strategies rely on multiple module properties, it is also possible to visualize the behavior of multiple metrics over the module history. More than forty history-sensitive metrics were created in Hist-Inspect and are available to be used in the definition of detection strategies. They measure the evolution of conventional measures, such as cyclomatic complexity and coupling metrics. The current release of Hist-Inspect also enables to import the computation of single-version metrics provided by existing tools [1][2]. In order to enable the declarative specification of different strategy configurations, a domain-specific language was adopted. The goal of such a DSL is to provide a high level of flexibility in defining and tuning these strategies, thus providing a feature that is not found in any of the existing measurement tools. Therefore, Hist-Inspect provides a flexible environment for both developers and researchers to tune and assess their history-sensitive detection strategies. The source code and several artifacts such as screenshots are available at Hist-Inspect website [3]. We have conducted already two exploratory studies [4] on the use of history-sensitive strategies, as supported by Hist-Inspect, to detect code smells. The results were very promising and they consistently outperformed conventional detection strategies [5]. For instance, we found that in seven versions of a system, history- sensitive strategies were more effective in detecting several instances of classical smells, such as God Class, Divergent Change and Shotgun Surgery. New studies need and can be conducted with the support of Hist-Inspect in order to enable us to better understand the role of history-sensitive detection strategies. 2. REFERENCES [1] Together. Website. [Online]. http://www.borland.com/br/products/together/ [2] Incode. Website. [Online]. http://loose.upt.ro/incode/pmwiki.php/ [3] Hist-Inspect. Website [Online]: http://code.google.com/p/hist-inspect (in Portuguese) [4] Mara, L., Dantas, F., Honorato, G., Garcia, A. and Lucena, C. 2010. Detectando anomalias de código em evolução: O que a história pode revelar?. In Proceedings of 4th SBCARS, Salvador, BA, Brazil, 2010. [5] Lanza, M., Marinescu, R. and Ducasse, S. Object-Oriented Metrics in Practice. Secaucus, NJ, USA: Springer-Verlag New York, Inc., 2006. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. AOSD’11, March 21-25, 2011, Pernambuco, Brazil. Copyright 2011 ACM 978-1-4503-0606-5/11/03…$10.00. 65