anthropics / claudes-c-compiler
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,365 units with 69,698 lines of code in units (46.1% of code).
    • 86 very long units (14,460 lines of code)
    • 231 long units (15,521 lines of code)
    • 598 medium size units (19,259 lines of code)
    • 706 small units (10,171 lines of code)
    • 1,744 very small units (10,287 lines of code)
20% | 22% | 27% | 14% | 14%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
rs23% | 24% | 30% | 11% | 9%
h0% | 0% | 5% | 37% | 57%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
src23% | 24% | 30% | 11% | 9%
include0% | 0% | 5% | 37% | 57%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
1188 88 2
527 14 2
333 51 2
291 24 2
276 85 3
269 31 15
242 22 1
231 10 1
227 20 1
215 65 2
210 62 7
209 52 8
201 30 2
200 43 4
198 1 3
196 40 3
191 23 3
184 58 3
182 16 2
182 55 4
182 59 6
181 46 6
181 32 10
180 18 1
180 21 2
178 15 4
174 24 2
171 30 2
167 24 14
164 50 3
162 20 1
161 11 6
157 51 1
157 24 6
157 44 1
156 16 1
152 38 2
144 27 2
144 28 7
144 12 2
143 55 3
143 1 2
136 47 2
131 72 1
131 42 1
130 1 2
128 30 4
127 39 1
127 19 7
127 8 5