The Impact of Compiler Warnings on Code Quality in C++ Projects

Publicerad

Typ

Examensarbete för masterexamen
Master's Thesis

Modellbyggare

Tidskriftstitel

ISSN

Volymtitel

Utgivare

Sammanfattning

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.

Beskrivning

Ämne/nyckelord

compiler warnings, code quality, C++, static code analysis

Citation

Arkitekt (konstruktör)

Geografisk plats

Byggnad (typ)

Byggår

Modelltyp

Skala

Teknik / material

Index

item.page.endorsement

item.page.review

item.page.supplemented

item.page.referenced