apple / swift-syntax
Conditional Complexity

The distribution of complexity of units (measured with McCabe index).

Intro
  • Conditional complexity (also called cyclomatic complexity) is a term used to measure the complexity of software. The term refers to the number of possible paths through a program function. A higher value ofter means higher maintenance and testing costs (infosecinstitute.com).
  • Conditional complexity is calculated by counting all conditions in the program that can affect the execution path (e.g. if statement, loops, switches, and/or operators, try and catch blocks...).
  • Conditional complexity is measured at the unit level (methods, functions...).
  • Units are classified in four categories based on the measured McCabe index: 1-5 (simple units), 6-10 (medium complex units), 11-25 (complex units), 26+ (very complex units).
Learn more...
Conditional Complexity Overall
  • There are 866 units with 3,616 lines of code in units (4.8% of code).
    • 0 very complex units (0 lines of code)
    • 0 complex units (0 lines of code)
    • 1 medium complex units (68 lines of code)
    • 4 simple units (97 lines of code)
    • 861 very simple units (3,451 lines of code)
0% | 0% | 1% | 2% | 95%
Legend:
51+
26-50
11-25
6-10
1-5
Alternative Visuals
Conditional Complexity per Extension
51+
26-50
11-25
6-10
1-5
py0% | 0% | 12% | 3% | 84%
swift0% | 0% | 0% | 2% | 97%
c0% | 0% | 0% | 0% | 100%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
ROOT0% | 0% | 18% | 0% | 81%
Sources/SwiftSyntax0% | 0% | 0% | 8% | 91%
Sources/SwiftSyntaxBuilder/gyb_helpers0% | 0% | 0% | 9% | 90%
Sources/SwiftSyntaxBuilder/gyb_generated0% | 0% | 0% | 0% | 100%
Sources/SwiftSyntax/gyb_generated0% | 0% | 0% | 0% | 100%
lit_tests0% | 0% | 0% | 0% | 100%
Sources/SwiftSyntaxParser0% | 0% | 0% | 0% | 100%
lit_tests/incrParse0% | 0% | 0% | 0% | 100%
Sources/_CSwiftSyntax/src0% | 0% | 0% | 0% | 100%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
def main()
in build-script.py
68 14 0
func forEachLineLength()
in Sources/SwiftSyntax/SourceLocation.swift
36 8 2
func forEachLineLength()
in Sources/SwiftSyntax/SourceLocation.swift
30 7 2
mutating func advanceToFirstToken()
in Sources/SwiftSyntax/SyntaxClassifier.swift
13 6 0
def generate_assert_stmt_text_choices()
in Sources/SwiftSyntaxBuilder/gyb_helpers/SyntaxBuildableWrappers.py
18 6 2
mutating func advanceToNextNode()
in Sources/SwiftSyntax/IncrementalParseTransition.swift
9 5 1
func distance()
in Sources/SwiftSyntax/SyntaxChildren.swift
13 5 2
func classify()
in Sources/SwiftSyntax/SyntaxClassifier.swift
10 5 1
mutating func next()
in Sources/SwiftSyntax/SyntaxClassifier.swift
45 5 0
def generate_expr_build_syntax_node()
in Sources/SwiftSyntaxBuilder/gyb_helpers/SyntaxBuildableWrappers.py
14 5 3
def default_initialization()
in Sources/SwiftSyntaxBuilder/gyb_helpers/SyntaxBuildableWrappers.py
11 5 1
def element_in_collections()
in Sources/SwiftSyntaxBuilder/gyb_helpers/SyntaxBuildableWrappers.py
6 5 1
13 5 5
def run_lit_tests()
in build-script.py
20 5 5
func formLeadingTrivia()
in Sources/SwiftSyntax/RawSyntax.swift
20 4 0
func formTrailingTrivia()
in Sources/SwiftSyntax/RawSyntax.swift
23 4 0
func withLeadingTrivia()
in Sources/SwiftSyntax/RawSyntax.swift
18 4 1
func withTrailingTrivia()
in Sources/SwiftSyntax/RawSyntax.swift
18 4 1
func classify()
in Sources/SwiftSyntax/SyntaxClassifier.swift
12 4 3
mutating func advanceToNextToken()
in Sources/SwiftSyntax/SyntaxClassifier.swift
11 4 0