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

Uloženo v:
Podrobná bibliografie
Název: The Impact of Compiler Warnings on Code Quality in C++ Projects
Autoři: Johansson, Albin, Holmberg, Carl, Gomes, Francisco, 1987, Leitner, Philipp, 1982
Zdroj: Utvecklarfokuserad prestandaförbättring för programvaruingenjörer 32nd IEEE/ACM International Conference on Program Comprehension, ICPC 2024, Lisbon, Portugal IEEE International Conference on Program Comprehension. :270-279
Témata: Code Quality, Compiler Warnings, Bayesian Data Analysis
Popis: Modern compilers often offer a variety of warning flags, which developers can enable to get feedback on code that, while syntactically correct, may be problematic. In the case of C++, one example of such 'correct but problematic' code is code that leads to undefined behavior (UB). The usage of compiler warnings has long been suspected as a way to decrease bugs and increase code quality. However, empirical evidence that supports this hypothesis is rare. In this study, we present evidence from a study of 127 open source C++ projects. We categorize their usage of compiler warnings into five groups based on which warning flags are being used, and analyse the relationship between compiler warnings and five quality metrics (bugs, critical issues, vulnerabilities, code smells, and technical debt) using Bayesian analysis. We conclude that, in general, compiler warnings indeed correlate with, and potentially cause, higher code quality, with the clearest impact being on the number of critical issues in a project. Using stricter warning flags expectantly correlates with higher code quality in our study objects. However, there are substantial differences between projects, which we attribute to the project's individual development culture. That is, while warnings matter, other factors such as quality culture, are likely to be even more important to source code quality.
Popis souboru: electronic
Přístupová URL adresa: https://research.chalmers.se/publication/541819
https://research.chalmers.se/publication/541819/file/541819_Fulltext.pdf
Databáze: SwePub
Popis
Abstrakt:Modern compilers often offer a variety of warning flags, which developers can enable to get feedback on code that, while syntactically correct, may be problematic. In the case of C++, one example of such 'correct but problematic' code is code that leads to undefined behavior (UB). The usage of compiler warnings has long been suspected as a way to decrease bugs and increase code quality. However, empirical evidence that supports this hypothesis is rare. In this study, we present evidence from a study of 127 open source C++ projects. We categorize their usage of compiler warnings into five groups based on which warning flags are being used, and analyse the relationship between compiler warnings and five quality metrics (bugs, critical issues, vulnerabilities, code smells, and technical debt) using Bayesian analysis. We conclude that, in general, compiler warnings indeed correlate with, and potentially cause, higher code quality, with the clearest impact being on the number of critical issues in a project. Using stricter warning flags expectantly correlates with higher code quality in our study objects. However, there are substantial differences between projects, which we attribute to the project's individual development culture. That is, while warnings matter, other factors such as quality culture, are likely to be even more important to source code quality.
ISSN:26437147
26437171
DOI:10.1145/3643916.3644410