openai / role-specific-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 2,072 units with 32,040 lines of code in units (48.3% of code).
    • 23 very long units (5,664 lines of code)
    • 84 long units (5,576 lines of code)
    • 263 medium size units (8,046 lines of code)
    • 416 small units (6,081 lines of code)
    • 1,286 very small units (6,673 lines of code)
17% | 17% | 25% | 18% | 20%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py19% | 19% | 24% | 17% | 19%
cjs28% | 14% | 21% | 18% | 17%
tsx12% | 16% | 27% | 21% | 23%
ts0% | 5% | 31% | 27% | 35%
js0% | 0% | 34% | 31% | 33%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
plugins17% | 17% | 25% | 18% | 20%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
1000 162 0
595 1 0
430 91 0
408 77 0
262 15 1
249 98 2
245 11 1
226 63 1
223 61 10
212 11 4
193 19 1
173 63 2
168 45 1
165 24 0
139 28 2
134 38 2
134 25 2
127 9 3
125 3 3
121 8 0
117 37 2
112 18 10
106 42 3
100 25 0
100 15 1
98 10 0
96 10 0
96 11 2
96 47 5
95 34 2
93 8 1
86 5 0
85 9 0
85 26 2
84 12 1
82 16 3
82 23 3
80 20 0
79 8 1
78 23 2
77 32 1
76 12 3
75 4 3
75 10 0
74 24 0
73 28 2
72 24 0
72 55 2
72 24 4
72 6 2