facebook / ThreatExchange
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 2,207 units with 25,687 lines of code in units (56.4% of code).
    • 16 very long units (2,295 lines of code)
    • 79 long units (5,584 lines of code)
    • 198 medium size units (6,066 lines of code)
    • 352 small units (5,167 lines of code)
    • 1,562 very small units (6,575 lines of code)
8% | 21% | 23% | 20% | 25%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
tsx25% | 20% | 25% | 16% | 10%
java14% | 28% | 19% | 19% | 18%
py3% | 16% | 19% | 19% | 41%
rb9% | 48% | 25% | 8% | 8%
php9% | 4% | 40% | 26% | 18%
cpp0% | 28% | 38% | 26% | 7%
c0% | 27% | 38% | 29% | 3%
go0% | 51% | 0% | 0% | 48%
h0% | 0% | 20% | 27% | 51%
js0% | 0% | 0% | 87% | 12%
ts0% | 0% | 0% | 100% | 0%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
hasher-matcher-actioner/webapp25% | 20% | 25% | 17% | 10%
api-reference-examples/java17% | 31% | 16% | 12% | 22%
pdq/java11% | 23% | 24% | 27% | 12%
python-threatexchange/threatexchange5% | 10% | 17% | 13% | 53%
api-reference-examples/python4% | 37% | 22% | 21% | 14%
api-reference-examples/ruby9% | 48% | 25% | 8% | 8%
pdq/php8% | 16% | 45% | 22% | 7%
pdq/python15% | 7% | 12% | 22% | 41%
hasher-matcher-actioner/hmalib0% | 9% | 20% | 20% | 48%
tmk/cpp0% | 29% | 33% | 26% | 10%
pdq/cpp0% | 22% | 39% | 24% | 13%
api-reference-examples/go0% | 51% | 0% | 0% | 48%
api-reference-examples/php0% | 0% | 22% | 42% | 34%
api-reference-examples/js0% | 0% | 0% | 87% | 12%
python-threatexchange/benchmarks0% | 0% | 0% | 48% | 51%
hasher-matcher-actioner/scripts0% | 0% | 0% | 40% | 59%
hasher-matcher-actioner/hmalib_extensions0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
261 8 0
203 12 7
199 8 0
190 49 3
150 28 2
141 1 0
140 15 9
134 31 1
122 13 1
116 32 2
111 6 6
111 24 3
107 8 2
105 12 8
104 4 0
101 39 3
97 24 5
96 39 3
96 23 1
95 23 2
95 23 2
95 19 17
94 19 17
91 20 6
89 1 5
89 12 1
89 32 3
88 5 3
88 23 5
87 26 1
86 10 4
86 5 0
86 21 1
85 24 5
84 12 2
84 10 7
83 11 2
82 24 3
82 26 3
81 40 4
79 22 5
78 5 1
78 6 5
77 24 3
77 10 4
76 3 3
76 12 5
76 9 9
75 12 8
74 6 27