aws-samples / serverless-samples
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 93 units with 2,316 lines of code in units (20.5% of code).
    • 1 very long units (642 lines of code)
    • 12 long units (849 lines of code)
    • 16 medium size units (452 lines of code)
    • 12 small units (180 lines of code)
    • 52 very small units (193 lines of code)
27% | 36% | 19% | 7% | 8%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py33% | 37% | 16% | 5% | 6%
js0% | 33% | 31% | 16% | 18%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
serverless-rest-api/python-http-cdk56% | 25% | 12% | 2% | 3%
serverless-rest-api/python-rest-sam0% | 59% | 24% | 7% | 7%
serverless-rest-api/python-http-sam0% | 58% | 25% | 7% | 7%
fargate-rest-api/javascript-rest-nlb-ecs-sam0% | 32% | 31% | 15% | 20%
serverless-rest-api/javascript-http-sam0% | 34% | 32% | 16% | 15%
apigw-private-custom-domain-name/src0% | 0% | 0% | 100% | 0%
lambda-ecs-dual-deploy/3-flask-dual-deployment0% | 0% | 0% | 0% | 100%
lambda-ecs-dual-deploy/2-flask-lambda-container0% | 0% | 0% | 0% | 100%
lambda-ecs-dual-deploy/1-flask-app-container0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def __init__()
in serverless-rest-api/python-http-cdk/lib/serverless_api_stack.py
642 11 5
def lambda_handler()
in serverless-rest-api/python-rest-sam/src/api/bookings.py
84 15 3
def lambda_handler()
in serverless-rest-api/python-http-sam/src/api/bookings.py
81 15 3
def lambda_handler()
in serverless-rest-api/python-http-cdk/src/api/bookings.py
81 11 3
def __init__()
in serverless-rest-api/python-http-cdk/lib/pipeline_stack.py
80 2 4
def lambda_handler()
in serverless-rest-api/python-rest-sam/src/api/resources.py
71 11 3
function processAuthRequest()
in serverless-rest-api/javascript-http-sam/src/api/authorizer.js
71 9 5
function processAuthRequest()
in fargate-rest-api/javascript-rest-nlb-ecs-sam/src/api/authorizer/authorizer.js
71 9 5
def lambda_handler()
in serverless-rest-api/python-http-sam/src/api/resources.py
68 11 3
def lambda_handler()
in serverless-rest-api/python-http-cdk/src/api/resources.py
68 8 3
def lambda_handler()
in serverless-rest-api/python-rest-sam/src/api/locations.py
60 11 3
def lambda_handler()
in serverless-rest-api/python-http-sam/src/api/locations.py
57 11 3
def lambda_handler()
in serverless-rest-api/python-http-cdk/src/api/locations.py
57 8 3
def __init__()
in serverless-rest-api/python-http-cdk/lib/cognito_stack.py
49 1 5
def validate_token()
in serverless-rest-api/python-http-sam/src/api/authorizer.py
34 12 2
def validate_token()
in serverless-rest-api/python-rest-sam/src/api/authorizer.py
34 12 2
def validate_token()
in serverless-rest-api/python-http-cdk/src/api/authorizer.py
34 12 2
def lambda_handler()
in serverless-rest-api/python-http-sam/src/api/authorizer.py
30 5 2
def lambda_handler()
in serverless-rest-api/python-rest-sam/src/api/authorizer.py
30 5 2
def lambda_handler()
in serverless-rest-api/python-http-cdk/src/api/authorizer.py
30 5 2