openai / openai-agents-js
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,912 units with 60,543 lines of code in units (72.1% of code).
    • 32 very long units (5,666 lines of code)
    • 118 long units (7,958 lines of code)
    • 652 medium size units (19,925 lines of code)
    • 1,035 small units (15,228 lines of code)
    • 2,075 very small units (11,766 lines of code)
9% | 13% | 32% | 25% | 19%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
ts9% | 13% | 32% | 25% | 19%
js0% | 0% | 0% | 70% | 30%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
packages9% | 13% | 32% | 25% | 19%
.agents0% | 23% | 26% | 33% | 15%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
427 62 1
370 54 3
318 41 1
299 40 7
279 46 9
267 31 1
266 36 6
244 17 1
243 43 1
206 38 1
195 29 1
180 40 3
150 11 2
146 51 1
136 32 2
132 19 1
129 11 2
127 21 1
127 23 1
125 25 2
120 24 1
115 8 4
112 17 1
112 5 0
111 21 5
109 35 1
107 13 2
104 13 6
103 12 6
103 40 1
103 13 2
101 28 3
100 9 1
99 11 1
98 5 2
94 6 4
92 39 1
92 10 1
91 14 3
91 23 1
91 11 1
91 9 2
90 12 1
90 12 1
90 8 1
89 19 1
88 22 5
88 9 4
88 8 1
87 1 3