openai / plugins
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...
  • To learn more about unit size, the Sokrates recommends the following resources:
    • Function Length, MartinFowler.com
      • "If you have to spend effort into looking at a fragment of code to figure out what it's doing, then you should extract it into a function and name the function after that 'what'."
    • Stack Overflow Discussion on Unit Size, stackoverflow.com
      • "Use common sense, stick to small function sizes in most instances but don't be dogmatic about it if you have a genuinely good reason to make an unusually big function."
    • Coding Smells, codinghorror.com
      • "All other things being equal, a shorter method is easier to read, easier to understand, and easier to troubleshoot. Refactor long methods into smaller methods if you can."
    • Clean Code: A Handbook of Agile Software Craftsmanship, by Robert Martin
      • "The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that. Functions should not be 100 lines long. Functions should hardly ever be 20 lines long."
Unit Size Overall
  • There are 3,265 units with 56,596 lines of code in units (51.6% of code).
    • 62 very long units (9,633 lines of code)
    • 166 long units (12,026 lines of code)
    • 541 medium size units (16,236 lines of code)
    • 609 small units (9,102 lines of code)
    • 1,887 very small units (9,599 lines of code)
17% | 21% | 28% | 16% | 16%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py18% | 21% | 27% | 15% | 17%
js9% | 19% | 33% | 20% | 17%
tsx62% | 0% | 17% | 8% | 11%
cjs0% | 45% | 34% | 7% | 12%
ts0% | 0% | 48% | 30% | 21%
swift0% | 0% | 44% | 37% | 18%
smk0% | 0% | 0% | 86% | 13%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
plugins17% | 21% | 28% | 16% | 16%
.agents0% | 27% | 45% | 0% | 27%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
402 31 1
380 112 2
370 101 1
265 33 1
238 48 0
232 25 0
214 38 1
213 27 0
209 60 0
205 41 0
204 10 3
199 46 0
193 41 1
189 20 0
176 19 3
170 13 3
167 40 0
165 9 1
158 17 4
158 1 0
157 43 0
154 1 0
150 49 1
148 18 0
144 42 1
143 11 1
141 27 1
139 21 0
136 33 1
135 23 0
135 20 0
133 46 5
131 25 1
131 1 0
130 22 4
127 19 0
125 28 1
124 36 0
124 14 1
124 15 1
119 41 1
119 17 0
118 22 3
116 45 1
116 27 0
112 20 0
112 14 0
110 52 1
110 2 0
109 29 0