apple / swift-syntax
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
Unit Size Overall
  • There are 866 units with 3,616 lines of code in units (4.8% of code).
    • 0 very long units (0 lines of code)
    • 2 long units (148 lines of code)
    • 8 medium size units (246 lines of code)
    • 38 small units (498 lines of code)
    • 818 very small units (2,724 lines of code)
0% | 4% | 6% | 13% | 75%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py0% | 26% | 4% | 25% | 42%
swift0% | 0% | 7% | 11% | 81%
c0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
ROOT0% | 40% | 7% | 26% | 26%
Sources/SwiftSyntax0% | 0% | 16% | 29% | 54%
lit_tests0% | 0% | 31% | 14% | 54%
Sources/SwiftSyntaxBuilder/gyb_helpers0% | 0% | 0% | 23% | 76%
Sources/SwiftSyntaxParser0% | 0% | 0% | 64% | 35%
lit_tests/incrParse0% | 0% | 0% | 25% | 74%
Sources/SwiftSyntaxBuilder/gyb_generated0% | 0% | 0% | 0% | 100%
Sources/SwiftSyntax/gyb_generated0% | 0% | 0% | 0% | 100%
Sources/_CSwiftSyntax/src0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def parse_args()
in build-script.py
80 1 0
def main()
in build-script.py
68 14 0
mutating func next()
in Sources/SwiftSyntax/SyntaxClassifier.swift
45 5 0
func test1()
in lit_tests/coloring_configs.swift
42 1 0
func forEachLineLength()
in Sources/SwiftSyntax/SourceLocation.swift
36 8 2
func forEachLineLength()
in Sources/SwiftSyntax/SourceLocation.swift
30 7 2
27 1 2
func formTrailingTrivia()
in Sources/SwiftSyntax/RawSyntax.swift
23 4 0
func index()
in Sources/SwiftSyntax/SyntaxChildren.swift
22 2 1
func f()
in lit_tests/coloring.swift
21 1 1
func formLeadingTrivia()
in Sources/SwiftSyntax/RawSyntax.swift
20 4 0
def run_lit_tests()
in build-script.py
20 5 5
func withLeadingTrivia()
in Sources/SwiftSyntax/RawSyntax.swift
18 4 1
func withTrailingTrivia()
in Sources/SwiftSyntax/RawSyntax.swift
18 4 1
def generate_assert_stmt_text_choices()
in Sources/SwiftSyntaxBuilder/gyb_helpers/SyntaxBuildableWrappers.py
18 6 2
func foo1()
in lit_tests/coloring_configs.swift
17 1 0
def run_xctests()
in build-script.py
16 2 5
func formLayoutArray()
in Sources/SwiftSyntax/RawSyntax.swift
14 3 1
def generate_expr_build_syntax_node()
in Sources/SwiftSyntaxBuilder/gyb_helpers/SyntaxBuildableWrappers.py
14 5 3
func write()
in Sources/SwiftSyntax/RawSyntax.swift
13 2 1