apple / HomeKitADK
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,133 units with 39,888 lines of code in units (69.6% of code).
    • 77 very long units (16,291 lines of code)
    • 102 long units (6,920 lines of code)
    • 334 medium size units (10,444 lines of code)
    • 262 small units (4,003 lines of code)
    • 358 very small units (2,230 lines of code)
40% | 17% | 26% | 10% | 5%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
c41% | 17% | 25% | 9% | 5%
m0% | 0% | 44% | 28% | 26%
h0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
HAP51% | 16% | 22% | 7% | 2%
PAL/Linux21% | 26% | 35% | 10% | 5%
PAL/POSIX21% | 26% | 35% | 10% | 5%
PAL/Raspi21% | 26% | 35% | 10% | 5%
External/JSON91% | 0% | 7% | 0% | <1%
PAL43% | 0% | 7% | 23% | 25%
External/HTTP80% | 0% | 5% | 9% | 5%
Tools/AccessorySetupGenerator100% | 0% | 0% | 0% | 0%
PAL/Mock8% | 23% | 34% | 14% | 19%
External/Base640% | 61% | 38% | 0% | 0%
PAL/Crypto0% | 4% | 31% | 40% | 23%
Applications/Lock0% | 14% | 55% | 18% | 11%
Applications/Lightbulb0% | 18% | 45% | 16% | 19%
Applications0% | 30% | 62% | 0% | 6%
PAL/Darwin0% | 0% | 44% | 28% | 26%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
1450 287 7
718 103 1
static bool AccessoryIsValid()
in HAP/HAPAccessoryValidation.c
650 114 1
size_t util_json_reader_read()
in External/JSON/util_json_reader.c
556 211 3
493 144 5
425 81 6
408 80 5
size_t util_http_reader_read()
in External/HTTP/util_http_reader.c
370 103 3
HAPError HAPBLECharacteristicParseAndWriteValue()
in HAP/HAPBLECharacteristicParseAndWriteValue.c
361 88 9
HAPError HAPBLEAccessoryServerGetAdvertisingParameters()
in HAP/HAPBLEAccessoryServer+Advertising.c
331 27 9
HAPError HAPBLEAccessoryServerDidRaiseEvent()
in HAP/HAPBLEAccessoryServer+Advertising.c
323 47 5
static HAPError HAPPairingPairSetupGetM4()
in HAP/HAPPairingPairSetup.c
315 34 3
static void handle_http_request()
in HAP/HAPIPAccessoryServer.c
291 101 1
HAPError HAPBLECharacteristicReadAndSerializeValue()
in HAP/HAPBLECharacteristicReadAndSerializeValue.c
278 63 6
static HAPError HandleWriteRequest()
in HAP/HAPBLEPeripheralManager.c
273 32 6
int main()
in Tools/AccessorySetupGenerator/Main.c
258 28 2
248 85 4
244 28 6
static void handle_secure_message()
in HAP/HAPIPAccessoryServer.c
230 39 1
209 25 3