The Impact of Compiler Warnings on Code Quality in C++ Projects
Loading...
Download
Date
Authors
Type
Examensarbete för masterexamen
Master's Thesis
Master's Thesis
Model builders
Journal Title
Journal ISSN
Volume Title
Publisher
Abstract
The usage of compiler warnings has widely been assumed to have a positive effect on code quality, but this notion has little evidence in research. This study investigated the relationship between the usage of compiler warnings and overall code quality in C++ projects. A purposive sampling approach was used to collect 127 C++ projects, which were subsequently analyzed with SonarCloud. Bayesian data analysis was utilized to investigate the correlation between compiler warning usage and measured code quality. The results indicated a correlation between stricter compiler warning usage and improved code quality for some code quality metrics, such as bugs, code smells, and technical debt. Projects that used compiler warnings generally performed better than projects with no warnings enabled, even for code quality metrics that were deemed unlikely to be affected by compiler warnings, such as the number of security hotspots and duplicated lines. Notably, projects that treated warnings as errors performed substantially better than similar projects that did not treat their warnings as errors. One proposed explanation was that this could be caused by a tendency among developers to ignore compiler warnings. It was concluded that the usage of stricter compiler warnings and improved code quality are correlated, while external factors such as engineering culture also likely contributed to the results.
Description
Keywords
compiler warnings, code quality, C++, static code analysis
