aws-samples / serverless-patterns
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 158 units with 4,949 lines of code in units (28.6% of code).
    • 6 very long units (833 lines of code)
    • 21 long units (1,363 lines of code)
    • 58 medium size units (1,953 lines of code)
    • 38 small units (579 lines of code)
    • 35 very small units (221 lines of code)
16% | 27% | 39% | 11% | 4%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
ts28% | 33% | 32% | 4% | <1%
py0% | 15% | 54% | 20% | 8%
cs0% | 79% | 0% | 8% | 12%
js0% | 0% | 40% | 44% | 15%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
apigw-s3-cdk95% | 0% | 0% | 0% | 4%
apig-waf79% | 0% | 20% | 0% | 0%
cdk-cloudfront-to-s3-and-lambda100% | 0% | 0% | 0% | 0%
apigw-http-api-lambda-rds-proxy-cdk100% | 0% | 0% | 0% | 0%
cdk-eventbridge-appsync-oauth55% | 25% | 15% | 0% | 3%
fargate-sns-sqs-cdk100% | 0% | 0% | 0% | 0%
cdk-codecommit-codepipeline-sfn-athena-glue0% | 71% | 15% | 12% | 0%
ta-eventbridge-lambda-s30% | 66% | 0% | 21% | 11%
apigw-to-private-apig-cdk0% | 68% | 31% | 0% | 0%
appsync-dynamodb-singletable-cdk0% | 100% | 0% | 0% | 0%
cdk-eventbridge-appsync0% | 100% | 0% | 0% | 0%
fargate-s3-cdk0% | 100% | 0% | 0% | 0%
apigw-rest-api-dynamodb-cdk0% | 100% | 0% | 0% | 0%
apigw-lambda-dynamodb-cdk0% | 73% | 0% | 13% | 12%
apigw-sns-sqs-lambda-cdk0% | 100% | 0% | 0% | 0%
fargate-sfn-cdk0% | 100% | 0% | 0% | 0%
cdk-vpc-lambda-sfn0% | 52% | 47% | 0% | 0%
apigw-canary-deployment-cdk0% | 50% | 49% | 0% | 0%
apigw-http-api-eventbridge-dotnet-cdk0% | 88% | 0% | 0% | 11%
fargate-sqs-cdk0% | 100% | 0% | 0% | 0%
private-apigw-lambda-cdk0% | 42% | 57% | 0% | 0%
sfn-callback-cdk0% | 77% | 0% | 22% | 0%
parallel-e2e-pipeline-cdk0% | 41% | 27% | 24% | 7%
apigw-http-api-eventbridge-cdk0% | 100% | 0% | 0% | 0%
xray-lambdalayers-cdk-python0% | 77% | 0% | 16% | 6%
cognito-restapi-vpclink0% | 0% | 78% | 10% | 11%
aurora-serverless-s3-ingestion0% | 0% | 87% | 0% | 12%
sqs-lambda-eb-cdk-python0% | 0% | 75% | 9% | 15%
apigw-http-api-lambda-cdk0% | 0% | 100% | 0% | 0%
cdk-eventbridge-stepfunction0% | 0% | 78% | 21% | 0%
apigw-fargate-cdk0% | 0% | 100% | 0% | 0%
auroraserverless-secretsmanager0% | 0% | 100% | 0% | 0%
fargate-dynamodb-cdk0% | 0% | 100% | 0% | 0%
fargate-aurora-serverless-cdk0% | 0% | 100% | 0% | 0%
sfn-inside-sfn-cdk-python0% | 0% | 100% | 0% | 0%
cfn-custom-resource-s3-create0% | 0% | 100% | 0% | 0%
fargate-eventbridge-cdk0% | 0% | 100% | 0% | 0%
fargate-sns-cdk0% | 0% | 100% | 0% | 0%
sfn-glue-sync-cdk0% | 0% | 100% | 0% | 0%
appsync-express-workflow0% | 0% | 100% | 0% | 0%
lambda-dynamodb-cdk0% | 0% | 100% | 0% | 0%
lambda-sns-sms-cdk0% | 0% | 100% | 0% | 0%
iot-lambda-cdk0% | 0% | 90% | 0% | 9%
appsync-eventbridge0% | 0% | 100% | 0% | 0%
sqs-lambda-cdk0% | 0% | 100% | 0% | 0%
sqs-lambda-cdk-python0% | 0% | 90% | 0% | 9%
cdk-lambda-appsync0% | 0% | 100% | 0% | 0%
msk-lambda-cdk0% | 0% | 100% | 0% | 0%
fargate-secretsmanager0% | 0% | 100% | 0% | 0%
sfn-dynamodb-cdk0% | 0% | 100% | 0% | 0%
lambda-cloudwatch-cdk0% | 0% | 65% | 34% | 0%
eventbridge-lambda-cdk0% | 0% | 86% | 0% | 13%
appsync-direct-lambda-resolver0% | 0% | 100% | 0% | 0%
cdk-appsync-sns0% | 0% | 100% | 0% | 0%
eventbridge-cloudwatch-cdk0% | 0% | 100% | 0% | 0%
cdk-appsync-sqs0% | 0% | 100% | 0% | 0%
eventbridge-scheduled-lambda-cdk-typescript0% | 0% | 100% | 0% | 0%
lambda-sns-cdk0% | 0% | 53% | 46% | 0%
lambda-sqs-cdk0% | 0% | 63% | 36% | 0%
cloudfront-lambda-edge-cdk-python0% | 0% | 63% | 36% | 0%
sqs-lambda-dynamodb-cdk0% | 0% | 67% | 32% | 0%
cloudfront-cff-s3-cdk-python0% | 0% | 69% | 0% | 30%
sns-lambda-cdk0% | 0% | 85% | 0% | 14%
eventbridge-sqs-cdk0% | 0% | 100% | 0% | 0%
fargate-cdk0% | 0% | 100% | 0% | 0%
appsync-notify-subscribers-of-database-updates0% | 0% | 0% | 83% | 16%
lambda-efs-cdk0% | 0% | 0% | 62% | 38%
apigw-http-api-lambda-rds-proxy0% | 0% | 0% | 73% | 26%
sfn-log-export0% | 0% | 0% | 58% | 41%
eventbridge-sns-cdk0% | 0% | 0% | 100% | 0%
dynamodb-lambda-cdk0% | 0% | 0% | 100% | 0%
s3-lambda-cdk0% | 0% | 0% | 100% | 0%
rabbitmq-lambda0% | 0% | 0% | 100% | 0%
sns-sqs-cdk0% | 0% | 0% | 100% | 0%
lambda-aurora-serverless0% | 0% | 0% | 100% | 0%
sfn-sqs-cdk0% | 0% | 0% | 100% | 0%
apigw-lambda-cdk0% | 0% | 0% | 100% | 0%
amplify_cognito_apigateway_lambda_envvariables0% | 0% | 0% | 100% | 0%
lambda-lambda0% | 0% | 0% | 100% | 0%
sfn-comprehend-sdk0% | 0% | 0% | 100% | 0%
dynamodb-kinesis-cdk0% | 0% | 0% | 100% | 0%
systems-manager-automation-to-lambda0% | 0% | 0% | 100% | 0%
s3-sqs-cdk0% | 0% | 0% | 100% | 0%
apigw-lambda-qldb0% | 0% | 0% | 0% | 100%
apigw-lambda-dynamodb0% | 0% | 0% | 0% | 100%
lambda-s30% | 0% | 0% | 0% | 100%
sfn-glue-sam0% | 0% | 0% | 0% | 100%
eventbridge-scheduled-lambda0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
constructor()
in apigw-s3-cdk/cdk/lib/apigw-s3-cdk-stack.ts
181 1 3
constructor()
in apig-waf/src/waf/index.ts
152 1 2
constructor()
in cdk-cloudfront-to-s3-and-lambda/cdk/lib/static-site-stack.ts
141 1 3
constructor()
in apigw-http-api-lambda-rds-proxy-cdk/src/lib/rds-proxy-sequelize-stack.ts
132 1 3
constructor()
in cdk-eventbridge-appsync-oauth/cdk/lib/main.ts
118 2 3
constructor()
in fargate-sns-sqs-cdk/cdk/lib/cdk-stack.ts
109 1 3
def __init__()
in ta-eventbridge-lambda-s3/s3_bucket_privatizer/s3_bucket_privatizer_stack.py
96 2 4
constructor()
in apigw-to-private-apig-cdk/src/api/index.ts
91 2 3
constructor()
in appsync-dynamodb-singletable-cdk/cdk/lib/appsync-cdk-stack.ts
88 1 3
constructor()
in cdk-eventbridge-appsync/cdk/lib/main.ts
85 1 3
constructor()
in fargate-s3-cdk/cdk/lib/cdk-stack.ts
73 1 3
constructor()
in apigw-rest-api-dynamodb-cdk/cdk/lib/api-dynamo-stack.ts
69 1 3
internal CdkStack()
in apigw-lambda-dynamodb-cdk/cdk/src/Cdk/CdkStack.cs
68 1 3
constructor()
in apigw-sns-sqs-lambda-cdk/cdk/lib/cdk-apigw-sns-sqs-lambda-stack.ts
64 1 3
constructor()
in fargate-sfn-cdk/cdk/lib/cdk-stack.ts
64 1 3
constructor()
in cdk-vpc-lambda-sfn/src/stacks/vpc_stack.ts
63 3 3
def __init__()
in apigw-canary-deployment-cdk/app.py
62 3 4
internal ApigwHttpApiEventbridgeDotnetCdkStack()
in apigw-http-api-eventbridge-dotnet-cdk/src/ApigwHttpApiEventbridgeDotnetCdk/ApigwHttpApiEventbridgeDotnetCdkStack.cs
61 1 3
constructor()
in fargate-sqs-cdk/cdk/lib/cdk-stack.ts
58 1 3
constructor()
in cdk-codecommit-codepipeline-sfn-athena-glue/src/stacks/stack_glue.ts
55 1 3