apple / swift-package-manager
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 1,054 units with 12,123 lines of code in units (21.3% of code).
    • 4 very long units (490 lines of code)
    • 28 long units (1,943 lines of code)
    • 115 medium size units (3,380 lines of code)
    • 200 small units (2,983 lines of code)
    • 707 very small units (3,327 lines of code)
4% | 16% | 27% | 24% | 27%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
swift4% | 14% | 27% | 25% | 27%
c0% | 38% | 35% | 6% | 19%
py0% | 0% | 0% | 0% | 100%
m0% | 0% | 0% | 0% | 100%
mm0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
Sources/PackageLoading28% | 11% | 21% | 15% | 23%
Sources/PackageCollectionsSigning11% | 7% | 16% | 38% | 25%
Sources/PackageCollections6% | 33% | 28% | 21% | 10%
Sources/PackagePlugin46% | 0% | 26% | 10% | 16%
Sources/Commands0% | 16% | 31% | 26% | 25%
Sources/PackageCollectionsSigningLibc0% | 46% | 42% | 7% | 2%
Sources/Workspace0% | 9% | 35% | 32% | 21%
Sources/SPMBuildCore0% | 24% | 21% | 17% | 36%
Sources/Xcodeproj0% | 27% | 18% | 27% | 27%
Sources/SPMTestSupport0% | 31% | 32% | 17% | 18%
Sources/PackageRegistry0% | 36% | 26% | 6% | 30%
Sources/PackageModel0% | 13% | 40% | 26% | 19%
Sources/PackageGraph0% | 8% | 24% | 20% | 46%
Fixtures/Miscellaneous0% | 0% | 75% | 8% | 15%
Sources/Build0% | 0% | 24% | 37% | 38%
Sources/XCBuildSupport0% | 0% | 27% | 29% | 42%
Sources/SourceControl0% | 0% | 12% | 27% | 59%
Sources/swiftpm-xctest-helper0% | 0% | 87% | 0% | 12%
Sources/PackageFingerprint0% | 0% | 29% | 59% | 11%
Sources/Basics0% | 0% | 0% | 47% | 52%
Sources/SPMPackageEditor0% | 0% | 0% | 35% | 64%
Sources/SPMLLBuild0% | 0% | 0% | 23% | 76%
Fixtures/DependencyResolution0% | 0% | 0% | 48% | 51%
Fixtures/CFamilyTargets0% | 0% | 0% | 0% | 100%
Sources/PackageDescription0% | 0% | 0% | 0% | 100%
Sources/LLBuildManifest0% | 0% | 0% | 0% | 100%
Utilities0% | 0% | 0% | 0% | 100%
Fixtures/Resources0% | 0% | 0% | 0% | 100%
Sources/swiftpm-manifest-tool0% | 0% | 0% | 0% | 100%
Sources/tsan_utils0% | 0% | 0% | 0% | 100%
Fixtures/ModuleMaps0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
func evaluateManifest()
in Sources/PackageLoading/ManifestLoader.swift
145 15 5
func checkStatus()
in Sources/PackageCollectionsSigning/Certificate/CertificatePolicy.swift
123 7 6
func get()
in Sources/PackageCollections/Providers/GitHubPackageMetadataProvider.swift
111 17 4
mutating func target()
in Sources/PackagePlugin/PluginInput.swift
111 20 1
static int asn1_d2i_read_bio()
in Sources/PackageCollectionsSigningLibc/asn1/a_d2i_fp.c
99 28 2
mutating func serialize()
in Sources/SPMBuildCore/PluginInvocation.swift
95 15 1
func appendSetting()
in Sources/Xcodeproj/pbxproj.swift
94 37 4
func performTestsForPlugin()
in Sources/Commands/SwiftPackageTool.swift
86 15 2
func emitAPIBaseline()
in Sources/Commands/APIDigester.swift
84 9 5
func verify()
in Sources/PackageCollectionsSigning/Certificate/CertificatePolicy.swift
81 9 7
func create()
in Sources/SPMTestSupport/MockWorkspace.swift
81 15 3
func downloadAndPopulateCache()
in Sources/PackageRegistry/RegistryDownloadsManager.swift
77 6 7
func listCollections()
in Sources/PackageCollections/API.swift
75 1 2
init()
in Sources/PackageModel/ManifestSourceGeneration.swift
75 22 1
func refreshCollections()
in Sources/PackageCollections/API.swift
71 1 1
func refreshCollection()
in Sources/PackageCollections/API.swift
70 1 2
func findPackage()
in Sources/PackageCollections/Storage/SQLitePackageCollectionsStorage.swift
70 10 3
func addCollection()
in Sources/PackageCollections/API.swift
66 1 4
func handle()
in Sources/Workspace/DefaultPluginScriptRunner.swift
66 16 1
func generate()
in Sources/Commands/GenerateLinuxMain.swift
65 8 0