Analyzing the Code Quality of Large Scale Software Packages
Bosco Ndemeye
Committee: Boyana Norris
Directed Research Project(Dec 2021)
Keywords: static analysis, llvm, code quality, clang, metrics

Many popular metrics used for the quantification of the quality or complexity of a codebase (e.g., McCabe’s Cyclomatic Complexity) were developed in the 1970s or 1980s when source code sizes were significantly smaller than theyare today, and before a number of modern programming language features were introduced in different languages. Thus, the many thresholds that were suggested by researchers for deciding whether a given function is lacking in a given quality dimension need to be updated. In the pursuit of this goal, we study a number of open-source high-performance codes, each of which has been in development for more than 15 years—a characteristic, which we take to imply good design and devise a method for identify project-specific thresholds. As such, first, we employ the LLVM/Clang compiler infrastructure and introduce aClang AST tool to gather AST-based metrics, as well as an LLVMIR pass for collecting those based on a source code’s static callgraph. Then we perform statistical analysis to identify reference thresholds of 22 code quality and callgraph-related metrics at the function-level. Next, we show that the gathered function-level data can be used to identify instances of major refactoring during the evolution of a codebase, and lastly we demonstrate how critical functions in source code can be identified and selected for careful study.