aws-samples / retail-demo-store
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 566 units with 8,606 lines of code in units (17.2% of code).
    • 6 very long units (891 lines of code)
    • 22 long units (1,405 lines of code)
    • 101 medium size units (3,163 lines of code)
    • 100 small units (1,522 lines of code)
    • 337 very small units (1,625 lines of code)
10% | 16% | 36% | 17% | 18%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py10% | 16% | 36% | 18% | 17%
js25% | 22% | 15% | 9% | 27%
go0% | 11% | 52% | 20% | 16%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
src/aws-lambda12% | 14% | 41% | 19% | 13%
src/web-ui25% | 22% | 15% | 8% | 27%
generators79% | 0% | 20% | 0% | 0%
src/recommendations0% | 29% | 38% | 17% | 13%
src/products0% | 12% | 60% | 17% | 9%
src/users0% | 16% | 45% | 21% | 16%
generators/datagenerator0% | 12% | 6% | 38% | 41%
src/videos0% | 29% | 0% | 32% | 37%
workshop/3-Experimentation0% | 0% | 70% | 0% | 29%
src/carts0% | 0% | 48% | 22% | 28%
src/search0% | 0% | 66% | 0% | 33%
src/orders0% | 0% | 34% | 18% | 47%
src/location0% | 0% | 0% | 40% | 59%
src/offers0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def update()
in src/aws-lambda/personalize-pre-create-campaigns/personalize-pre-create-campaigns.py
223 23 0
def generate_interactions()
in generators/generate_interactions_personalize.py
187 25 3
def lambda_handler()
in src/aws-lambda/pinpoint-auto-workshop/pinpoint-auto-workshop.py
142 15 2
orderCompleted()
in src/web-ui/src/analytics/AnalyticsHandler.js
118 17 3
async identify()
in src/web-ui/src/analytics/AnalyticsHandler.js
112 15 1
productAddedToCart()
in src/web-ui/src/analytics/AnalyticsHandler.js
109 12 6
func UserVerifyAndUpdatePhone()
in src/users/src/users-service/handlers.go
94 11 2
productViewed()
in src/web-ui/src/analytics/AnalyticsHandler.js
81 12 5
cartViewed()
in src/web-ui/src/analytics/AnalyticsHandler.js
78 11 4
checkoutStarted()
in src/web-ui/src/analytics/AnalyticsHandler.js
78 11 4
def handle()
in src/aws-lambda/alexa-skill-lambda/alexa-skill-lambda.py
74 7 2
def get_products()
in src/recommendations/src/recommendations-service/app.py
70 25 8
func createProductsTable()
in src/products/src/products-service/localdev.go
68 4 0
def get_top_n()
in src/recommendations/src/recommendations-service/app.py
65 17 5
def get_ranking()
in src/recommendations/src/recommendations-service/app.py
63 19 6
def lambda_handler()
in src/aws-lambda/pinpoint-recommender/pinpoint-recommender.py
61 2 2
productRemovedFromCart()
in src/web-ui/src/analytics/AnalyticsHandler.js
61 8 4
def coupon_offer()
in src/recommendations/src/recommendations-service/app.py
61 12 0
def handle()
in src/aws-lambda/alexa-skill-lambda/alexa-skill-lambda.py
60 16 2
def __init__()
in generators/datagenerator/users.py
59 3 4