apple / swift-format
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 119 units with 1,014 lines of code in units (10.3% of code).
    • 0 very long units (0 lines of code)
    • 2 long units (115 lines of code)
    • 9 medium size units (216 lines of code)
    • 14 small units (221 lines of code)
    • 94 very small units (462 lines of code)
0% | 11% | 21% | 21% | 45%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py0% | 48% | 0% | 25% | 25%
swift0% | 6% | 24% | 21% | 48%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
ROOT0% | 48% | 0% | 25% | 25%
Sources/generate-pipeline0% | 33% | 42% | 8% | 15%
Sources/SwiftFormatPrettyPrint0% | 0% | 20% | 22% | 56%
Sources/swift-format0% | 0% | 24% | 26% | 48%
Sources/SwiftFormatRules0% | 0% | 16% | 30% | 52%
Sources/SwiftFormat0% | 0% | 53% | 0% | 46%
Sources/SwiftFormatWhitespaceLinter0% | 0% | 0% | 39% | 60%
Sources/SwiftFormatTestSupport0% | 0% | 0% | 0% | 100%
Sources/SwiftFormatCore0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def run()
in build-script-helper.py
61 11 1
func write()
in Sources/generate-pipeline/PipelineGenerator.swift
54 6 1
func insert()
in Sources/SwiftFormatRules/ModifierListSyntax+Convenience.swift
32 3 3
init()
in Sources/SwiftFormatPrettyPrint/Verbatim.swift
25 2 2
func write()
in Sources/generate-pipeline/RuleRegistryGenerator.swift
25 4 1
func write()
in Sources/generate-pipeline/RuleNameCacheGenerator.swift
24 4 1
mutating func next()
in Sources/swift-format/Utilities/FileIterator.swift
24 6 0
func visit()
in Sources/SwiftFormat/Pipelines+Generated.swift
23 1 1
func print()
in Sources/SwiftFormatPrettyPrint/Verbatim.swift
21 7 1
func collect()
in Sources/generate-pipeline/RuleCollector.swift
21 5 1
mutating func validate()
in Sources/swift-format/Subcommands/LintFormatOptions.swift
21 9 0
init()
in Sources/SwiftFormatPrettyPrint/Comment.swift
20 4 2
def parse_args()
in build-script-helper.py
20 2 1
func findTryAwaitExprConnectingToken()
in Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift
19 6 1
func formatAndAppend()
in Sources/SwiftFormatRules/OrderedImports.swift
19 2 1
func run()
in Sources/swift-format/Subcommands/DumpConfiguration.swift
18 3 0
mutating func nodes()
in Sources/SwiftFormatRules/OneVariableDeclarationPerLine.swift
17 4 1
func printDiagnostic()
in Sources/swift-format/Utilities/StderrDiagnosticPrinter.swift
17 6 1
mutating func next()
in Sources/SwiftFormatWhitespaceLinter/LazySplitSequence.swift
16 4 0
func visit()
in Sources/generate-pipeline/PipelineGenerator.swift
14 2 1