Supporting the Identification of Architecturally-Relevant Code Anomalies Isela Macia, Roberta Arcoverde, Elder Cirilo, Alessandro Garcia, Arndt von Staa Informatics Department, Pontifical Catholic University of Rio de Janeiro (PUC-Rio), Rio de Janeiro RJ Brazil {ibertran, rarcoverde, ecirilo, afgarcia, arndt}@inf.puc-rio.br AbstractCode anomalies are likely to be critical to the systems' maintainability when they are related to architectural problems. Many tools have been developed to support the identification of code anomalies. However, those tools are restricted to only analyze source code structure and identify individual anomaly occurrences. These limitations are the main reasons why state-of-art tools are often unable to identify architecturally-relevant code anomalies, i.e. those related to architectural problems. To overcome these shortcomings we propose SCOOP, a tool that includes: (i) architecture-code traces in the analysis of the source code, and (ii) exploits relationships between multiple occurrences of code anomalies to detect the architecturally-relevant ones. Our preliminary evaluation indicated that SCOOP was able to detect anomalous code elements related to 293 out of 368 architectural problems found in 3 software systems. Keywords-code anomaly; pattern; architectural problem I. INTRODUCTION Code anomalies, also known as code smells, are recurring code structures which usually make systems more difficult to understand and maintain [1]. Code anomalies are even more severe to the system maintainability when they are related to one or more architectural problems [5][7] - hereafter called architecturally-relevant code anomalies. The reason is that the progressive introduction of architectural problems in the implementation can result in spending a lot of effort even when dealing with simple code changes. In more critical cases, architectural problems can lead to the system discontinuation [5]. Therefore, developers need to be provided with mechanisms that allow them to detect those critical code anomalies as early as possible [7]. However, detecting architecturally-relevant code anomalies is not trivial. Recent studies have shown that looking at individual occurrences of code anomalies is not enough for identifying those that impact on the architectural design [6][7]. The main reason is that a single architecture- level element is usually realized by multiple implementation- level elements. Thus, architectural problems are often associated with inter-related anomalous code elements [7][8]. Additionally, developers cannot distinguish which anomalous code elements are architecturally harmful without considering the role they play in the architectural design. To support code anomalies detection, a wide range of code analysis tools have been developed [9][11][12][15]. These tools are usually focused on the extraction and combination of static code measures to detect potential maintainability problems. However, such state-of-art tools are limited to support the detection of architecturally-relevant code anomalies. First, they only identify individual code anomalies, without analyzing particular relationships between them. Second, they are restricted to analyzing the source code structure, leading to well-known false positives and false negatives [10], and guiding developers in wrong directions when performing maintenance tasks. In this paper we present SCOOP [13], a tool that detects architecturally-relevant code anomalies. Developers might benefit from using SCOOP typically when performing maintenance tasks, like refactoring or modifying existing features. By identifying architecturally-relevant code anomalies, developers can invest their refactoring efforts into solving anomalies that could possibly cause architecture problems, improving refactoring effectiveness. For identifying architecturally-relevant code anomalies, SCOOP’s novelty consists in (i) using architecture information, instead of static analysis only, and (ii) analyzing groups of anomalies for identifying patterns of code anomaly occurrences. SCOOP is implemented as an Eclipse plug-in, allowing developers to use it during the implementation of Java systems. Preliminary results of SCOOPs usage indicated that it was able to detect code anomalies related to 293 out of 368 architectural problems found in 3 software systems. These results indicate that our tool can improve the effectiveness of existing ones [9][11][12][15] and help developers prioritize refactorings during maintenance tasks. II. RELATED WORK A number of tools have been proposed for identifying code anomalies [9][11][12][15]. To this end, most of these tools rely on the use of detection strategies [10] - expressions composed by metrics and thresholds. Each detection strategy aims at identifying occurrences of a specific code anomaly [10]. However, conventional detection strategies suffer from several shortcomings that hinder their support on the identification of architecturally-relevant code anomalies [6]. The main limitation of conventional detection strategies is that they only consider the source code structure, disregarding architectural design information. Additionally, conventional detection strategies only identify individual anomaly occurrences. That is, they do not analyze structural relationships between code anomalies, which could be indicators of the anomaly's adverse influence on the architecture [6]. These limitations lead conventional detection strategies to not inform developers accurately about the presence of architecturally-relevant code anomalies 978-1-4673-2312-3/12/$31.00 ©2012 IEEE