Skip to search boxSkip to navigationSkip to main content

High-MCC functions in the Linux Kernel

  • Ahmad Jbara(corresponding author)
    ,
  • Adam Matan
    ,
  • Dror G. Feitelson
*Corresponding author for this work
  • Netanya Academic College
    ,
  • Hebrew University of Jerusalem
Scholary Output:
Contribution to journal
Article
Research
Peer-review

Related Event

Title

2012 20th IEEE International Conference on Program Comprehension, ICPC 2012

Event type

Conference

Date

06/11/2012 - 06/13/2012

Location

PassauGermany

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.

Publication Information

Output type

Scholary Output:
Contribution to journal
Article
Research
Peer-review

Original language

English (US)

Pages from-to (Number of pages)

Pages 1261-1298 (38 pages)

Journal (Volume, Issue Number)

Empirical Software Engineering (Volume 19, Issue 5)

Publication milestones

  • Published - 10/01/2014

Publication status

Published - 10/01/2014

ISSN

1382-3256

Publication IDs

  • Scopus: 84907594352
  • Scopus: 84865019147

Publication metrics

Metrics

SciVal
citations
12
Fractional count
1
Fractional count
0.33
Fractional count
2
Fractional count
0.67
Fractional count
1
Fractional count
1
Scopus
citations
SciVal
FWCI
0.70
SciVal
Author count
3
SciVal
Paper percentile
71

PlumX, opens in new tab

Citation count
16
Captures
22