Abstract
McCabe’s Cyclomatic Complexity (MCC) is a widely used metric for the complexity of control flow. Common usage decrees that functions should not have an MCC above 50, and preferably much less. However, the Linux kernel includes more than 800 functions with MCC values above 50, and over the years 369 functions have had an MCC of 100 or more. Moreover, some of these functions undergo extensive evolution, indicating that developers are successful in coping with the supposed high complexity. Functions with similarly high MCC values also occur in other operating systems and domains, including Windows. For example, the highest MCC value in FreeBSD is 1316, double the highest MCC in Linux. We attempt to explain all this by analyzing the structure of high-MCC functions in Linux and showing that in many cases they are in fact well-structured (albeit we observe some cases where developers indeed refactor the code in order to reduce complexity). Moreover, human opinions do not correlate with the MCC values of these functions. A survey of perceived complexity shows that there are cases where high MCC functions were ranked as having a low complexity. We characterize these cases and identify specific code attributes such as the diversity of constructs (not only a switch but also ifs) and nesting that correlate with discrete increases in perceived complexity. These observations indicate that a high MCC is not necessarily an impediment to code comprehension, and support the notion that complexity cannot be fully captured using simple syntactic code metrics. In particular, we show that regularity in the code (meaning repetitions of the same pattern of control structures) correlates with low perceived complexity.


























Similar content being viewed by others
Notes
Graphs for all functions analyzed are available at www.cs.huji.ac.il/~ahmadjbara/hiMCC.htm
In this and subsequent figures, we distinguish between development versions of Linux (1.1, 1.3, 2.1, 2.3, and 2.5), production versions (1.0, 1.2, 2.0, 2.2, and 2.4, shown as dashed lines), and the 2.6 series, which combined both types. These are identified only by their minor (third) number. The X axis is calendar years starting with the release of Linux in 1994.
This was chosen to enable them to respond to surprises. Thus if they see a function they think is “very complex” and give it a high mark, and later another that is even much more complex, they can still express this using a value beyond their previously used range.
References
Adams B, De Meuter W, Tromp H, Hassan AE (2009) Can we refactor conditional compilation into aspects? In: 8th Intl. conf. aspect-oriented softw. dev., pp 243–254. doi:10.1145/1509239.1509274
Baggen R, Correia JP, Schill K, Visser J (2012) Standardized code quality benchmarking for improving software maintainability. Software Quality J 20(2):287–307. doi:10.1007/s11219-011-9144-9
Ball T, Larus JR (2000) Using paths to measure, explain, and enhance program behavior. Computer 33(7):57–65. doi:10.1109/2.869371
Bame P (2011) pmccabe. http://parisc-linux.org/~bame/pmccabe/overview.html. Accessed 18 Sept 2011
Binkley AB, Schach SR (1998) Validation of the coupling dependency metric as a predictor of run-time failures and maintenance measures. In: 20th Intl. conf. softw. eng., pp 452–455. doi:10.1109/ICSE.1998.671604
Capiluppi A, Izquierdo-Cortázar D (2013) Effort estimation of FLOSS projects: a study of the Linux kernel. Empir Softw Eng 18(1):60–88. doi:10.1007/s10664-011-9191-7
Curtis B, Sappidi J, Subramanyam J (2011) An evaluation of the internal quality of business applications: does size matter? In: 33rd Intl. conf. softw. eng., pp 711–715. doi:10.1145/1985793.1985893
Curtis B, Sheppard SB, Milliman P (1979) Third time charm: stronger prediction of programmer performance by software complexity metrics. In: 4th Intl. conf. softw. eng., pp 356–360
Denaro G, Pezzè M (2002) An empirical evaluation of fault-proneness models. In: 24th Intl. conf. softw. eng., pp 241–251. doi:10.1145/581339.581371
Dijkstra EW (1968) GoTo statement considered harmful. Commun ACM 11(3):147–148. doi:10.1145/362929.362947
Etsion Y, Tsafrir D, Feitelson DG (2006) Process prioritization using output production: scheduling for multimedia. ACM Trans Multimed Comput Commun Appl 2(4):318–342. doi:10.1145/1201730.1201734
Foreman J, Gross J, Rosenstein R, Fisher D, Brune K (1997) C4 software technology reference guide: a prototype (CMU/SEI-97-HB-001). Retrieved from the Software Engineering Institute, Carnegie Mellon University. http://www.sei.cmu.edu/library/abstracts/reports/97hb001.cfm. Accessed 10 Aug 2013
Harrison W, Magel K, Kluczny R, DeKock A (1982) Applying software complexity metrics to program maintenance. Computer 15(9):65–79. doi:10.1109/MC.1982.1654138
Heitlager I, Kuipers T, Visser J (2007) A practical model for measuring maintainability. In: 6th Intl. conf. quality inf. & comm. tech., pp 30–39. doi:10.1109/QUATIC.2007.8
Herraiz I, Hassan AE (2011) Beyond lines of code: do we need more complexity metrics? In: Oram A, Wilson G (eds) Making software: what really works, and why we believe it. O’Reilly Media Inc., pp 125–141
Hindle A, Godfrey MW, Holt RC (2008) Reading beside the lines: indentation as a proxy for complexity metrics. In: 16th IEEE Intl. conf. program comprehension, pp 133–142. doi:10.1109/ICPC.2008.13
Israeli A, Feitelson DG (2010) The Linux kernel as a case study in software evolution. J Syst Softw 83(3):485–501. doi:10.1016/j.jss.2009.09.042
Jbara A, Feitelson DG 2013 Characterization and assessment of the Linux configuration complexity. In: 13th IEEE Intl. working conf source code analysis & manipulation
Jbara A, Matan A, Feitelson DG (2012) High-MCC functions in the Linux kernel. In: 20th IEEE Intl. conf. program comprehension, pp 83–92. doi:10.1109/ICPC.2012.6240512
Jones C (1994) Software metrics: good, bad, and missing. Computer 27(9):98–100. doi:10.1109/2.312055
Koziolek H, Schlich B, Bilich C (2010) A large-scale industrial case study on architecture-based software reliability analysis. In: 21st Intl. symp. software reliability eng., pp 279–288. doi:10.1109/ISSRE.2010.15
Lanning DL, Khoshgoftaar TM (1994) Modeling the relationship between source code complexity and maintenance difficulty. Computer 27(9):35–40. doi:10.1109/2.312036
Lehman MM, Ramil JF (2003) Software evolution—background, theory, practice. Inf Process Lett 88(1–2):33–44. doi:10.1016/S0020-0190(03)00382-X
Liebig J, Apel S, Lengauer C, Kästner C, Schulze M (2010) An analysis of the variability in forty preprocessor-based software product lines. In: 32nd Intl. conf. softw. eng., vol 1, pp 105–114. doi:10.1145/1806799.1806819
McCabe T (1976) A complexity measure. IEEE Trans Softw Eng 2(4):308–320. doi:10.1109/TSE.1976.233837
McCabe Software (2009) Metrics & thresholds in McCabe IQ. URL: www.mccabe.com/pdf/McCabe%20IQ%20Metrics.pdf. Visited 23 Dec 2009
Mens T, Fernández-Ramil J, Degrandsart S (2008) The evolution of Eclipse. In: Intl. conf. softw. maintenance, pp 386–395. doi:10.1109/ICSM.2008.4658087
MSDN Visual Studio Team System 2008 Development Developer Center (2008) Avoid excessive complexity. URL: msdn.microsoft.com/en-us/library/ms182212.aspx. Visited 23 Dec 2009
Myers GJ (1977) An extension to the cyclomatic measure of program complexity. SIGPLAN Not 12(10):61–64. doi:10.1145/954627.954633
Nagappan N, Ball T, Zeller A (2006) Mining metrics to predict component failures. In: 28th Intl. conf. softw. eng., pp 452–461. doi:10.1145/1134285.1134349
Ohlsson N, Alberg H (1996) Predicting fault-prone software modules in telephone switches. IEEE Trans Softw Eng 22(12):886–894. doi:10.1109/32.553637
Olague HM, Etzkorn LH, Gholston S, Quattlebaum S (2007) Empirical validation of three software metrics suites to predict fault-proneness of object-oriented classes developed using highly iterative or agile software development processes. IEEE Trans Softw Eng 33(6):402–419. doi:10.1109/TSE.2007.1015
Oman P, Hagemeister J (1994) Construction and testing of polynomials predicting software maintainability. J Syst Softw 24(3):251–266. doi:10.1016/0164-1212(94)90067-1
Sauer F (2005) Eclipse metrics plugin 1.3.6. URL metrics.sourceforge.net/. Visited 23 Dec 2009
Schneidewind N, Hinchey M (2009) A complexity reliability model. In: 20th Intl. symp. software reliability eng., pp 1–10. doi:10.1109/ISSRE.2009.10
Shepperd M (1988) A critique of cyclomatic complexity as a software metric. Softw Eng J 3(2):30–36. doi:10.1049/sej.1988.0003
Shepperd M, Ince DC (1994) A critique of three metrics. J Syst Softw 26(3):197–210. doi:10.1016/0164-1212(94)90011-6
Soetens QD, Demeyer S (2010) Studying the effect of refactorings: a complexity metrics perspective. In: 7th Intl. conf. quality inf. & comm. tech., pp 313–318. doi:10.1109/QUATIC.2010.58
Soloway E, Ehrlich K (1984) Empirical studies of programming knowledge. IEEE Trans Softw Eng SE-10(5):595–609. doi:10.1109/TSE.1984.5010283
Stamelos I, Angelis L, Oikonomou A, Bleris GL (2002) Code quality analysis in open source software development. Inf Syst J 12(1):43–60. doi:10.1046/j.1365-2575.2002.00117.x
Stark G, Durst RC, Vowell CW (1994) Using metrics in management decision making. Computer 27(9):42–48. doi:10.1109/2.312037
Vasa R, Lumpe M, Branch P, Nierstrasz O (2009) Comparative analysis of evolving software systems using the Gini coefficient. In: 25th Intl. conf. softw. maintenance, pp 179–188. doi:10.1109/ICSM.2009.5306322
VerifySoft Technology (2005) McCabe metrics. http://www.verifysoft.com/en_mccabe_metrics.html. Accessed 23 Dec 2009
Weyuker EJ (1988) Evaluating software complexity measures. IEEE Trans Softw Eng 14(9):1357–1365. doi:10.1109/32.6178
Ziv J, Lempel A (1978) Compression of individual sequences via variable-rate coding. IEEE Trans Inf Theory IT-24(5):530–536. doi:10.1109/TIT.1978.1055934
Author information
Authors and Affiliations
Corresponding author
Additional information
Communicated by: Michael Godfrey and Arie van Deursen
Rights and permissions
About this article
Cite this article
Jbara, A., Matan, A. & Feitelson, D.G. High-MCC Functions in the Linux Kernel. Empir Software Eng 19, 1261–1298 (2014). https://doi.org/10.1007/s10664-013-9275-7
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10664-013-9275-7