Understanding Code Smell Detection via Code Review: A Study of the OpenStack Community

Xiaofeng Han, Amjed Tahir, Peng Liang, Steve Counsell, Yajing Luo

Abstract

While automated tools are widely used for code smell detection, they often suffer from high false-positive rates due to a lack of contextual understanding. This paper presents an empirical study of the OpenStack community to investigate how human reviewers identify and address code smells during peer reviews. By analyzing over 300,000 review comments from the Nova and Neutron projects, we find that human reviewers focus on a small subset of smells—primarily duplicated code, bad naming, and dead code—and that developers fix these issues in 86% of cases. Our findings suggest that code smells are often treated as violations of project-specific coding conventions, highlighting the importance of human context in maintaining code quality.

Introduction

In software engineering, "code smells" refer to surface-level indicators of deeper design flaws, such as duplicated code or overly long methods. While not bugs themselves, these smells complicate maintenance and increase the risk of future defects. Static analysis tools like SonarQube or PMD are commonly employed to detect these issues, yet they frequently produce false positives because they lack the project-specific context necessary to distinguish between a legitimate design choice and a genuine flaw.

This study addresses this gap by examining the human element of code smell detection. We explore how often reviewers catch smells during peer reviews, the underlying causes of these smells, and the likelihood of developers addressing them within a large-scale, mature open-source community.

Methodology

The researchers employed a Mining Software Repositories (MSR) approach, analyzing five years of data (2014–2018) from two major OpenStack projects: Nova (compute fabric controller) and Neutron (networking). The process involved several stages of data extraction and refinement to filter relevant discussions from a massive dataset.

Overview of the research methodology and data processing pipeline.

Initially, over 300,000 review comments were mined. To identify relevant discussions, the team used a combination of keyword-based searches (e.g., "dead code", "duplicated") and statistically significant random sampling. This ensured the inclusion of smells described in general or non-technical language. Following this, 19,146 comments underwent manual inspection to verify their relevance to code smells. Finally, a thematic analysis was performed on 1,190 verified smell-related reviews to categorize causes and interaction patterns.

Results and Discussion

The Prevalence of Specific Smells

The study revealed that while academic literature identifies dozens of code smell types, human reviewers focus intensely on a "Big Three": Duplicated Code, Bad Naming, and Dead Code. These categories dominate the discourse in peer reviews, suggesting that reviewers prioritize smells that have a clear impact on readability and maintenance.

Distribution of code smell types identified by reviewers in the OpenStack community.

Smells as Convention Violations

A key insight from the qualitative analysis is that reviewers often frame code smells as violations of project-specific coding conventions rather than abstract design principles. This suggests that the perception of "smelliness" is highly contextual. When a cause was explicitly provided, the most common reason for a smell was a violation of coding conventions (23%), followed by a lack of familiarity with the existing codebase.

Actionability and Mentorship

The interaction between reviewers and developers is highly productive. Developers addressed 86% of the identified code smells. This high fix rate is likely driven by the constructive nature of the feedback; in 35% of cases, reviewers provided specific code snippets or refactoring "recipes." This mentorship role fosters a high level of trust in human-led detection compared to automated tools, as peers understand the project's unique constraints.

Conclusion

Human-led code review is a highly effective mechanism for managing code smells in mature open-source communities like OpenStack. By focusing on high-impact smells and providing actionable, context-aware feedback, reviewers ensure that the vast majority of identified issues are resolved. Future work should investigate whether these patterns hold in different programming languages and less mature development environments, as well as the factors preventing the resolution of the remaining 14% of identified smells, often attributed to technical debt or time constraints.

Summary updated

BibTeX
@inproceedings{han2021understanding,
  author = {Xiaofeng Han and Amjed Tahir and Peng Liang and Steve Counsell and Yajing Luo},
  title = {{Understanding Code Smell Detection via Code Review: A Study of the OpenStack Community}},
  booktitle = {ICPC},
  year = {2021},
  doi = {10.1109/icpc52881.2021.00038},
}
Figure